submit2
This commit is contained in:
parent
fe913763f6
commit
fddead63be
12
cv9/snake.c
12
cv9/snake.c
@ -6,7 +6,7 @@ struct snake* add_snake(struct snake* snake,int x,int y){
|
|||||||
head->x = x;
|
head->x = x;
|
||||||
head->y = y;
|
head->y = y;
|
||||||
head->next = snake;
|
head->next = snake;
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,13 +18,13 @@ struct snake* remove_snake(struct snake* snake){
|
|||||||
while(curent_element->next != NULL){
|
while(curent_element->next != NULL){
|
||||||
curent_element = curent_element->next;
|
curent_element = curent_element->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(curent_element);
|
free(curent_element);
|
||||||
|
|
||||||
if(curent_element==snake){
|
if(curent_element==snake){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return snake;
|
return snake;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,12 +34,11 @@ void free_snake(struct snake* sn){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct snake* next_element;
|
struct snake* next_element;
|
||||||
while(current->next!=NULL){
|
while(current!=NULL){
|
||||||
next_element=current->next;
|
next_element=current->next;
|
||||||
free(current);
|
free(current);
|
||||||
current=next_element;
|
current=next_element;
|
||||||
}
|
}
|
||||||
free(current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_snake(struct snake* snake,int x,int y){
|
int is_snake(struct snake* snake,int x,int y){
|
||||||
@ -58,3 +57,4 @@ int step_state(struct state* st){
|
|||||||
int ny = (st->snake->y + st->sy);
|
int ny = (st->snake->y + st->sy);
|
||||||
return END_CONTINUE;
|
return END_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user