/** * 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; }
/** * 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; } }
/** * See if the actor on whom the camera is is approaching an edge. * Request a scroll if he is. */ static void MonitorScroll() { int newx, newy; int Loffset, Toffset; /* * Only do it if the actor is there and is visible */ if (!g_pScrollMover || MoverHidden(g_pScrollMover) || !MoverIs(g_pScrollMover)) return; GetActorPos(g_scrollActor, &newx, &newy); if (g_oldx == newx && g_oldy == newy) return; PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); /* * Approaching right side or left side of the screen? */ if (newx > Loffset+SCREEN_WIDTH - RLDISTANCE && Loffset < g_ImageW - SCREEN_WIDTH) { if (newx > g_oldx) NeedScroll(LEFT); } else if (newx < Loffset + RLDISTANCE && Loffset) { if (newx < g_oldx) NeedScroll(RIGHT); } /* * Approaching bottom or top of the screen? */ if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < g_ImageH-SCREEN_HEIGHT) { if (newy > g_oldy) NeedScroll(UP); } else if (Toffset && newy < Toffset + UDISTANCE + GetActorBottom(g_scrollActor) - GetActorTop(g_scrollActor)) { if (newy < g_oldy) NeedScroll(DOWN); } g_oldx = newx; g_oldy = newy; }
/** * 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! }
/** * 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; } }