Aktualizovat du4 /snake.c
This commit is contained in:
parent
2951b46f8e
commit
70f9ed5e68
@ -79,7 +79,7 @@ int is_snake(struct snake* snake,int x,int y){
|
|||||||
FAZY: 1. -> Kontrola kolizie (seba + vs. stien)
|
FAZY: 1. -> Kontrola kolizie (seba + vs. stien)
|
||||||
2. -> Kontrola logiky zobratia jedla (resp. kolizie s jedlom, update statusu, pripadny narast hada)
|
2. -> Kontrola logiky zobratia jedla (resp. kolizie s jedlom, update statusu, pripadny narast hada)
|
||||||
3. -> Realizacia pohybu
|
3. -> Realizacia pohybu
|
||||||
4. -> finalna kontrola poctu jedla*/
|
4. -> finalna kontrola poctu jedla */
|
||||||
int step_state(struct state* st){
|
int step_state(struct state* st){
|
||||||
int nx = (st->snake->x + st->sx);
|
int nx = (st->snake->x + st->sx);
|
||||||
int ny = (st->snake->y + st->sy);
|
int ny = (st->snake->y + st->sy);
|
||||||
@ -112,9 +112,11 @@ int step_state(struct state* st){
|
|||||||
st->foodx[i] = -1;
|
st->foodx[i] = -1;
|
||||||
st->foody[i] = -1;
|
st->foody[i] = -1;
|
||||||
|
|
||||||
add_snake(st->snake; nx, ny);
|
add_snake(st->snake, nx, ny);
|
||||||
|
|
||||||
hasEatenFoodinThisCycle = true;
|
hasEatenFoodinThisCycle = true;
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
//hra bude pokracovat normalne dalej, ak NIE JE vsetko jedlo zobrate
|
//hra bude pokracovat normalne dalej, ak NIE JE vsetko jedlo zobrate
|
||||||
if (st->foodx[i] != -1)
|
if (st->foodx[i] != -1)
|
||||||
@ -123,7 +125,7 @@ int step_state(struct state* st){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//normalny pohyb snake-a (ak jedlo nebolo zjedene)
|
//normalny pohyb snake-a (ak jedlo nebolo zjedene v tomto update cykle)
|
||||||
if (!hasEatenFoodinThisCycle)
|
if (!hasEatenFoodinThisCycle)
|
||||||
{
|
{
|
||||||
st->snake = add_snake(st->snake, nx, ny);
|
st->snake = add_snake(st->snake, nx, ny);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user