Added test player movement
authorLukas Krickl <lukas@krickl.dev>
Wed, 2 Oct 2024 16:12:12 +0000 (18:12 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 2 Oct 2024 16:12:12 +0000 (18:12 +0200)
src/player.s

index ac4d0b9cb0610dfea2a1063e4fa5354b95acad40..b89e7d09cbfed1bfaefbc3969e64d0a74e6eabe2 100644 (file)
 player_update:
   ; update 
 
+  ; d: player_y
+  ; e: player_x
+
   ; input handling
   input_held BTNDOWN
   jr z, @notdown REL
-  
-  ld de, player_y
-  add hl, de
+  ; hl = player_y 
   ld a, [hl]
   inc a
   ld [hl], a
 @notdown:
+  
+  input_held BTNUP
+  jr z, @notup REL
+
+  ; hl = player_y
+  ld a, [hl]
+  dec a
+  ld [hl], a
+@notup:
+  
+  ; store y in d 
+  ; and inc hl 
+  ld a, [hl+]
+  ld d, a 
+
+  input_held BTNLEFT
+  jr z, @notleft REL
+
+  ; hl = player_x 
+  ld a, [hl]
+  dec a
+  ld [hl], a
+@notleft:
+
+  input_held BTNRIGHT
+  jr z, @notright REL
 
+  ; hl = player_x 
+  ld a, [hl]
+  inc a
+  ld [hl], a
+@notright:
+  
 
   ; drawing 
-  ; d: player_y
-  ; e: player_x
 
-  ld a, [hl+]
-  ld d, a
-  ld a, [hl+]
+  ; sotre x in e
+  ld a, [hl]
   ld e, a
 
   ; obj 1