GliderPRO/Sources/Play.c

1 line
18 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // Play.c //---------------------------------------------------------------------------- //============================================================================ #include <Resources.h> #include "Externs.h" #include "Environ.h" #include "House.h" #include "MainWindow.h" #include "RectUtils.h" #include "Scoreboard.h" #define kHouseBannerAlert 1009 #define kInitialGliders 2 #define kRingDelay 90 #define kRingSpread 25000 // 25000 #define kRingBaseDelay 5000 // 5000 #define kChimeDelay 180 typedef struct { short nextRing; short rings; short delay; } phoneType, *phonePtr; void InitGlider (gliderPtr, short); void SetHouseToFirstRoom (void); void SetHouseToSavedRoom (void); void HandlePlayEvent (void); void PlayGame (void); void HandleRoomVisitation (void); void SetObjectsToDefaults (void); void InitTelephone (void); void HandleTelephone (void); Boolean DoesStarCodeExist (short); short GetNumStarsRemaining (short, short); phoneType thePhone, theChimes; Rect glidSrcRect, justRoomsRect; GWorldPtr glidSrcMap, glid2SrcMap; GWorldPtr glidMaskMap; long gameFrame; short batteryTotal, bandsTotal, foilTotal, mortals; Boolean playing, evenFrame, twoPlayerGame, showFoil, demoGoing; Boolean doBackground, playerSuicide, phoneBitSet, tvOn; extern WindowPtr menuWindow; extern FSSpecPtr theHousesSpecs; extern demoPtr demoData; extern gameType smallGame; extern Rect gliderSrc[kNumGliderSrcRects]; extern Rect boardDestRect, boardSrcRect; extern long incrementModeTime; extern short numBands, otherPlayerEscaped, demoIndex, demoHouseIndex; extern short splashOriginH, splashOriginV, countDown, thisHouseIndex; extern short numStarsRemaining, numChimes, saidFollow; extern Boolean quitting, isMusicOn, gameOver, hasMirror, onePlayerLeft; extern Boolean isPlayMusicIdle, failedMusic, quickerTransitions; extern Boolean switchedOut; //============================================================== Functions //-------------------------------------------------------------- NewGame void NewGame (short mode) { Rect tempRect; Size freeBytes, growBytes; OSErr theErr; Boolean wasPlayMusicPref; AdjustScoreboardHeight(); gameOver = false; theMode = kPlayMode; if (isPlayMusicGame) { if (!isMusicOn) { theErr = StartMusic(); if (theErr != noErr) { YellowAlert(kYellowNoMusic, theErr); failedMusic = true; } } SetMusicalMode(kPlayGameScoreMode); } else { if (isMusicOn) StopTheMusic(); } if (mode != kResumeGameMode) SetObjectsToDefaults(); HideCursor(); if (mode == kResumeGameMode) SetHouseToSavedRoom(); else if (mode == kNewGameMode) SetHouseToFirstRoom(); DetermineRoomOpenings(); NilSavedMaps(); gameFrame = 0L; numBands = 0; demoIndex = 0; saidFollow = 0; otherPlayerEscaped = kNoOneEscaped; onePlayerLeft = false; playerSuicide = false; if (twoPlayerGame) // initialize glider(s) { InitGlider(&theGlider, kNewGameMode); InitGlider(&theGlider2, kNewGameMode); SetPort((GrafPtr)glidSrcMap); LoadGraphic(kGliderPictID); SetPort((GrafPtr)glid2SrcMap); LoadGraphic(kGlider2PictID); } else { InitGlider(&theGlider, mode); SetPort((GrafPtr)glidSrcMap); LoadGraphic(kGliderPictID); SetPort((GrafPtr)glid2SrcMap); LoadGraphic(kGliderFoilPictID); } #if !BUILD_ARCADE_VERSION // HideMenuBarOld(); // TEMP #endif SetPort((GrafPtr)mainWindow); // paint strip on screen black tempRect = thisMac.screen; tempRect.top = tempRect.bottom - 20; // thisMac.menuHigh PaintRect(&tempRect); #ifdef COMPILEQT if ((thisMac.hasQT) && (hasMovie)) { SetMovieGWorld(theMovie, (CGrafPtr)mainWindow, nil); } #endif SetPort((GrafPtr)workSrcMap); PaintRect(&workSrcRect); // if (quickerTransitions) // DissBitsChunky(&workSrcRect); // else // DissBits(&workSrcRect); // DebugStr("\pIf screen isn't black, exit to shell."); // TEMP TEMP TEMP DrawLocale(); RefreshScoreboa