Browse Source

Support flipping actors horizontally

master
Forest Belton 3 years ago
parent
commit
50ade55af1
4 changed files with 23 additions and 8 deletions
  1. +11
    -0
      draw_coll_map.py
  2. +10
    -8
      src/actor.c
  3. +1
    -0
      src/actor.h
  4. +1
    -0
      src/player.c

+ 11
- 0
draw_coll_map.py View File

@ -0,0 +1,11 @@
import sys
c = 0
with open(sys.argv[1], "rb") as f:
while True:
b = f.read(1)
if len(b) == 0:
break
ws = " " if c < 31 else "\n"
c = (c + 1) % 32
print(f"{b[0]:02}{ws}", end="")

+ 10
- 8
src/actor.c View File

@ -29,6 +29,7 @@ void actor_init(void) {
actor_reset();
PLAYER_ACTOR->active = 1;
PLAYER_ACTOR->flip = 0;
PLAYER_ACTOR->anim = ANIM_STAND;
PLAYER_ACTOR->frame_idx = 0;
PLAYER_ACTOR->frame_counter = 0;
@ -60,6 +61,7 @@ actor_t *actor_create_mob(uint8_t id) {
a = &all_actors[i];
a->active = 1;
a->flip = 0;
a->mob_anim_idx = mob_anim_idx;
a->anim = ANIM_STAND;
a->frame_idx = 0;
@ -99,26 +101,26 @@ void actor_update(void) {
oam_ptr->y = a->y + 16;
oam_ptr->x = a->x + 8;
oam_ptr->tile = *anim_ptr++ + TILE_INDEX_PLAYER;
oam_ptr->attr = 0;
oam_ptr->tile = anim_ptr[a->flip] + TILE_INDEX_PLAYER;
oam_ptr->attr = a->flip ? (1 << 5) : 0;
oam_ptr++;
oam_ptr->y = a->y + 16;
oam_ptr->x = a->x + TILE_WIDTH + 8;
oam_ptr->tile = *anim_ptr++ + TILE_INDEX_PLAYER;
oam_ptr->attr = 0;
oam_ptr->tile = anim_ptr[1 - a->flip] + TILE_INDEX_PLAYER;
oam_ptr->attr = a->flip ? (1 << 5) : 0;
oam_ptr++;
oam_ptr->y = a->y + TILE_WIDTH + 16;
oam_ptr->x = a->x + 8;
oam_ptr->tile = *anim_ptr++ + TILE_INDEX_PLAYER;
oam_ptr->attr = 0;
oam_ptr->tile = anim_ptr[a->flip + 2] + TILE_INDEX_PLAYER;
oam_ptr->attr = a->flip ? (1 << 5) : 0;
oam_ptr++;
oam_ptr->y = a->y + TILE_WIDTH + 16;
oam_ptr->x = a->x + TILE_WIDTH + 8;
oam_ptr->tile = *anim_ptr++ + TILE_INDEX_PLAYER;
oam_ptr->attr = 0;
oam_ptr->tile = anim_ptr[1 - a->flip + 2] + TILE_INDEX_PLAYER;
oam_ptr->attr = a->flip ? (1 << 5) : 0;
oam_ptr++;
a++;

+ 1
- 0
src/actor.h View File

@ -22,6 +22,7 @@ typedef enum {
typedef struct {
uint8_t active;
uint8_t flip;
uint8_t mob_anim_idx;
actor_anim_state_t anim;
uint8_t frame_idx;

+ 1
- 0
src/player.c View File

@ -79,6 +79,7 @@ void player_update(void) {
PLAYER.vy = PLAYER_INIT_FALL_VY;
}
PLAYER_ACTOR->flip = PLAYER.dir == DIR_LEFT;
PLAYER_ACTOR->x = PLAYER.x;
PLAYER_ACTOR->y = PLAYER.y_hi;
}

Loading…
Cancel
Save