]> git.tdb.fi Git - libs/game.git/commitdiff
Defer creation of bullets until the end of the frame
authorMikko Rasa <tdb@tdb.fi>
Mon, 28 Nov 2022 12:12:15 +0000 (14:12 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 28 Nov 2022 12:12:15 +0000 (14:12 +0200)
examples/bassteroids/source/playercontroller.cpp

index 46f9c1f85e30dfe710c96411a041c73455b22029..cd0c62bad8594b77d0557a299cb964e71b3ef514 100644 (file)
@@ -51,7 +51,7 @@ void PlayerController::tick(Time::TimeDelta dt)
                body->add_torque(angular_vel.radians()*-min(angular_speed.radians()+setup.turn_rate/angular_speed.radians(), 1.0f/dt_secs));
 
        if(controls->fire.was_pressed())
-               fire();
+               defer([this]{ fire(); });
 
        controls->reset_edges();
 }