ff
This commit is contained in:
parent
304844b7e1
commit
a790569a53
14
cv9/snake.c
14
cv9/snake.c
@ -9,7 +9,20 @@ struct snake* add_snake(struct snake* snake, int x, int y) {
|
|||||||
return new_head;
|
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) {
|
struct snake* remove_snake(struct snake* snake) {
|
||||||
|
if (snake == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
struct snake* temp = snake;
|
struct snake* temp = snake;
|
||||||
while(temp->next->next != NULL) {
|
while(temp->next->next != NULL) {
|
||||||
temp = temp->next;
|
temp = temp->next;
|
||||||
@ -19,6 +32,7 @@ struct snake* remove_snake(struct snake* snake) {
|
|||||||
return snake;
|
return snake;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int is_snake(struct snake* snake, int x, int y) {
|
int is_snake(struct snake* snake, int x, int y) {
|
||||||
while(snake != NULL) {
|
while(snake != NULL) {
|
||||||
if(snake->x == x && snake->y == y) {
|
if(snake->x == x && snake->y == y) {
|
||||||
|
Loading…
Reference in New Issue
Block a user