#include #include #include "snake.h" #include "world.h" int main() { struct state* st=create_world(10, 10); while (1) { for (int y = 0; yheight; y++) { for (int x = 0; xwidth; x++) { if (is_snake(st->snake, x, y)) { printf("O"); } else { int food = 0; for (int i = 0; i < FOOD_COUNT; i++) { if (st->foodx[i] == x && st->foody[i] == y) { food = 1; break; } } printf(food ? "*" : "."); } } printf("\n"); } printf("WASD: "); char c; scanf(" %c", &c); if (c == 'w') change_direction(st, 0, -1); else if (c == 's') change_direction(st, 0, 1); else if (c == 'a') change_direction(st, -1, 0); else if (c == 'd') change_direction(st, 1, 0); else if (c == 'q') break; int res = step_state(st); if (res != END_CONTINUE) { printf("End of game: %d\n", res); break; } } free_world(st); return 0; }