commit
This commit is contained in:
parent
cc7b910591
commit
9a31fd09f8
@ -59,11 +59,11 @@ int is_snake(struct snake* snake, int x, int y) {
|
||||
int step_state(struct state* st) {
|
||||
int nx = st->snake->x + st->sx;
|
||||
int ny = st->snake->y + st->sy;
|
||||
int ate_food = nx == st->food_x && ny == st->food_y;
|
||||
int ate_food = nx == st->foodx && ny == st->foody;
|
||||
struct snake* tail = get_tail(st->snake);
|
||||
|
||||
if (nx < 0 || ny < 0 || nx >= st->width || ny >= st->height) {
|
||||
return END_GAME;
|
||||
return END_SNAKE;
|
||||
}
|
||||
if (is_snake(st->snake, nx, ny)) {
|
||||
if (ate_food || tail == NULL || tail->x != nx || tail->y != ny) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user