From 228a3c4b9c6e2f54a9d90af935dbf3816b1272f7 Mon Sep 17 00:00:00 2001 From: Oleksandr Hryshchenko Date: Mon, 26 Apr 2021 19:42:04 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20'du7/snake.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du7/snake.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/du7/snake.c b/du7/snake.c index 80deddc..73379aa 100644 --- a/du7/snake.c +++ b/du7/snake.c @@ -20,7 +20,7 @@ struct snake* add_snake(struct snake* snake,int x,int y){ //temp->next = (struct snake*) calloc(1, sizeof(struct snake)); temp->next->x = temp->x - (myX - temp->x); - temp->next->y = temp->y - (myX - temp->y); + temp->next->y = temp->y - (myY - temp->y); temp->next->next = NULL; return newHead; @@ -66,7 +66,7 @@ int step_state(struct state* st){ int ny = (st->snake->y + st->sy); for(int i = 0; i < FOOD_COUNT; i++){ - if(st->snake-> == st->foodx && st->snake->y == st->food[i]){ + if(nx == st->foodx[i] && ny == st->foody[i]){ add_snake(st->snake, st->foodx[i], st->foody[i]); st->foodx[i] = -1; st->foody[i] = -1; @@ -81,7 +81,7 @@ int step_state(struct state* st){ } } - for(struct snake* temp = st->snake->next != NULL; temp = temp->next){ + for(struct snake* temp = st->snake->next; temp != NULL; temp = temp->next){ if(nx == temp->x && ny == temp->y){ return END_SNAKE; }