diff --git a/include/timer.h b/include/timer.h index aa0bddd..86dfd0f 100644 --- a/include/timer.h +++ b/include/timer.h @@ -11,4 +11,6 @@ uint32_t get_elapsed_frames(); void pause_elapsed_frames(); void reset_elapsed_frames(); +uint32_t get_global_frames(); + #endif diff --git a/src/object_state.c b/src/object_state.c index 4d9b379..8714044 100644 --- a/src/object_state.c +++ b/src/object_state.c @@ -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; diff --git a/src/screen_level.c b/src/screen_level.c index 3f98846..7d7909c 100644 --- a/src/screen_level.c +++ b/src/screen_level.c @@ -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) } } + 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) { - camera_update(&camera, &player); - update_obj_window(&leveldata, &obj_table_common, camera.pos.vx, camera.pos.vy); - object_pool_update(&obj_table_common); player_update(&player); } } diff --git a/src/timer.c b/src/timer.c index be7f52f..ce34276 100644 --- a/src/timer.c +++ b/src/timer.c @@ -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() {