pvjc25/a3/main.c
2025-05-01 22:45:15 +02:00

43 lines
684 B
C

#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#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;
}
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
free_snake(game_state.snake);
printf("\n--- KONIEC HRY ---\n");
return 0;
}