From 61fb29d873f270bfb8078c365f2c03a3123da7b5 Mon Sep 17 00:00:00 2001 From: Forest Belton <65484+forestbelton@users.noreply.github.com> Date: Mon, 28 Jun 2021 20:06:52 -0400 Subject: [PATCH] Reduce player speed and flip sprite --- src/main.s | 7 +++++++ src/player.s | 21 +++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main.s b/src/main.s index 3d546af..a4cc98b 100644 --- a/src/main.s +++ b/src/main.s @@ -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 diff --git a/src/player.s b/src/player.s index 52f8505..c8ec48a 100644 --- a/src/player.s +++ b/src/player.s @@ -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