X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=examples%2Fbassteroids%2Fsource%2Fgamecontroller.cpp;h=b5640330310ad111f01f70d4b7aafba260a305fe;hb=9ce882cbb6bb7628d7c9883c43491a75c10625d7;hp=f32f04b3716908fffec8438537ab2bcf275d4269;hpb=29aa52b23d74d390c677b728776022a9b267d9e6;p=libs%2Fgame.git diff --git a/examples/bassteroids/source/gamecontroller.cpp b/examples/bassteroids/source/gamecontroller.cpp index f32f04b..b564033 100644 --- a/examples/bassteroids/source/gamecontroller.cpp +++ b/examples/bassteroids/source/gamecontroller.cpp @@ -8,7 +8,8 @@ using namespace Msp; GameController::GameController(Game::Stage &s): System(s), - asteroid_setup{ .mesh = { .object_name = "Asteroid 1.object" }} + asteroid_setup{ .physical={ .body={ .mass=200, .moment_of_inertia=2160 }, .collider={ .type=ColliderType::CIRCLE, .radius=3.0f } }, + .mesh={ .object_name="Asteroid 1.object" }} { } void GameController::tick(Time::TimeDelta) @@ -18,10 +19,14 @@ void GameController::tick(Time::TimeDelta) case LEVEL_START: defer([this]{ uniform_real_distribution sdist(-1, 1); + uniform_real_distribution udist(0, 1); for(unsigned i=0; iget_transform()->set_position({ sdist(rng)*32, sdist(rng)*18, 0.0f }); + Geometry::Angle angle = Geometry::Angle::from_turns(udist(rng)); + float speed = udist(rng)*7; + asteroids.back()->get_body()->set_velocity({ cos(angle)*speed, sin(angle)*speed }); } state = PLAYING; });