diff --git a/cv9/snake.c b/cv9/snake.c index 0c66745..ddfa9e2 100644 --- a/cv9/snake.c +++ b/cv9/snake.c @@ -9,7 +9,20 @@ struct snake* add_snake(struct snake* snake, int x, int y) { return new_head; } +/*struct snake* remove_snake(struct snake* snake) { + struct snake* temp = snake; + while(temp->next->next != NULL) { + temp = temp->next; + } + free(temp->next); + temp->next = NULL; + return snake; +}*/ + struct snake* remove_snake(struct snake* snake) { + if (snake == NULL) { + return NULL; + } struct snake* temp = snake; while(temp->next->next != NULL) { temp = temp->next; @@ -19,6 +32,7 @@ struct snake* remove_snake(struct snake* snake) { return snake; } + int is_snake(struct snake* snake, int x, int y) { while(snake != NULL) { if(snake->x == x && snake->y == y) {