diff --git a/draw_coll_map.py b/draw_coll_map.py new file mode 100644 index 0000000..75a6448 --- /dev/null +++ b/draw_coll_map.py @@ -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="") diff --git a/src/actor.c b/src/actor.c index f332764..4d1acad 100644 --- a/src/actor.c +++ b/src/actor.c @@ -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++; diff --git a/src/actor.h b/src/actor.h index 163b53d..3f43a8a 100644 --- a/src/actor.h +++ b/src/actor.h @@ -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; diff --git a/src/player.c b/src/player.c index c3a56f2..094bd3b 100644 --- a/src/player.c +++ b/src/player.c @@ -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; }