Saga
Saga Game Engine
Loading...
Searching...
No Matches
app.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <utility>
5#include "../Gameworld/gameworld.h"
6
7namespace Saga {
8
14class App {
15public:
16 App();
17 virtual ~App();
24 void update(float deltaTime, float time);
25
33 void fixedUpdate(float deltaTime, float time);
34
38 void draw();
39
46 void keyEvent(int key, int action);
47
54 void mousePosEvent(double xpos, double ypos);
55
62 void mouseButtonEvent(int button, int action);
63
69 void scrollEvent(double distance);
70
77 void framebufferResizeEvent(int width, int height);
78
85 void windowResizeEvent(int width, int height);
86
92 std::shared_ptr<GameWorld> createGameWorld();
93
99 void removeGameWorld(std::shared_ptr<GameWorld> world);
100
101private:
105 class AppExclusiveGameWorld : public GameWorld {
106 public:
107 virtual ~AppExclusiveGameWorld();
108
109 bool started = false;
110 void runStageStartup();
111 void runStageUpdate(float deltaTime, float time);
112 void runStageFixedUpdate(float deltaTime, float time);
113 void runStageDraw();
114 void runStageCleanup();
115 void keyEvent(int key, int action);
116 void mousePosEvent(double xpos, double ypos);
117 void mouseButtonEvent(int button, int action);
118 void scrollEvent(double distance);
119 void windowResizeEvent(int width, int height);
120 };
121 std::vector<std::shared_ptr<AppExclusiveGameWorld>> worlds;
122};
123}
Manages several GameWorld. Responsible for assembling them and passing along Staged events as well as...
Definition: app.h:14
std::shared_ptr< GameWorld > createGameWorld()
Create a Game World object.
Definition: app.cpp:77
void draw()
Invoke the Draw stage of any managed World.
Definition: app.cpp:38
void windowResizeEvent(int width, int height)
Invoked whenever the user resize the window.
Definition: app.cpp:71
void scrollEvent(double distance)
Invoke a scroll event, that happens when the user scroll with the mouse.
Definition: app.cpp:62
void keyEvent(int key, int action)
Invoke a keyboard event.
Definition: app.cpp:44
virtual ~App()
Definition: app.cpp:12
void mousePosEvent(double xpos, double ypos)
Invoke a mouse position event. This happens whenever the mouse changes position.
Definition: app.cpp:50
void update(float deltaTime, float time)
This invokes the Update stages of any world, or the Start stage if this is the world's first frame.
Definition: app.cpp:22
void framebufferResizeEvent(int width, int height)
Invoked whenever the framebuffer needs to be resized.
Definition: app.cpp:68
void mouseButtonEvent(int button, int action)
Invoke a mouse button event.
Definition: app.cpp:56
App()
Definition: app.cpp:9
void removeGameWorld(std::shared_ptr< GameWorld > world)
Remove a GameWorld.
Definition: app.cpp:85
void fixedUpdate(float deltaTime, float time)
This invokes the FixedUpdate stages of any world, if that world has been started. Fixed updates shoul...
Definition: app.cpp:32
Maintains a game world, where Entity, Component, Systems, and MetaSystems can be added,...
Definition: gameworld.h:28
Definition: app.cpp:8