-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
59 lines (47 loc) · 1.1 KB
/
main.c
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
#include "game.h"
extern int g_terminal_y;
extern int g_terminal_x;
extern int g_game_status;
int main(int argc, char *argv[])
{
setlocale(LC_ALL, "");
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
curs_set(0);
nodelay(stdscr, 1);
initialize_colors();
srand(time(NULL));
spawn_enemy();
getmaxyx(stdscr, g_terminal_y, g_terminal_x);
WINDOW *main_window;
if (g_terminal_x < WIDTH || g_terminal_y < HEIGHT)
{
nodelay(stdscr, 0);
resize();
}
else
{
main_window = newwin(HEIGHT,WIDTH,g_terminal_y/2-HEIGHT/2, g_terminal_x/2-WIDTH/2);
g_game_status = 1;
}
while(g_game_status > 0)
{
getmaxyx(stdscr, g_terminal_y, g_terminal_x);
if (g_game_status == 1)
{
title(main_window);
}
else if (g_game_status == 2)
{
gameplay(main_window);
}
else if (g_game_status == 3)
{
gameover(main_window);
}
}
endwin();
return 0;
}