raylibstarter 0.1.0
scene.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <string>
5
6#include <raylib.h>
7
8#include "actor.h"
9
10namespace game::core {
11 /**
12 * Scenes are one basic element of this engine. They contain the actual game-play elements. Scene classes derived
13 * from this base class implement an Update() method to manipulate the game state and draw graphics via the Draw()
14 * method to be implemented.
15 *
16 * A scene object contains actors that are automatically drawn by the Stage object. Actor objects can be placed in
17 * the actor-map of a scene object and will be drawn automatically if their visible attribute is true.
18 * If actor objects are supposed to be available across scenes, they can also be stored in game::core::actors.
19 * Objects that are only referenced there will not be drawn automatically.
20 *
21 * @brief Scene base class. Scenes are managed by the Stage object.
22 */
23 class Scene {
24 public:
25 /// Actors of the scene. The Actor objects of this map are drawn automatically by the Stage object if their visibility attribute is true.
26 std::map<std::string, std::shared_ptr<game::core::Actor>> actors = { };
27
29 TraceLog(LOG_INFO, "game::core::Scene constructor called");
30 }
31
32 virtual ~Scene() {
33 TraceLog(LOG_INFO, "game::core::Scene destructor called");
34 }
35
36 /**
37 * @brief The Update() method is used to process input and update the game state. It is called automatically before Draw() is called.
38 */
39 virtual void Update() = 0;
40
41 /**
42 * @brief The Draw() method can be used to output graphics. Note that the elements of the actor map are drawn automatically.
43 */
44 virtual void Draw() = 0;
45 };
46}
Scene base class. Scenes are managed by the Stage object.
Definition: scene.h:23
virtual void Draw()=0
The Draw() method can be used to output graphics. Note that the elements of the actor map are drawn a...
virtual ~Scene()
Definition: scene.h:32
virtual void Update()=0
The Update() method is used to process input and update the game state. It is called automatically be...
std::map< std::string, std::shared_ptr< game::core::Actor > > actors
Actors of the scene. The Actor objects of this map are drawn automatically by the Stage object if the...
Definition: scene.h:26