using namespace blobs;
-namespace {
-
-struct SwitchPanel {
- SwitchPanel(world::Planet &p, app::Application &app, app::MasterState &state)
- : planet(p), app(app), state(state) { }
-
- void operator ()(creature::Creature &c) {
- if (planet.Creatures().empty()) {
- planet.GetSimulation().Log() << "no more creatures, game over" << std::endl;
- state.GetCreaturePanel().Hide();
- while (app.HasState()) {
- app.PopState();
- }
- } else {
- for (auto a : planet.Creatures()) {
- if (a != &c) {
- state.GetCreaturePanel().Show(*a);
- a->WhenDead([&](creature::Creature &b) { (*this)(b); });
- break;
- }
- }
- }
- }
-
- world::Planet &planet;
- app::Application &app;
- app::MasterState &state;
-};
-}
-
int main(int argc, char *argv[]) {
app::Init init(true, 8);
app::Assets assets;
world::Sun sun;
+ sun.Name("Sun");
sun.Mass(1.0e14);
sun.Radius(20.0);
sun.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25));
sun.AngularMomentum(1.0e13);
world::Planet planet(25);
+ planet.Name("Planet");
planet.SetParent(sun);
planet.Mass(1.0e10);
planet.GetOrbit().SemiMajorAxis(941.7);
planet.AngularMomentum(6.0e10);
world::Planet moon(3);
+ moon.Name("Moon");
moon.SetParent(planet);
moon.Mass(1.0e6);
moon.GetOrbit().SemiMajorAxis(37.0);
moon.AngularMomentum(1.0e4);
world::Planet second_planet(9);
+ second_planet.Name("Second planet");
second_planet.SetParent(sun);
second_planet.Mass(1.0e9);
second_planet.GetOrbit().SemiMajorAxis(350.0);
state.GetTimePanel().SetBody(planet);
app::Application app(init.window, init.viewport);
- SwitchPanel swp(planet, app, state);
- blob->WhenDead([&](creature::Creature &c) { swp(c); });
app.PushState(&state);
app.Run();