dEngine
Simple 2D C++ game engine
GameLevel.h
Go to the documentation of this file.
1 #ifndef DENGINE_GAMELEVEL_H
2 #define DENGINE_GAMELEVEL_H
3 
4 
5 #include "GameObject.h"
6 #include <string>
7 #include <cmath>
8 #include <algorithm>
9 #include <memory>
10 
11 namespace dengine {
19  class GameLevel {
20  public:
24  GameLevel();
25 
29  virtual ~GameLevel();
30 
34  virtual void Load() = 0;
35 
39  virtual void UnLoad() = 0;
40 
44  virtual void Update() = 0;
45 
49  virtual void Render() = 0;
50 
54  virtual void Start() = 0;
55 
59  virtual void Pause() = 0;
60 
64  virtual void Resume() = 0;
65 
69  virtual std::weak_ptr <GameObject> AddObject(GameObject *go);
70 
74  virtual std::weak_ptr <GameObject> GetObject(std::string gameObjectName);
75 
79  virtual std::weak_ptr <GameObject> GetObjectByComponent(std::string componentName);
80 
81  protected:
85  void StartObjects();
86 
90  virtual void UpdateObjects();
91 
95  virtual void RenderObjects();
96 
101  bool started;
102  std::vector <std::shared_ptr<GameObject>> objects;
103  std::vector <std::shared_ptr<GameObject>> newObjects;
104  };
105 }
106 
107 #endif //DENGINE_GAMELEVEL_H
A base object for a game The gameobject can be considered the most basic building block of a game...
Definition: GameObject.h:19
void StartObjects()
Calls the start method on any registered objects.
Definition: GameLevel.cpp:49
bool started
Is true if Start has already ran.
Definition: GameLevel.h:101
A level of the game.
Definition: GameLevel.h:19
virtual void Update()=0
Used for performing logic updates.
virtual std::weak_ptr< GameObject > GetObject(std::string gameObjectName)
Retrieves a pointer to the object from the level.
Definition: GameLevel.cpp:38
virtual void UnLoad()=0
Used for removing assets from memory.
virtual ~GameLevel()
Cleans up and removes any memory allocated by GameLevel.
Definition: GameLevel.cpp:9
GameLevel()
Creates a new gamelevel.
Definition: GameLevel.cpp:7
std::vector< std::shared_ptr< GameObject > > newObjects
Definition: GameLevel.h:103
virtual void Load()=0
Used for loading assets into memory.
std::vector< std::shared_ptr< GameObject > > objects
Definition: GameLevel.h:102
virtual void UpdateObjects()
Calls the Update method on any registered objects.
Definition: GameLevel.cpp:57
virtual std::weak_ptr< GameObject > AddObject(GameObject *go)
Adds an object to the level.
Definition: GameLevel.cpp:14
virtual std::weak_ptr< GameObject > GetObjectByComponent(std::string componentName)
Retrieves an object from the level based on if it has a component or not.
Definition: GameLevel.cpp:25
virtual void Render()=0
Used for rendering graphics, text and more.
virtual void RenderObjects()
Calls the Render method on any registered objects.
Definition: GameLevel.cpp:70
virtual void Resume()=0
Resumes the game.
The namespace containing the engine&#39;s code.
Definition: Collider.h:9
virtual void Pause()=0
Pauses the game.
virtual void Start()=0
Called at instantiation.