Updated Scene System (markdown)

Kayne Ruse
2013-05-02 05:40:36 -07:00
parent 6695ddf704
commit a718816176
+7 -7
@@ -9,17 +9,17 @@ The scene system is the backbone of the game client, utilizing the [strategy pat
## Breakdown ## Breakdown
main.cpp simply creates an instance of SceneManager, calls it's `Init()`, `Loop()` and `Quit()` functions in order, and handles any fatal exceptions thrown from the rest of the program. `main.cpp` simply creates an instance of `SceneManager`, calls it's `Init()`, `Loop()` and `Quit()` functions in order, and handles any fatal exceptions thrown from the rest of the program.
scene_list.hpp holds an enum class of macros, one for each scene in the game. All scenes in the game should include this file in the *.cpp. The macros `QUIT`, `CONTINUE` and `FIRST` are reserved. `scene_list.hpp` holds an enum class of macros, one for each scene in the game. All scenes in the game should include this file in the *.cpp. The macros `QUIT`, `CONTINUE` and `FIRST` are reserved.
base_scene.hpp and base_scene.cpp hold the interface of the strategy pattern i.e. all scenes in the game MUST inherit from the BaseScene class. This class handles the game's screen (which is a static member) and the player's input (via SDL). `base_scene.hpp` and `base_scene.cpp` hold the interface of the strategy pattern i.e. all scenes in the game MUST inherit from the `BaseScene` class. This class handles the game's screen (which is a static member) and the player's input (via SDL).
scene_manager.hpp and scene_manager.cpp hold the SceneManager class, which initializes and deinitializes the game client, and handles the transition between scenes in the strategy pattern. `scene_manager.hpp` and `scene_manager.cpp` hold the `SceneManager` class, which initializes and deinitializes the game client, and handles the transition between scenes in the strategy pattern.
## Instructions ## Instructions
To add a new scene to the game, create a class that inherits from BaseScene, overriding any or all of it's members. Then, include the class's header into scene_manager.cpp where it's [indicated](https://github.com/Ratstail91/Tortuga/blob/master/client/scene_manager.cpp#L9). Finally, add a new macro for your scene to scene_list.hpp, and modify SceneManager::LoadScene(SceneIndex) to include that macro and your scene's constructor. To add a new scene to the game, create a class that inherits from `BaseScene`, overriding any or all of it's members. Then, include the class's header into `scene_manager.cpp` where it's [indicated](https://github.com/Ratstail91/Tortuga/blob/master/client/scene_manager.cpp#L9). Finally, add a new macro for your scene to `scene_list.hpp`, and modify `SceneManager::LoadScene(SceneIndex)` to include that macro and your scene's constructor.
Here's an example, using a class called "NewScene": Here's an example, using a class called `NewScene`:
```c++11 ```c++
void SceneManager::LoadScene(SceneList sceneIndex) { void SceneManager::LoadScene(SceneList sceneIndex) {
UnloadScene(); UnloadScene();