Pararena2/Sources/PlayCore.c

1 line
14 KiB
C
Raw Permalink Normal View History

/*============================================================*/ /*============================================================*/ /*== ==*/ /*== Play Handling Core Routines ==*/ /*== ==*/ /*============================================================*/ /*============================================================*/ /*======================================================== Includes */ #include "AppleTalkDDP.h" #include "Globals.h" #include "UnivUtilities.h" #include "PlayCore.h" #include "NetOpponent.h" #include "SoundUtils.h" #include "MainWindow.h" #include "PlayUtils.h" #include "RenderQD.h" #include "Replay.h" #include "CommonPerson.h" #include "Human.h" #include "Dynamics.h" #include "Render.h" #include "Ball.h" /*======================================================== Functions */ /*======================================================== DoCommandKey */ void DoCommandKey (void) { #define kNoThanksButton 1 short response; Boolean dummyBool; if (BitTst(&theKeyMap, kQKeyMap)) /* is -Q- key held down? */ { quitting = TRUE; primaryMode = kIdleMode; if (netGameInSession) dummyBool = SendModalMessage(kAbortGameMessage); } if (BitTst(&theKeyMap, kEKeyMap)) /* is -E- key held down? */ { if ((whichGame == kTournament) && (!gameIsOver)) { timePaused = Ticks; FlushSoundQueues(); StopCrowdSound(); TurnSMSOff(); InitCursor(); FlushEvents(everyEvent, kRemoveAllEvents); CenterAlert(rAbortGameAlertID); response = Alert(rAbortGameAlertID, kNilPointer); TurnSMSOn(); RefreshMainWindow(); ResumeCrowdSound(); UpdatePlayerScore(); UpdateOpponentScore(); timePaused = Ticks - timePaused; baseTime += timePaused / 60; RedrawWholeScreen(); HideCursor(); if (response == kNoThanksButton) { return; } else { playerWonTheGame = kOpponentWon; UpdateStats(); UpdateWorldRecords(); primaryMode = kIdleMode; } } else { primaryMode = kIdleMode; if (netGameInSession) { dummyBool = SendModalMessage(kAbortGameMessage); } } } } /*======================================================== DoPausing */ void DoPausing (void) { if (!netGameInSession) { pausing = TRUE; timePaused = Ticks; } } /*======================================================== UnPauseGame */ void UnPauseGame (void) { TurnSMSOn(); HideMenuBar((GrafPtr)mainWndo); EraseMenuBarRect(); RefreshMainWindow(); ResumeCrowdSound(); UpdatePlayerScore(); UpdateOpponentScore(); timePaused = Ticks - timePaused; baseTime += timePaused / 60; RedrawWholeScreen(); HideCursor(); } /*======================================================== DoSpecial */ void DoSpecial (void) { Point theMouse; GetMouse(&theMouse); LocalToGlobal(&theMouse); theMouse.h -= displayHCenter; theMouse.v -= displayVCenter; theBall.xPos = theMouse.h * 128; theBall.zPos = -theMouse.v * 128; theBall.xVel = 0; theBall.zVel = 0; } /*======================================================== DoSoundToggle */ void DoSoundToggle (void) { soundOn = !soundOn; if (soundOn) { StartCrowdSound(); } else { StopCrowdSound(); } while (BitTst(&theKeyMap, kSKeyMap)) GetKeys(theKeyMap); } /*======================================================== CheckAbortiveInput */ void CheckAbortiveInput (void) { Boolean confirmed; GetKeys(theKeyMap); if (BitTst(&theKeyMap, kCommandKeyMap)) DoCommandKey(); if (BitTst(&theKeyMap, kTabKeyMap)) DoPausing(); if (BitTst(&theKeyMap, kSKeyMap)) DoSoundToggle(); if ((replayOnR) && (BitTst(&theKeyMap, kRKeyMap))) { if (netGameInSession) { confirmed = SendModalMessage(kInstantReplayMessage); } DoInstantReplay(); } if (BitTst(&theKeyMap, kOptionKeyMap) && BitTst(&theKeyMap, kZKeyMap)) DoSpecial(); } /*======================================================== HandleTimerEtc */ void HandleTimerEtc (void) { if (replaySomething) { replayFlag++; if (replayFlag == 0) DoInstantReplay(); } theDoo