Saturday, September 15, 2012

Game Structure Blueprint

The Design

As mentioned in the previous post I wanted to come up with a blueprint to handle the setup/running of the game as well as managing the different game states.


The design is pretty straightforward. Game component begins by initializing a singleton Communicator instance to handle all communications among objects. 


Next, the Scene Director is initialized which directs scenes to transition from one to another. Each scene handles loading/unloading its own assets at the request of the scene director's enter scene and exit scene functions when transitioning between scenes. By default Scene Director initializes the Splash Scene as its first scene. 


Splash Scene, as with all scenes, loads and initializes its own assets, game objects,  components, and registers listeners with the Communicator to listen for certain messages. The first object is the splash menu, from which the user can start a selected level or quit the application. Next is the Splash Input, which enables the user to interact with the 3D splash menu  using the mouse. Lastly, the Splash Level Preview allows the user to scroll through a list of currently available levels to view them. Once the start button is pressed, the currently selected level number is passed to the scene director along with a message to end the splash scene. Scene Director calls the splash cleanup function, which unloads the assets and deregisters any listeners withe the Communicator. The director then sends a message to the Level Scene to Initialize the given level. 


Upon initialization the level loads all assets, and configures the columns with their exposures. Exposure is the amount influence a column has on  other columns. Exposures are configured in a separate file to prevent hard coding them in the game per level. 

Control flow reaches the Level scene now, which has a number of objects. A level menu system from which the user can return to the splash scene or reset the current level. Column Manager which is responsible for managing all data related to the columns which include, tracking the selected and effected columns, moving columns correctly based on exposures, validating each move, resetting invalid moves, and changing column textures. The user continues to play the game until they complete it or quit.

Assuming the user quits the level,  a message is sent back to the scene director indicating level termination. Scene director calls the level component's cleanup function which unloads all assets and removes all of its registered listeners from the Communicator, preventing it from sending or receiving any messages. The scene is then destroyed, and Scene Director transitions to the Splash Screen.

The user can continue this loop, however assume the user presses the application quit button. A message is sent back to the director to cleanup the splash scene. The director then sends a message to the game component, which cleans up the Communicator  and Scene Director objects before exiting the application.

No comments:

Post a Comment