summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--application/main.cpp5
-rw-r--r--game/gamestate.cpp15
-rw-r--r--game/gamestate.h20
-rw-r--r--game/world.h11
4 files changed, 37 insertions, 14 deletions
diff --git a/application/main.cpp b/application/main.cpp
index f198517..df8828a 100644
--- a/application/main.cpp
+++ b/application/main.cpp
@@ -4,12 +4,12 @@
#include <game/activities/go.h>
#include <game/activities/idle.h>
#include <game/activity.h>
+#include <game/gamestate.h>
#include <game/network/rail.h>
#include <game/terrain.h>
#include <game/vehicles/railVehicle.h>
#include <game/vehicles/railVehicleClass.h>
#include <game/vehicles/train.h>
-#include <game/world.h>
#include <game/worldobject.h>
#include <gfx/camera_controller.h>
#include <gfx/gl/camera.h>
@@ -26,7 +26,7 @@
static const int DISPLAY_WIDTH = 1280;
static const int DISPLAY_HEIGHT = 1024;
-class SDL_Application : public InputHandler, public std::enable_shared_from_this<SDL_Application> {
+class SDL_Application : public InputHandler, public std::enable_shared_from_this<SDL_Application>, GameState {
public:
SDL_Application()
{
@@ -160,7 +160,6 @@ private:
bool isRunning {true};
Collection<InputHandler> inputStack;
- World world;
};
int
diff --git a/game/gamestate.cpp b/game/gamestate.cpp
new file mode 100644
index 0000000..fcd4248
--- /dev/null
+++ b/game/gamestate.cpp
@@ -0,0 +1,15 @@
+#include "gamestate.h"
+#include <cassert>
+
+GameState * gameState {nullptr};
+
+GameState::GameState()
+{
+ assert(!gameState);
+ gameState = this;
+}
+
+GameState::~GameState()
+{
+ gameState = nullptr;
+}
diff --git a/game/gamestate.h b/game/gamestate.h
new file mode 100644
index 0000000..b8dfa61
--- /dev/null
+++ b/game/gamestate.h
@@ -0,0 +1,20 @@
+#ifndef GAMESTATE_H
+#define GAMESTATE_H
+
+#include <collection.hpp>
+#include <special_members.hpp>
+
+class WorldObject;
+
+class GameState {
+public:
+ GameState();
+ ~GameState();
+ NO_MOVE(GameState);
+ NO_COPY(GameState);
+
+ Collection<WorldObject> world;
+};
+extern GameState * gameState;
+
+#endif
diff --git a/game/world.h b/game/world.h
deleted file mode 100644
index a0185e7..0000000
--- a/game/world.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef WORLD_H
-#define WORLD_H
-
-#include "worldobject.h"
-#include <collection.hpp>
-
-class World : public Collection<WorldObject> {
-public:
-};
-
-#endif