Fix timer-locked animations and reduce title card time

This commit is contained in:
Lucas S. Vieira 2024-11-17 23:41:22 -03:00
parent 2c8614387f
commit 2117e8e82a
4 changed files with 18 additions and 5 deletions

View file

@ -11,4 +11,6 @@ uint32_t get_elapsed_frames();
void pause_elapsed_frames();
void reset_elapsed_frames();
uint32_t get_global_frames();
#endif

View file

@ -163,7 +163,10 @@ object_render(ObjectState *state, ObjectTableEntry *typedata,
begin_render_routine:
if(state->props & OBJ_FLAG_ANIM_LOCK) {
uint32_t frame = get_elapsed_frames();
// This is a weird fix for animation locks when the level
// timer is frozen, but hey, it works.
uint32_t frame = paused ? get_elapsed_frames() : get_global_frames();
if(an->duration > 0) {
frame = (frame / an->duration);
if(an->loopback >= 0) frame %= an->num_frames;

View file

@ -84,7 +84,7 @@ screen_level_load()
pause_elapsed_frames();
level_fade = 0;
data->level_counter = 180;
data->level_counter = 120;
level_ring_count = 0;
level_finished = 0;
@ -228,11 +228,11 @@ screen_level_update(void *d)
}
}
// Only update these if past fade in!
if(data->level_transition > 0) {
camera_update(&camera, &player);
update_obj_window(&leveldata, &obj_table_common, camera.pos.vx, camera.pos.vy);
object_pool_update(&obj_table_common);
// Only update these if past fade in!
if(data->level_transition > 0) {
player_update(&player);
}
}

View file

@ -10,6 +10,7 @@ volatile int frame_counter = 0;
volatile int frame_rate = 0;
volatile uint8_t counting_frames = 0;
volatile uint32_t frame_count = 0;
volatile uint32_t global_count = 0;
void
timer_tick()
@ -42,6 +43,7 @@ timer_update()
frame_counter++;
if(counting_frames && !paused)
frame_count++;
global_count++;
}
int
@ -56,6 +58,12 @@ get_elapsed_frames()
return frame_count;
}
uint32_t
get_global_frames()
{
return global_count;
}
void
pause_elapsed_frames()
{