From: Mikko Rasa Date: Mon, 28 Nov 2022 12:12:15 +0000 (+0200) Subject: Defer creation of bullets until the end of the frame X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=47767a381e6bdde03f68efdfc1d8e628c3655019;p=libs%2Fgame.git Defer creation of bullets until the end of the frame --- diff --git a/examples/bassteroids/source/playercontroller.cpp b/examples/bassteroids/source/playercontroller.cpp index 46f9c1f..cd0c62b 100644 --- a/examples/bassteroids/source/playercontroller.cpp +++ b/examples/bassteroids/source/playercontroller.cpp @@ -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(); }