I thought I'd take some time out from working on the Finite State Machine I mentioned a couple posts ago to explain what the FSM is going to look like. Here are the states I've been working on, complete with a description of what they do, and how they transition into the next state:
Loading State
Loads pretty much every resource it can, such as meshes, textures, and the like. Since we can't know what level the player will play, we can save music and level layouts for later. This also displays the loading screen. When the game is done loading, the FSM transitions to the Main Menu.
Main Menu
Displays the main menu and awaits mouse input from the user. Depending on the buttons pressed, the FSM transitions to the Load Level State either to load a new level or to load saved progress.
Load Level State
Depending on the input from the Main Menu, either loads in level data from a new level, or loads in a saved game file. The state then uses this data to construct a level cube that gets stored in the GameManager as the active level. Once loading is done, the FSM transitions to the Cube Level State.
Cube Level State
Displays the cube and lets the player rotate it to see their progress on every level. Once the player has rotated a side to face the camera (using mouse input), he or she can press a button to transition into the Side Puzzle State. Alternatively, he can press a button to transition back to the menu.
Side Puzzle State
The meat and potatoes of the game. This displays one side of the cube so the player can add, subtract, and manipulate the pieces of the puzzle. When the player is done, he or she can press a button and transition back to the Cube Level State. Alternatively, he can press a button to transition back to the menu.
The more I work on this thing, the more I realize how much I like structuring games in terms of a state machine. I like being able to create an individual state for each action I want the player to perform, and for each situation I want the player to deal with. The difficult part is going to be organizing everything such that the cube and puzzles will be accessible to both the Cube Level and Side Puzzle States. Since each puzzle will be updating every frame of both states, it's important that they're both accessible. I don't want to make the cube itself a singleton, because I'd like to maybe have multiple cubes on screen at some point, so I'll probably store the cube in the GameManager, which is a singleton.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment