-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (56 loc) · 1.23 KB
/
main.cpp
File metadata and controls
60 lines (56 loc) · 1.23 KB
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
#include "game.h"
void init();
void deinit();
int main() {
init();
preload();
// Music
bool playMusic = true;
if (playMusic) {
if (!musica) allegro_message("Couldn't load midi!");
else play_midi(musica, TRUE);
set_volume(200, 150);
}
// Main loop
do {
Sleep(SPEED);
if (!gameStarted) {
titleScreen();
if (quitGame) break;
} else {
gameLoop();
}
} while (!key[KEY_ESC]);
// Destroy objects
destroy_bitmap(backgr);
destroy_bitmap(frame);
destroy_bitmap(title);
destroy_bitmap(buffer);
destroy_midi(musica);
destroy_sample(beep);
destroy_sample(up2);
destroy_sample(up1);
// Finish
deinit();
return 0;
}
END_OF_MAIN()
void init() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, WIDTH, HEIGHT, 0, 0);
if (res != 0) {
allegro_message(allegro_error);
exit(-1);
}
install_timer();
install_keyboard();
install_mouse();
install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
}
void deinit() {
clear_keybuf();
}