From 9f59571d48291d853b4d342a2b20393806219a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 15 Jan 2023 00:37:02 +0200 Subject: [PATCH] Fix bug with fruits spawning on top of snake --- mato8.asm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mato8.asm b/mato8.asm index 94b4146..973996e 100644 --- a/mato8.asm +++ b/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