added some error handling
parent
f8c92fbd75
commit
50df5e1896
8
game.c
8
game.c
|
@ -41,11 +41,15 @@ void play_game(GAME_STATE* state) {
|
|||
state -> status = 0;
|
||||
|
||||
FIELD* f = malloc(sizeof(FIELD));
|
||||
if (2 * 40 > COLS || 20 > LINES) {
|
||||
endwin();
|
||||
fprintf(stderr, "Snek: Terminal is to small, must be 80x20 at least\n");
|
||||
exit(1);
|
||||
}
|
||||
init_field(f, 40, 20, state);
|
||||
init_player(f -> player , f -> width / 2, f -> height / 2);
|
||||
add_ball(f, 1);
|
||||
|
||||
|
||||
redraw_field(f);
|
||||
|
||||
fd_set inputs, test_fds;
|
||||
|
@ -59,7 +63,7 @@ void play_game(GAME_STATE* state) {
|
|||
while(1) {
|
||||
if (state -> status) {
|
||||
destroy_field(f);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue