forked from leesihoo0919/CrazzyClimbing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_CrazzyClimbing.cpp
84 lines (59 loc) · 1.53 KB
/
main_CrazzyClimbing.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
79
80
81
82
83
#include "Game.h"
#include "GameIntro.h"
#include "GameHome.h"
#include "GameMode1.h"
#include "GameEnding1.h"
#include "GameMode2.h"
#include "GameEnding2.h"
#include "GameMode3.h"
#include "GameEnding3.h"
/////////////////////////////////////////////////
// Declaration
SDL_Window* g_window;
SDL_Renderer* g_renderer;
bool g_flag_running;
Uint32 g_last_time_ms;
// Game Phases
int g_current_game_phase;
int main(int argc, char* argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();
g_window = SDL_CreateWindow("First Window", 100, 100, 500, 500, 0);
g_renderer = SDL_CreateRenderer(g_window, -1, 0);
InitGame();
PhaseInterface* game_phases[8];
game_phases[0] = new Intro;
game_phases[1] = new Home;
game_phases[2] = new Mode1;
game_phases[3] = new Mode2;
game_phases[4] = new Mode3;
game_phases[5] = new Ending1;
game_phases[6] = new Ending2;
game_phases[7] = new Ending3;
g_current_game_phase = PHASE_INTRO;
while (g_flag_running)
{
Uint32 cur_time_ms = SDL_GetTicks();
if (cur_time_ms - g_last_time_ms < 33)
continue;
game_phases[g_current_game_phase]->HandleEvents();
game_phases[g_current_game_phase]->Update();
game_phases[g_current_game_phase]->Render();
g_last_time_ms = cur_time_ms;
}
delete game_phases[0];
delete game_phases[1];
delete game_phases[2];
delete game_phases[3];
delete game_phases[4];
delete game_phases[5];
delete game_phases[6];
delete game_phases[7];
ClearGame();
SDL_DestroyRenderer(g_renderer);
SDL_DestroyWindow(g_window);
Mix_CloseAudio();
SDL_Quit();
return 0;
}