1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// vim:ft=doxygen
namespace crepe {
/**
\defgroup feature_scene Scenes
\ingroup feature
\brief User-defined scenes
Scenes can be used to implement game environments, and allow arbitrary game objects to be organized
as part of the game structure. Scenes are implemented as derivative classes of Scene, which are
added to the game using the SceneManager. Scenes describe the start of a Scene and cannot modify
GameObject during runtime of a Scene (use Scripting for this purpose).
\see SceneManager
\see GameObject
\see Script
\see Scene
\par Example
This example demonstrates how to define and add scenes to a scene manager in the `crepe` framework.
Two concrete scene classes, `ConcreteScene1` and `ConcreteScene2`, are derived from the base `Scene` class.
Each scene class overrides the `load_scene` method to create and initialize game objects specific to the scene.
Finally, the scenes are added to the scene manager.
```cpp
using namespace crepe;
class ConcreteScene1 : public Scene {
public:
using Scene::Scene;
void load_scene() {
auto & mgr = this->component_manager;
GameObject object1 = mgr.new_object("scene_1", "tag_scene_1", Vector2{0, 0}, 0, 1);
GameObject object2 = mgr.new_object("scene_1", "tag_scene_1", Vector2{1, 0}, 0, 1);
GameObject object3 = mgr.new_object("scene_1", "tag_scene_1", Vector2{2, 0}, 0, 1);
}
};
class ConcreteScene2 : public Scene {
public:
using Scene::Scene;
void load_scene() {
auto & mgr = this->component_manager;
GameObject object1 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 0}, 0, 1);
GameObject object2 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 1}, 0, 1);
GameObject object3 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 2}, 0, 1);
GameObject object4 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 3}, 0, 1);
}
};
// Add the scenes to the scene manager
scene_mgr.add_scene<ConcreteScene1>("scene1");
scene_mgr.add_scene<ConcreteScene2>("scene2");
```
*/
}
|