mirror of
https://github.com/softdorothy/Glypha3.git
synced 2024-06-18 12:29:31 +00:00
1 line
43 KiB
C
1 line
43 KiB
C
|
//============================================================================
//----------------------------------------------------------------------------
// Play.c
//----------------------------------------------------------------------------
//============================================================================
// This (rather large) file handles all player routines while a game is in<69>
// progress. It gets the player's input, moves the player, tests for collisions<6E>
// and generally handles the "main game loop". Enemies and actually drawing<6E>
// the graphics to the screen are handled in other files.
#include "Externs.h"
#define kFlapImpulse 48
#define kGlideImpulse 12
#define kAirResistance 2
#define kMaxHVelocity 192
#define kMaxVVelocity 512
#define kNumLightningStrikes 5
void SetUpLevel (void);
void ResetPlayer (Boolean);
void OffAMortal (void);
void DoCommandKey (void);
void GetPlayerInput (void);
void HandlePlayerIdle (void);
void HandlePlayerFlying (void);
void HandlePlayerWalking (void);
void HandlePlayerSinking (void);
void HandlePlayerFalling (void);
void HandlePlayerBones (void);
void MovePlayer (void);
void CheckTouchDownCollision (void);
void CheckPlatformCollision (void);
void KeepPlayerOnPlatform (void);
void CheckLavaRoofCollision (void);
void SetAndCheckPlayerDest (void);
void HandleLightning (void);
void FinishLightning (void);
void HandleCountDownTimer (void);
void CheckHighScore (void);
playerType thePlayer;
enemyType theEnemies[kMaxEnemies];
KeyMap theKeys;
Rect platformRects[6], touchDownRects[6], enemyRects[24];
Rect enemyInitRects[5];
long theScore, wasTensOfThousands;
short numLedges, beginOnLevel, levelOn, livesLeft, lightH, lightV;
short lightningCount, numEnemies, countDownTimer;
Boolean playing, pausing, flapKeyDown, evenFrame;
Boolean doEnemyFlapSound, doEnemyScrapeSound;
extern handInfo theHand;
extern prefsInfo thePrefs;
extern Rect playerRects[11], mainWindowRect;
extern short numUpdateRects1, numUpdateRects2, numOwls;
extern Boolean quitting, openTheScores;
//============================================================== Functions
//-------------------------------------------------------------- InitNewGame
// This funciton sets up variables and readies for a new game. It is called<65>
// only when a the user selects "New Game" - during the course of a game, it<69>
// is not called again.
void InitNewGame (void)
{ // Initialize a number of game variables.
countDownTimer = 0; // Zero count down timer.
numLedges = 3; // Initial number of ledges (platforms).
beginOnLevel = 1; // Ledge (platform) the player is on (center ledge).
levelOn = 0; // Game level on (first level).
livesLeft = kInitNumLives; // Number of player lives remaining.
theScore = 0L; // Player's score (a long - can go to 2 billion).
playing = TRUE; // Flag playing.
pausing = FALSE; // Not paused.
evenFrame = TRUE; // Set an initial state for evenFrame.
wasTensOfThousands = 0L; // Used for noting when player gets an extra life.
numOwls = 4; // Number of "owl" enemies for this level.
numUpdateRects1 = 0; // Init number of "update" rectangles.
numUpdateRects2 = 0; // (see Render.c to see what these do)
InitHandLocation(); // Get the mummy hand down in the lava.
theHand.mode = kLurking; // Flag the hand in "lurking" mode.
SetUpLevel(); // Set up platforms for first level (wave).
DumpBackToWorkMap(); // Copy background offscreen to "work" offscreen.
UpdateLivesNumbers(); // Display number of lives remaining on screen.
UpdateScoreNumbers(); // Display the player's score (zero at this point).
UpdateLevelNumbers(); // Display the level (wave) the player is on.
GenerateEnemies(); // Prepare all enemies for this level.
ResetPlayer(TRUE); // Initialize all player variables and put on ledge.
}
//-------------------------------------------------------------- SetUpLevel
// Primarily, this function is called to set up the ledges for the<68>
// current level (wave) the player is on. It determines how many<6E>
// a
|