Изменить 'du7/snake.c'
This commit is contained in:
parent
0ae2b69355
commit
228a3c4b9c
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user