#define PLAYER_SPEED 0xE0
#define PISTOL_TILE 0x86
+#define PLAYER_WALKING_TILE 0x8E
; sets up the player actor
player_init:
player_draw:
ld a, 2
call oamalloc
-
+
+ ; was any direction pressed this frame?
+ ld a, [curr_inputs]
+ and a, BTNUP | BTNDOWN | BTNLEFT | BTNRIGHT
+ jp nz, @walking
+
+ ; idle sprite
ld de, player
ld b, PLAYER_SPRITE_IDLE1
ld c, 0
ld a, 3
call actor_draw
-
+
+ jp @weapon
+@walking:
+
+ ld de, player
+ ld b, PLAYER_WALKING_TILE
+
+ ld a, [animation_frame]
+ cp a, 1
+ jr z, @flip REL
+
+ ld c, 0
+ ld a, 3
+ jr @no_flip REL
+
+@flip:
+ ld c, OAM_FXFLIP
+ ld a, 4
+@no_flip:
+
+ call actor_draw
+
+@weapon:
; TODO: draw based on player weapon type
ld de, player
ld b, PISTOL_TILE
ld h, a
call_hl
+ call update_anim_timer
+
ret
+
+ ; updates the global animation timer
+ ; and the animation frame
+update_anim_timer:
+ ld a, [animation_timer]
+ inc a
+ and a, 0x1F ; max timer
+ ld [animation_timer], a
+ ; bail if no overflow
+ ret nz
+
+@tick_frame:
+ ld a, [animation_frame]
+ xor a, 1
+ ld [animation_frame], a
+ ret
new_game:
ld de, l_main_menu