Browse Source

Don't allow player movement off-screen

master
Forest Belton 3 years ago
parent
commit
2079d44097
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      src/player.s

+ 12
- 1
src/player.s View File

@ -53,16 +53,27 @@ Player_Update::
and BTN_RIGHT and BTN_RIGHT
jr z, .left jr z, .left
; check for right boundary
ld hl, _OAM + 1
ld a, [hl]
cp 160
jr nc, .done
ld hl, _OAM + 1 ld hl, _OAM + 1
inc [hl] inc [hl]
.left: .left:
; check for move left
; check for left button
ld a, b ld a, b
and BTN_LEFT and BTN_LEFT
jr z, .done jr z, .done
; check for left boundary
ld hl, _OAM + 1 ld hl, _OAM + 1
ld a, [hl]
cp 9
jr c, .done
dec [hl] dec [hl]
.done: .done:

Loading…
Cancel
Save