-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
65 lines (58 loc) · 2.01 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This is the main file to hold everthing together
#include "Framework\timer.h"
#include "game.h"
#include "GameUI.h"
#include "Framework\console.h"
#include <Windows.h>
#include "ai.h"
#include "survival.h"
#include "coop.h"
#include "infection.h"
#include "animation.h"
CStopWatch g_Timer; // Timer function to keep track of time and the frame rate
bool g_bQuitGame = false; // Set to true if you want to quit the game
const unsigned char gc_ucFPS = 15; // FPS of this game
const unsigned int gc_uFrameTime = 1000 / gc_ucFPS; // time for each frame
short sPacMap[21][38];
extern COORD monster1;
extern int score;
extern int score2;
extern Console console;
stage state=INIT_intro;
extern PMAP pacMap;
extern PMAP pacMap2;
extern PMAP pacMap3;
//function declarations
void mainLoop();
// TODO:
// Bug in waitUnitil. it waits for the time from getElapsedTime to waitUntil, but should be insignificant.
// main function - starting function
//Done By Daniel(Leader)
int main( void )
{
init(); // initialize your variables
mainLoop(); // main loop
shutdown(); // do clean up, if any. free memory.
free_map(pacMap);
free_map(pacMap2);
free_map(pacMap3);
return 0;
}
//--------------------------------------------------------------
// Purpose : This main loop calls functions to get input,
// update and render the game at a specific frame rate
// Input : void
// Output : void
//--------------------------------------------------------------
//Done By Daniel(Leader)
void mainLoop()
{
g_Timer.startTimer(); // Start timer to calculate how long it takes to render this frame
while (!g_bQuitGame) // run this loop until user wants to quit
{
getInput(); // get keyboard input
update(g_Timer.getElapsedTime(),state); // update the game
render(state); // render the graphics output to screen
g_Timer.waitUntil(gc_uFrameTime); // Frame rate limiter. Limits each frame to a specified time in ms.
}
}