aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-06 21:40:31 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-06 21:40:31 -0400
commite3fae4da977856f5c953d9e3b3ea0bce51789a17 (patch)
treea390fde25cc019b5a19f2a96b061f7100fd9b02b
parenta13dde134922a3ec5b16be1bb65a689f552b5418 (diff)
downloadnes-snake-e3fae4da977856f5c953d9e3b3ea0bce51789a17.tar.gz
nes-snake-e3fae4da977856f5c953d9e3b3ea0bce51789a17.zip
check for collisions against the (currently invisible) wall
-rw-r--r--main.s19
1 files changed, 19 insertions, 0 deletions
diff --git a/main.s b/main.s
index 6138de9..4b8e5d8 100644
--- a/main.s
+++ b/main.s
@@ -197,6 +197,25 @@ apply_direction:
ADC head_x, y ; head_x offset by 1 is head_y
STA head_x, y
+check_collisions
+ LDA head_x
+ CMP #$18
+ BCC collision
+ CMP #$E8
+ BCS collision
+
+ LDA head_y
+ CMP #$18
+ BCC collision
+ CMP #$E8
+ BCS collision
+
+ JMP end_game_loop
+
+collision:
+ LDA #$00
+ STA game_state
+
end_game_loop:
RTS