pvjc25/a3/main.c
2025-05-13 18:28:02 +02:00

35 lines
582 B
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "snake.h"
#include "world.h"
int main(void) {
struct state game_state;
setup_world(&game_state, 20, 10);
draw_world(&game_state);
while (1) {
char command = read_input();
change_direction(&game_state, command);
int outcome = step_state(&game_state);
draw_world(&game_state);
if (outcome != END_CONTINUE) {
break;
}
sleep(1);
}
free_snake(game_state.snake);
printf("\n--- KONIEC HRY ---\n");
return 0;
}