]> git.localhorst.tv Git - blobs.git/blob - src/blobs.cpp
randomize creature properties a bit
[blobs.git] / src / blobs.cpp
1 #include "app/Application.hpp"
2 #include "app/Assets.hpp"
3 #include "app/init.hpp"
4 #include "app/MasterState.hpp"
5 #include "creature/Creature.hpp"
6 #include "math/const.hpp"
7 #include "world/Planet.hpp"
8 #include "world/Set.hpp"
9 #include "world/Simulation.hpp"
10 #include "world/Sun.hpp"
11 #include "world/TileType.hpp"
12
13 #include <cstdint>
14 #include <iostream>
15
16
17 using namespace blobs;
18
19 int main(int argc, char *argv[]) {
20         app::Init init(true, 8);
21         app::Assets assets;
22
23         world::Sun sun;
24         sun.Mass(1.0e14);
25         sun.Radius(20.0);
26         sun.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25));
27         sun.AngularMomentum(1.0e13);
28
29         world::Planet planet(25);
30         planet.SetParent(sun);
31         planet.Mass(1.0e10);
32         planet.GetOrbit().SemiMajorAxis(941.7);
33         planet.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25));
34         planet.AxialTilt(glm::dvec2(PI * 0.127, 0.0));
35         planet.AngularMomentum(6.0e10);
36
37         world::Planet moon(3);
38         moon.SetParent(planet);
39         moon.Mass(1.0e6);
40         moon.GetOrbit().SemiMajorAxis(37.0);
41         moon.Rotation(PI * 0.25);
42         moon.AngularMomentum(1.0e4);
43
44         world::Planet second_planet(9);
45         second_planet.SetParent(sun);
46         second_planet.Mass(1.0e9);
47         second_planet.GetOrbit().SemiMajorAxis(350.0);
48         second_planet.SurfaceTilt(glm::dvec2(PI * 0.125, PI * 0.25));
49         second_planet.AxialTilt(glm::dvec2(PI * 0.95, 0.0));
50         second_planet.AngularMomentum(1.0e8);
51
52         world::Simulation sim(sun, assets.data.resources, assets.data.tile_types);
53         sim.AddSun(sun);
54         sim.AddPlanet(planet);
55         sim.AddPlanet(second_planet);
56         sim.AddPlanet(moon);
57
58         world::GenerateEarthlike(assets.data.tile_types, planet);
59         planet.Atmosphere(assets.data.resources["air"].id);
60         world::GenerateTest(assets.data.tile_types, moon);
61         world::GenerateTest(assets.data.tile_types, second_planet);
62
63         std::cout << "length of year: " << planet.OrbitalPeriod() << "s" << std::endl;
64         std::cout << "length of moon cycle: " << moon.OrbitalPeriod() << "s" << std::endl;
65         std::cout << "length of day: " << planet.RotationalPeriod() << "s" << std::endl;
66         std::cout << "days per year: " << (planet.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
67         std::cout << "moon cycle in days: " << (moon.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
68         std::cout << "moon cycles per year: " << (planet.OrbitalPeriod() / moon.OrbitalPeriod()) << std::endl;
69
70         auto blob = new creature::Creature(sim);
71         Spawn(*blob, planet, assets);
72         blob->BuildVAO();
73         blob->Name("Blob");
74
75         app::MasterState state(assets, sim);
76         state.GetCamera()
77                 .Reference(planet)
78                 // sunrise
79                 //.FirstPerson(0, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
80                 // sunset
81                 //.FirstPerson(3, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
82                 // from afar
83                 .MapView(0, glm::vec3(0.0f, 0.0f, 10.0f), 0.0f)
84                 // from afar, rotating
85                 //.Orbital(glm::vec3(-60.0f, 0.0f, 0.0f))
86         ;
87         // system view
88         //state.GetCamera()
89         //      .Reference(sun)
90         //      .Orbital(glm::vec3(-500.0f, 500.0f, 500.0f))
91         //;
92         state.GetCreaturePanel().Show(*blob);
93
94         app::Application app(init.window, init.viewport);
95         app.PushState(&state);
96         app.Run();
97
98         return 0;
99 }