From 00241431bf542e48787c2bc89fc11189d97008f3 Mon Sep 17 00:00:00 2001 From: hgn Date: Mon, 13 Dec 2021 07:53:55 +0000 Subject: [PATCH] fixed state resetting --- fishladder.c | 56 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/fishladder.c b/fishladder.c index b95248c..d6f3ef0 100644 --- a/fishladder.c +++ b/fishladder.c @@ -1060,6 +1060,12 @@ static int is_simulation_running(void) return world.buttons[ k_world_button_sim ].pressed; } +static void clear_animation_flags(void) +{ + for( int i = 0; i < world.w*world.h; i ++ ) + world.data[ i ].state &= ~(FLAG_FLIP_FLOP|FLAG_FLIP_ROTATING); +} + static void simulation_stop(void) { world.buttons[ k_world_button_sim ].pressed = 0; @@ -1068,14 +1074,40 @@ static void simulation_stop(void) world.num_fishes = 0; world.sim_frame = 0; world.sim_run = 0; + world.frame_lerp = 0.0f; io_reset(); sfx_system_fadeout( &audio_system_balls_rolling, 44100 ); + clear_animation_flags(); + vg_info( "Stopping simulation!\n" ); } +static void simulation_start(void) +{ + vg_success( "Starting simulation!\n" ); + + sfx_set_playrnd( &audio_rolls, &audio_system_balls_rolling, 0, 1 ); + + world.num_fishes = 0; + world.sim_frame = 0; + world.sim_run = 0; + + world.sim_delta_speed = 2.5f; + world.sim_delta_ref = vg_time; + world.sim_internal_ref = 0.0f; + world.sim_internal_time = 0.0f; + world.pause_offset_target = 0.0f; + + world.sim_target = 0; + + clear_animation_flags(); + + io_reset(); +} + static int world_check_pos_ok( v2i co ) { return (co[0] < 2 || co[0] >= world.w-2 || co[1] < 2 || co[1] >= world.h-2)? 0: 1; @@ -1888,30 +1920,6 @@ static void draw_numbers( v3f coord, int number ) } }*/ -static void simulation_start(void) -{ - vg_success( "Starting simulation!\n" ); - - sfx_set_playrnd( &audio_rolls, &audio_system_balls_rolling, 0, 1 ); - - world.num_fishes = 0; - world.sim_frame = 0; - world.sim_run = 0; - - world.sim_delta_speed = 2.5f; - world.sim_delta_ref = vg_time; - world.sim_internal_ref = 0.0f; - world.sim_internal_time = 0.0f; - world.pause_offset_target = 0.0f; - - world.sim_target = 0; - - for( int i = 0; i < world.w*world.h; i ++ ) - world.data[ i ].state &= ~FLAG_FLIP_FLOP; - - io_reset(); -} - static void wbutton_run( enum e_world_button btn_name ) { static v3f button_colours[] = { -- 2.25.1