Updated Scene System (markdown)
+9
-9
@@ -1,22 +1,22 @@
|
||||
The scene system is the backbone of the game client, utilizing the [strategy pattern](http://en.wikipedia.org/wiki/Strategy_pattern) to control various different logical scenarios found throughout the game (the main menu, the game world, combat scenarios, etc). It consists of the following files:
|
||||
|
||||
* scene_list.hpp
|
||||
* base_scene.hpp
|
||||
* base_scene.cpp
|
||||
* scene_manager.hpp
|
||||
* scene_manager.cpp
|
||||
* main.cpp
|
||||
* [scene_list.hpp](https://github.com/Ratstail91/Tortuga/blob/master/client/scene_list.hpp)
|
||||
* [base_scene.hpp](https://github.com/Ratstail91/Tortuga/blob/master/client/base_scene.hpp)
|
||||
* [base_scene.cpp](https://github.com/Ratstail91/Tortuga/blob/master/client/base_scene.cpp)
|
||||
* [scene_manager.hpp](https://github.com/Ratstail91/Tortuga/blob/master/client/scene_manager.hpp)
|
||||
* [scene_manager.cpp](https://github.com/Ratstail91/Tortuga/blob/master/client/scene_manager.cpp)
|
||||
* [main.cpp](https://github.com/Ratstail91/Tortuga/blob/master/client/main.cpp)
|
||||
|
||||
## 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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
|
||||
## 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. 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":
|
||||
|
||||
```c++11
|
||||
|
||||
Reference in New Issue
Block a user