fixed state resetting
authorhgn <hgodden00@gmail.com>
Mon, 13 Dec 2021 07:53:55 +0000 (07:53 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 13 Dec 2021 07:53:55 +0000 (07:53 +0000)
fishladder.c

index b95248c0d76443f19c2015fe3626f829bd89b2a8..d6f3ef007f2ff57ec0b95bc5f2dfef04e151a0a5 100644 (file)
@@ -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[] = {