-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
81 lines (54 loc) · 1.42 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# include <graphics.h>
# include "frame_timer.h"
# include "menu_scene.h"
# include "game_scene.h"
# include "scene_manager.h"
# include "selector_scene.h"
# include "util.h"
# include "atlas.h"
# include "resource.h"
# include "player.h"
# include "bullet.h"
#pragma comment(lib,"Winmm.lib")
bool is_debug = false;
Player* player_1 = nullptr;
Player* player_2 = nullptr;
Scene* menu_scene = nullptr;
Scene* game_scene = nullptr;
Scene* selector_scene = nullptr;
SceneManager scene_manager;
Camera main_camera;
void init() {
menu_scene = new MenuScene();
game_scene = new GameScene();
selector_scene = new SelectorScene();
rs::load_game_resources();
initgraph(1280, 720);
settextstyle(28, 0, _T("IPix"));
setbkmode(TRANSPARENT);
scene_manager.set_current_scene(menu_scene);
BeginBatchDraw();
}
void loop() {
ExMessage msg;
while (true) {
frame_timer::frame_start_time = GetTickCount();
while (peekmessage(&msg)) {
scene_manager.on_input(msg);
}
static DWORD last_tick_time = GetTickCount();
DWORD current_tick_time = GetTickCount();
DWORD delta_tick = current_tick_time - last_tick_time;
scene_manager.on_update(delta_tick);
last_tick_time = current_tick_time;
cleardevice();
scene_manager.on_draw(main_camera);
FlushBatchDraw();
frame_timer::frame_sleep();
}
}
int main() {
init();
loop();
return 0;
}