GliderPRO/Sources/Dynamics3.c

1 line
15 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // Dynamics3.c //---------------------------------------------------------------------------- //============================================================================ #include "Externs.h" #include "RectUtils.h" #define kBalloonStart 310 #define kCopterStart 8 #define kDartVelocity 6 dynaPtr dinahs; short numDynamics; extern Rect breadSrc[]; extern short numLights; extern Boolean evenFrame; //============================================================== Functions //-------------------------------------------------------------- HandleDynamics // This is the master function that calls all the specific handlers above. void HandleDynamics (void) { short i; for (i = 0; i < numDynamics; i++) { switch (dinahs[i].type) { case kSparkle: HandleSparkleObject(i); break; case kToaster: HandleToast(i); break; case kMacPlus: HandleMacPlus(i); break; case kTV: HandleTV(i); break; case kCoffee: HandleCoffee(i); break; case kOutlet: HandleOutlet(i); break; case kVCR: HandleVCR(i); break; case kStereo: HandleStereo(i); break; case kMicrowave: HandleMicrowave(i); break; case kBalloon: HandleBalloon(i); break; case kCopterLf: case kCopterRt: HandleCopter(i); break; case kDartLf: case kDartRt: HandleDart(i); break; case kBall: HandleBall(i); break; case kDrip: HandleDrip(i); break; case kFish: HandleFish(i); break; default: break; } } } //-------------------------------------------------------------- HandleDynamics // This is the master function that calls all the various rendering handlers<72> // above. void RenderDynamics (void) { short i; for (i = 0; i < numDynamics; i++) { switch (dinahs[i].type) { case kToaster: RenderToast(i); break; case kBalloon: RenderBalloon(i); break; case kCopterLf: case kCopterRt: RenderCopter(i); break; case kDartLf: case kDartRt: RenderDart(i); break; case kBall: RenderBall(i); break; case kDrip: RenderDrip(i); break; case kFish: RenderFish(i); break; default: break; } } } //-------------------------------------------------------------- ZeroDinahs // This clears all dynamics - zeros them all out. Used to initialize them. void ZeroDinahs (void) { short i; for (i = 0; i < kMaxDynamicObs; i++) { dinahs[i].type = kObjectIsEmpty; QSetRect(&dinahs[i].dest, 0, 0, 0, 0); QSetRect(&dinahs[i].whole, 0, 0, 0, 0); dinahs[i].hVel = 0; dinahs[i].vVel = 0; dinahs[i].count = 0; dinahs[i].frame = 0; dinahs[i].timer = 0; dinahs[i].position = 0; dinahs[i].room = 0; dinahs[i].byte0 = 0; dinahs[i].active = false; } numDynamics = 0; } //-------------------------------------------------------------- AddDynamicObject // When a room is being drawn, various dynamic objects are pointed here. // This function sets up the structures to handle them. short AddDynamicObject (short what, Rect *where, objectType *who, short room, short index, Boolean isOn) { short position, velocity; Boolean lilFrame; if (numDynamics >= kMaxDynamicObs) return (-1); dinahs[numDynamics].type = what; switch (what) { case kSparkle: dinahs[numDynamics].dest = sparkleSrc[0]; ZeroRectCorner(&dinahs[numDynamics].dest); QOffsetRect(&dinahs[numDynamics].dest, where->left, where->top); dinahs[numDynamics].whole = dinahs[numDynamics].dest; dinahs[numDynamics].hVel = 0; dinahs[numDynamics].vVel = 0; dinahs[numDynamics].count = 0; dinahs[numDynamics].frame = 0; dinahs[numDynamics].timer = RandomInt(60) + 15; dinahs[numDynamics].position = 0; dinahs[numDynamics].room = room; dinahs[numDynamics].byte0 = (Byte)index; dinahs[numDynamics].byte1 = 0; dinahs[numDynamics].