GliderPRO/Sources/DynamicMaps.c

1 line
19 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // DynamicMaps.c //---------------------------------------------------------------------------- //============================================================================ #include "Externs.h" #include "Environ.h" #include "MainWindow.h" #include "Objects.h" #include "RectUtils.h" #include "Room.h" #include "Utilities.h" void BackUpFlames (Rect *, short); void BackUpTikiFlames (Rect *, short); void BackUpBBQCoals (Rect *, short); void BackUpPendulum (Rect *, short); void BackUpStar (Rect *, short); sparklePtr sparkles; flyingPtPtr flyingPoints; flamePtr flames, tikiFlames, bbqCoals; pendulumPtr pendulums; starPtr theStars; shredPtr shreds; Rect pointsSrc[15]; short numSparkles, numFlyingPts, numChimes; short numFlames, numSavedMaps, numTikiFlames, numCoals; short numPendulums, clockFrame, numStars, numShredded; extern savedType savedMaps[]; extern Rect flame[], tikiFlame[], coals[], pendulumSrc[]; extern Rect starSrc[]; extern short numGrease, numDynamics; //============================================================== Functions //-------------------------------------------------------------- NilSavedMaps // Deletes array of "dyanmics" offscreen pixmaps. void NilSavedMaps (void) { short i; for (i = 0; i < kMaxSavedMaps; i++) { if (savedMaps[i].map != nil) { DisposeGWorld(savedMaps[i].map); // KillOffScreenPixMap(savedMaps[i].map); savedMaps[i].map = nil; } savedMaps[i].where = -1; savedMaps[i].who = -1; } numSavedMaps = 0; } //-------------------------------------------------------------- BackUpToSavedMap // Saves a copy of the room behind an object to an array of pixmaps. // Then when the object in question is drawn, there is a copy of the<68> // room that it obscured so that, should the player get the object,<2C> // it can be made to "disappear". short BackUpToSavedMap (Rect *theRect, short where, short who) { Rect mapRect; OSErr theErr; if (numSavedMaps >= kMaxSavedMaps) return(-1); mapRect = *theRect; ZeroRectCorner(&mapRect); savedMaps[numSavedMaps].dest = *theRect; // CreateOffScreenPixMap(&mapRect, &savedMaps[numSavedMaps].map); theErr = CreateOffScreenGWorld(&savedMaps[numSavedMaps].map, &mapRect, kPreferredDepth); CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap), GetPortBitMapForCopyBits(savedMaps[numSavedMaps].map), theRect, &mapRect, srcCopy, nil); savedMaps[numSavedMaps].where = where; savedMaps[numSavedMaps].who = who; numSavedMaps++; return (numSavedMaps - 1); // return array index } //-------------------------------------------------------------- ReBackUpSavedMap // This function is similar to the above, but assumes there is already<64> // a slot in the pixmap array for the object. It re-copies the background<6E> // and is needed when the lights in the room go on or off. short ReBackUpSavedMap (Rect *theRect, short where, short who) { Rect mapRect; short i, foundIndex; foundIndex = -1; for (i = 0; i < numSavedMaps; i++) { if ((savedMaps[i].where == where) && (savedMaps[i].who == who)) { foundIndex = i; mapRect = *theRect; ZeroRectCorner(&mapRect); CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap), GetPortBitMapForCopyBits(savedMaps[foundIndex].map), theRect, &mapRect, srcCopy, nil); return (foundIndex); } } return (foundIndex); } //-------------------------------------------------------------- RestoreFromSavedMap // This copies the saved background swatch to the screen - effectively<6C> // covering up or "erasing" the object. void RestoreFromSavedMap (short where, short who, Boolean doSparkle) { Rect mapRect, bounds; short i; for (i = 0; i < numSavedMaps; i++) { if ((savedMaps[i].where == where) && (savedMaps[i].who == who) && (savedMaps[i].map != nil)) { mapRect = savedMaps[i].dest; ZeroRectCorner(&mapRect); CopyBits(GetPortBitMapForCopyBits(savedMaps[i].map), (BitMap *)*Ge