GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseGame.hpp
Go to the documentation of this file.
1 #ifndef RADIX_BASEGAME_HPP
2 #define RADIX_BASEGAME_HPP
3 
4 #include <radix/util/sdl/Fps.hpp>
5 #include <radix/World.hpp>
6 #include <radix/GameWorld.hpp>
7 #include <radix/Window.hpp>
11 #include <radix/env/Config.hpp>
15 
16 namespace radix {
17 
18 const int UPDATE_RATE = 60;
19 const int SKIP_TIME = 1000 / UPDATE_RATE;
20 const int MAX_SKIP = 5;
21 
22 class BaseGame {
23 public:
24  static Fps fps;
25 
26  BaseGame();
27  virtual ~BaseGame();
28 
29  // No copy
30  BaseGame(const BaseGame&) = delete;
31  BaseGame operator=(const BaseGame&) = delete;
32 
33  // No movement
34  BaseGame(BaseGame&&) = delete;
35  BaseGame operator=(BaseGame&&) = delete;
36 
37  bool isRunning();
38  virtual void processInput();
39  virtual void update();
40  virtual void cleanUp();
41  virtual void close();
42  virtual void render();
43  void setup();
44  World* getWorld();
47  inline Window& getWindow() {
48  return window;
49  }
50 
51 protected:
52  void loadMap();
53  virtual void prepareCamera();
54  virtual void initHook();
55 
60 
61  std::shared_ptr<ScreenRenderer> screenRenderer;
62  std::unique_ptr<Renderer> renderer;
63  std::unique_ptr<Camera> camera;
64  std::shared_ptr<radix::Screen> screen;
66 
67  std::string defaultMap = "/maps/n1.xml";
68  std::string windowTitle = "RadixEngine";
69 
70  bool closed;
71  unsigned int currentTime = 0, nextUpdate = 0, lastUpdate = 0, lastRender = 0;
72 };
73 
74 } /* namespace radix */
75 
76 #endif /* RADIX_BASEGAME_HPP */
Window window
Definition: BaseGame.hpp:56
Definition: GameController.hpp:7
static Fps fps
Definition: BaseGame.hpp:24
Config config
Definition: BaseGame.hpp:58
virtual ~BaseGame()
Definition: BaseGame.cpp:25
Definition: Window.hpp:22
std::unique_ptr< Camera > camera
Definition: BaseGame.hpp:63
std::shared_ptr< radix::Screen > screen
Definition: BaseGame.hpp:64
const int SKIP_TIME
Definition: BaseGame.hpp:19
EventDispatcher::CallbackHolder screenshotCallbackHolder
Definition: BaseGame.hpp:65
std::string windowTitle
Definition: BaseGame.hpp:68
Configuration class.
Definition: Config.hpp:19
World * getWorld()
Definition: BaseGame.cpp:67
Definition: ScreenRenderer.hpp:14
unsigned int lastUpdate
Definition: BaseGame.hpp:71
std::string defaultMap
Definition: BaseGame.hpp:67
Window & getWindow()
Definition: BaseGame.hpp:47
virtual void processInput()
Definition: BaseGame.cpp:93
virtual void update()
Definition: BaseGame.cpp:79
std::shared_ptr< ScreenRenderer > screenRenderer
Definition: BaseGame.hpp:61
virtual void cleanUp()
Definition: BaseGame.cpp:96
World world
Definition: BaseGame.hpp:57
ScreenRenderer * getScreenRenderer()
Definition: BaseGame.cpp:71
virtual void render()
Definition: BaseGame.cpp:101
unsigned int currentTime
Definition: BaseGame.hpp:71
unsigned int nextUpdate
Definition: BaseGame.hpp:71
GameWorld * getGameWorld()
Definition: BaseGame.cpp:75
Definition: GameWorld.hpp:10
virtual void close()
Definition: BaseGame.cpp:122
void loadMap()
Definition: BaseGame.cpp:126
virtual void prepareCamera()
Definition: BaseGame.cpp:110
Definition: Fps.hpp:6
GameWorld gameWorld
Definition: BaseGame.hpp:59
bool isRunning()
Definition: BaseGame.cpp:63
Definition: EventDispatcher.hpp:20
Definition: World.hpp:32
BaseGame()
Definition: BaseGame.cpp:14
BaseGame operator=(const BaseGame &)=delete
Definition: BaseGame.hpp:22
const int UPDATE_RATE
Definition: BaseGame.hpp:18
const int MAX_SKIP
Definition: BaseGame.hpp:20
bool closed
Definition: BaseGame.hpp:70
virtual void initHook()
Definition: BaseGame.cpp:94
void setup()
Definition: BaseGame.cpp:28
std::unique_ptr< Renderer > renderer
Definition: BaseGame.hpp:62
unsigned int lastRender
Definition: BaseGame.hpp:71