-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainGame.cpp
79 lines (64 loc) · 1.34 KB
/
mainGame.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
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "LTexture.h"
#include "pacman.h"
#include "creatWallandPoint.h"
#include "InitCloseSDL.h"
#include "externVariables.h"
#include "renderGame.h"
#include "Motion_Collision.h"
using namespace std;
int main( int argc, char* args[] )
{
srand(time(NULL));
//Start up SDL and create window
if( !init() )
{
printf( "Failed to initialize!\n" );
return 0;
}
//Load media
if( !loadMedia() )
{
printf( "Failed to load media!\n" );
return 0;
}
//Load sound
if( !loadSound() )
{
printf( "Failed to load music!\n" );
return 0;
}
//Main loop flag
bool quit = false;
//Create Walls
createWalls();
createPoint();
//Create Pacman & Ghost Animation & Point
getPacmanAnimation();
getGhostAnimation();
//Play opening music
RenderGame();
Mix_PlayChannel(1, opening, 0);
while(Mix_Playing(1) != 0)
{
SDL_Delay(200);
}
//Play theme music
Mix_PlayMusic( theme, -1 );
//Game loop
while( !quit )
{
//Handle Events from keyboard
handleEvent(quit);
//Handle motion and collision
Motion_Collision(quit);
//Render Game
RenderGame();
if (quit == true)
{
isPlayAgain(quit);
}
}
//Free resources and close SDL
close();
return 0;
}