GliderPRO/Sources/Dynamics.c

1 line
19 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // Dynamics.c //---------------------------------------------------------------------------- //============================================================================ #include "Externs.h" #include "Environ.h" #include "MainWindow.h" #include "Objects.h" #include "RectUtils.h" #include "Room.h" #define kShoveVelocity 8 Rect breadSrc[kNumBreadPicts]; extern dynaPtr dinahs; extern bandPtr bands; extern short numBands, tvWithMovieNumber; extern Boolean evenFrame, twoPlayerGame, onePlayerLeft, playerDead; //============================================================== Functions //-------------------------------------------------------------- CheckDynamicCollision // Checks for a collision betwen the glider and one of the dynamic objects. // For example, did the glider hit a flying piece of toast? void CheckDynamicCollision (short who, gliderPtr thisGlider, Boolean doOffset) { Rect dinahRect; dinahRect = dinahs[who].dest; if (doOffset) QOffsetRect(&dinahRect, -playOriginH, -playOriginV); if (SectGlider(thisGlider, &dinahRect, true)) { if ((thisGlider->mode == kGliderNormal) || (thisGlider->mode == kGliderFaceLeft) || (thisGlider->mode == kGliderFaceRight) || (thisGlider->mode == kGliderBurning) || (thisGlider->mode == kGliderGoingFoil) || (thisGlider->mode == kGliderLosingFoil)) { if ((foilTotal > 0) || (thisGlider->mode == kGliderLosingFoil)) { if (IsRectLeftOfRect(&dinahRect, &thisGlider->dest)) thisGlider->hDesiredVel = kShoveVelocity; else thisGlider->hDesiredVel = -kShoveVelocity; if (dinahs[who].vVel < 0) thisGlider->vDesiredVel = dinahs[who].vVel; PlayPrioritySound(kFoilHitSound, kFoilHitPriority); if ((evenFrame) && (foilTotal > 0)) { foilTotal--; if (foilTotal <= 0) StartGliderFoilLosing(thisGlider); } } else { StartGliderFadingOut(thisGlider); PlayPrioritySound(kFadeOutSound, kFadeOutPriority); } } } } //-------------------------------------------------------------- DidBandHitDynamic // Checks to see if a rubber band struck a dynamic. Boolean DidBandHitDynamic (short who) { Rect dinahRect; short i; Boolean collided; dinahRect = dinahs[who].dest; for (i = 0; i < numBands; i++) { if (bands[i].dest.bottom < dinahRect.top) collided = false; else if (bands[i].dest.top > dinahRect.bottom) collided = false; else if (bands[i].dest.right < dinahRect.left) collided = false; else if (bands[i].dest.left > dinahRect.right) collided = false; else collided = true; if (collided) break; } return (collided); } //-------------------------------------------------------------- RenderToast // The following handful of functions handle drawing specific "dynamic" objecsts. void RenderToast (short who) { Rect src, dest; short vClip; if (dinahs[who].moving) { dest = dinahs[who].dest; QOffsetRect(&dest, playOriginH, playOriginV); src = breadSrc[dinahs[who].frame]; vClip = dinahs[who].dest.bottom - dinahs[who].hVel; if (vClip > 0) { src.bottom -= vClip; dest.bottom -= vClip; } CopyMask((BitMap *)*GetGWorldPixMap(toastSrcMap), (BitMap *)*GetGWorldPixMap(toastMaskMap), (BitMap *)*GetGWorldPixMap(workSrcMap), &src, &src, &dest); AddRectToBackRects(&dest); dest = dinahs[who].whole; QOffsetRect(&dest, playOriginH, playOriginV); AddRectToWorkRects(&dest); } } //-------------------------------------------------------------- RenderBalloon void RenderBalloon (short who) { Rect src, dest; if (dinahs[who].moving) { dest = dinahs[who].dest; QOffsetRect(&dest, playOriginH, playOriginV); src = balloonSrc[dinahs[who].frame]; CopyMask((BitMap *)*GetGWorldPixMap(balloonSrcMap), (BitMap *)*GetGWorldPixMap(balloonMaskMap), (BitMap *)*GetGWorldPixMap(workSrcMap), &src, &src, &dest); AddRectTo