-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
48 lines (46 loc) · 909 Bytes
/
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
#include <ncurses.h>
#include "k.c"
#include "ui.c"
#include "hof.c"
int main(void){
struct game game = {
.board = {
{' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' '}
},
.score = 0
};
struct player player = {
.name = "Alex",
.score = 0
};
struct player list[10];
int size = load(list);
int dy, dx;
bool result;
initscr();
noecho();
cbreak();
clear();
curs_set(0);
keypad(stdscr, TRUE);
start_color();
do{
add_random_tile(&game);
render(game);
if(is_move_possible(game) == true){
A: get_input(&dy, &dx);
result = update(&game, dy, dx);
if(result == false)
goto A;
} else
break;
} while(result == true || is_game_won(game) == false);
player.score = game.score;
add_player(list, &size, player);
getch();
exit_game(player.score);
endwin();
}