Fix bug with fruits spawning on top of snake
This commit is contained in:
parent
9b6df7216f
commit
9f59571d48
10
mato8.asm
10
mato8.asm
|
@ -153,12 +153,16 @@ spawn_fruit:
|
|||
|
||||
ld i, single_pixel
|
||||
drw fruit_x_reg, fruit_y_reg, 1
|
||||
; Did we spawn over the snake?
|
||||
se vf, 0
|
||||
jp spawn_fruit
|
||||
|
||||
; Did we spawn succesfully?
|
||||
sne vf, 0
|
||||
ret
|
||||
|
||||
; No, we spawned over the snake. Erase and try again
|
||||
ld i, single_pixel
|
||||
drw fruit_x_reg, fruit_y_reg, 1
|
||||
jp spawn_fruit
|
||||
|
||||
turn_up:
|
||||
; Don't allow 180° turns (which would kill the snake instantly)
|
||||
se v1, direction_down
|
||||
|
|
Loading…
Reference in New Issue