コード例 #1
0
ファイル: actors.cpp プロジェクト: AdamRi/scummvm-pink
/**
 * Given cursor position and an actor number, ascertains
 * whether the cursor is within the actor's tag area.
 * Returns True for a positive result, False for negative.
 */
bool InHotSpot(int ano, int curX, int curY) {
	int	aTop, aBot;	// Top and bottom limits }
	int	aHeight;	// Height		 } of active area
	int	aLeft, aRight;	// Left and right	 }
	int	aWidth;		// Width		 }
	unsigned topEighth, botEighth, leftEighth, rightEighth;

	// First check if within broad range
	if (curX < (aLeft = GetActorLeft(ano))		// too far left
		||  curX > (aRight = GetActorRight(ano))	// too far right
		||  curY < (aTop = GetActorTop(ano))		// too high
		||  curY > (aBot = GetActorBottom(ano)) )	// too low
			return false;

	GetActorTagPortion(ano, &topEighth, &botEighth, &leftEighth, &rightEighth);

	aWidth = aRight - aLeft;
	aLeft += ((leftEighth - 1)*aWidth)/8;
	aRight -= ((8 - rightEighth)*aWidth)/8;

	// check if within x-range
	if (curX < aLeft || curX > aRight)
		return false;

	aHeight = aBot - aTop;
	aTop += ((topEighth - 1)*aHeight)/8;
	aBot -= ((8 - botEighth)*aHeight)/8;

	// check if within y-range
	if (curY < aTop || curY > aBot)
		return false;

	return true;
}
コード例 #2
0
ファイル: pdisplay.cpp プロジェクト: AReim1982/scummvm
/**
 * Given cursor position and an actor number, ascertains whether the
 * cursor is within the actor's tag area.
 * Returns TRUE for a positive result, FALSE for negative.
 * If TRUE, the mid-top co-ordinates of the actor's tag area are also
 * returned.
 */
static bool InHotSpot(int ano, int aniX, int aniY, int *pxtext, int *pytext) {
	int	Top, Bot;		// Top and bottom limits of active area
	int	left, right;	// left and right of active area
	int	qrt = 0;		// 1/4 of height (sometimes 1/2)

	// First check if within x-range
	if (aniX > (left = GetActorLeft(ano)) && aniX < (right = GetActorRight(ano))) {
		Top = GetActorTop(ano);
		Bot = GetActorBottom(ano);

		// y-range varies according to tag-type
		switch (TagType(ano)) {
		case TAG_DEF:
			// Next to bottom 1/4 of the actor's area
			qrt = (Bot - Top) >> 1;		// Half actor's height
			Top += qrt;			// Top = mid-height

			qrt = qrt >> 1;			// Quarter height
			Bot -= qrt;			// Bot = 1/4 way up
			break;

		case TAG_Q1TO3:
			// Top 3/4 of the actor's area
			qrt = (Bot - Top) >> 2;		// 1/4 actor's height
			Bot -= qrt;			// Bot = 1/4 way up
			break;

		case TAG_Q1TO4:
			// All the actor's area
			break;

		default:
			error("illegal tag area type");
		}

		// Now check if within y-range
		if (aniY >= Top && aniY <= Bot) {
			if (TagType(ano) == TAG_Q1TO3)
				*pytext = Top + qrt;
			else
				*pytext = Top;
			*pxtext = (left + right) / 2;
			return true;
		}
	}
コード例 #3
0
ファイル: actors.cpp プロジェクト: AdamRi/scummvm-pink
/**
 * Returns the position of the mid-top of the actor.
 * Delegate the task for moving actors.
 * @param ano			Actor Id
 * @param x				Output x
 * @param y				Output y
 */
void GetActorMidTop(int ano, int *x, int *y) {
	// Not used in JAPAN version
	PMOVER pActor;

	assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // unknown actor

	pActor = GetMover(ano);

	if (pActor)
		GetMoverMidTop(pActor, x, y);
	else if (TinselV2) {
		*x = (GetActorLeft(ano) + GetActorRight(ano)) / 2;
		*y = GetActorTop(ano);
	} else if (actorInfo[ano - 1].presObj) {
		*x = (MultiLeftmost(actorInfo[ano - 1].presObj)
		      + MultiRightmost(actorInfo[ano - 1].presObj)) / 2;
		*y = MultiHighest(actorInfo[ano - 1].presObj);
	} else
		GetActorPos(ano, x, y);		// The best we can do!
}
コード例 #4
0
ファイル: actors.cpp プロジェクト: AdamRi/scummvm-pink
/**
 * GetActorTagPos
 */
void GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute) {
	unsigned topEighth, botEighth;
	int	aTop;		// Top and bottom limits }
	int	aHeight;	// Height		 } of active area
	int	Loffset, Toffset;

	GetActorTagPortion(actor, &topEighth, &botEighth, (unsigned *)&Loffset, (unsigned *)&Toffset);

	aTop = GetActorTop(actor);
	aHeight = GetActorBottom(actor) - aTop;
	aTop += ((topEighth - 1) * aHeight) / 8;

	*pTagX = ((GetActorLeft(actor) + GetActorRight(actor)) / 2);
	*pTagY = aTop;

	if (!bAbsolute) {
		PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
		*pTagX -= Loffset;
		*pTagY -= Toffset;
	}
}