Browse Source

Use fixed-point number to store Y coordinate

master
Forest Belton 2 years ago
parent
commit
e2ad9075e0
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      src/player.s

+ 9
- 3
src/player.s View File

@ -10,7 +10,7 @@ playerWorldY: dw
; player data
PLAYER_X:: db
PLAYER_Y:: db
PLAYER_Y:: dw
PLAYER_DIR:: db
PLAYER_JUMPING:: db
@ -44,6 +44,8 @@ Player_Init::
ld [hl], 0
inc hl
ld [hl], 0
inc hl
ld [hl], 0
; Copy sprite to VRAM
ld bc, _VRAM8000 + SPRITE_IDX * 16
@ -104,9 +106,12 @@ Player_Update::
STORE16 bc
; y -= floor(vy)
ld hl, PLAYER_Y
ld hl, PLAYER_Y + 1
ld a, [hl]
sub c
ld [hl-], a
ld a, [hl]
sub b
sbc b
ld [hl], a
; roll back jump if there was a collision
@ -216,6 +221,7 @@ update_oam:
and OAMF_XFLIP
ld c, a
dec hl ; skip fractional part
ld a, [hl-] ; y
add 16

Loading…
Cancel
Save