summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/environment.cpp18
-rw-r--r--game/environment.h16
-rw-r--r--game/gamestate.cpp3
-rw-r--r--game/gamestate.h2
4 files changed, 39 insertions, 0 deletions
diff --git a/game/environment.cpp b/game/environment.cpp
new file mode 100644
index 0000000..fd2bfd4
--- /dev/null
+++ b/game/environment.cpp
@@ -0,0 +1,18 @@
+#include "environment.h"
+#include <chronology.h>
+#include <gfx/gl/sceneRenderer.h>
+
+Environment::Environment() : worldTime {"2024-01-01T12:00:00"_time_t} { }
+
+void
+Environment::tick(TickDuration)
+{
+ worldTime += 1;
+}
+
+void
+Environment::render(const SceneRenderer & renderer, const SceneProvider & scene) const
+{
+ renderer.setAmbientLight({0.5F, 0.5F, 0.5F});
+ renderer.setDirectionalLight({0.6F, 0.6F, 0.6F}, {-1, 1, -1}, scene);
+}
diff --git a/game/environment.h b/game/environment.h
new file mode 100644
index 0000000..62eedb8
--- /dev/null
+++ b/game/environment.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "worldobject.h"
+
+class SceneRenderer;
+class SceneProvider;
+
+class Environment : public WorldObject {
+public:
+ Environment();
+ void tick(TickDuration elapsed) override;
+ void render(const SceneRenderer &, const SceneProvider &) const;
+
+private:
+ time_t worldTime;
+};
diff --git a/game/gamestate.cpp b/game/gamestate.cpp
index fcd4248..910e8a7 100644
--- a/game/gamestate.cpp
+++ b/game/gamestate.cpp
@@ -1,4 +1,5 @@
#include "gamestate.h"
+#include "environment.h"
#include <cassert>
GameState * gameState {nullptr};
@@ -7,6 +8,8 @@ GameState::GameState()
{
assert(!gameState);
gameState = this;
+
+ environment = world.create<Environment>();
}
GameState::~GameState()
diff --git a/game/gamestate.h b/game/gamestate.h
index f07f844..892aa69 100644
--- a/game/gamestate.h
+++ b/game/gamestate.h
@@ -7,6 +7,7 @@
class WorldObject;
class GeoData;
+class Environment;
class GameState {
public:
@@ -17,6 +18,7 @@ public:
Collection<WorldObject> world;
std::shared_ptr<GeoData> geoData;
+ std::shared_ptr<Environment> environment;
AssetFactory::Assets assets;
};