Browse Source

Reduce player speed and flip sprite

master
Forest Belton 3 years ago
parent
commit
61fb29d873
2 changed files with 20 additions and 8 deletions
  1. +7
    -0
      src/main.s
  2. +13
    -8
      src/player.s

+ 7
- 0
src/main.s View File

@ -10,6 +10,10 @@ rept $150 - _entry
db 0
endr
SECTION "Frame", WRAM0
frame:: db
SECTION "Code", ROM0
start:
@ -50,6 +54,9 @@ start:
ld [hl], %11100100
.loop:
ld hl, frame
inc [hl]
call Keys_Update
call Player_Update

+ 13
- 8
src/player.s View File

@ -6,13 +6,6 @@ Section "Player Data", WRAM0
playerWorldX: dw
playerWorldY: dw
; Sprite data
playerSprite:
playerScreenY: db
playerScreenX: db
playerTileIndex: db
playerFlags: db
Section "Player Code", ROM0
spriteData:
@ -45,6 +38,13 @@ Player_Init::
ret
Player_Update::
; Only update every 2 frames
ld hl, frame
ld a, [hl]
and %1
cp %1
jr nz, .done
ld hl, keys
ld b, [hl]
@ -59,8 +59,10 @@ Player_Update::
cp 160
jr nc, .done
ld hl, _OAM + 1
; Update x-position and set x-flip = false
inc [hl]
ld hl, _OAM + 3
res 5, [hl]
.left:
; check for left button
@ -74,7 +76,10 @@ Player_Update::
cp 9
jr c, .done
; Update x-position and set x-flip = true
dec [hl]
ld hl, _OAM + 3
set 5, [hl]
.done:
ret

Loading…
Cancel
Save