Unit 8
State Machines
Thursday 5th May 2016: The Game Maker's Companion, Jacob Habgood
What is a State Machine?
"State machines provide a way of breaking down large programming tasks into smaller chunks so that you can consider them more easily."
It seems that a State Machine Is a page of code that makes your game work. It can also be referred to by other pieces, this can greatly simplify the coding process if done right and allow you to do more complex actions within the game. It also helps tell the game what should be happening when a specific state is started, for example if the character enters a falling state then he will fall down, but if he then hits a platform he will enter the standing state and stop.
How does it work?
The aim of a State Machine is to make things within the game change states, this will cause different things to happen based on what state the object enters.
Here is a diagram of a state machine for a game that the book is using as an example:
This diagram gives a clear representation about the different states for the character and how they enter each one, as we can see if the player is in the standing state and presses the space bar then the character will enter the jumping function. Once the animation ends then it will hen enter the falling state until it hits the ground, at which point it will return to the standing state.
How would it be useful to my project?
The point of a state machine, is to have a sort of engine that can control apects of the game using minimal amounts of code. This will also allow easy troubleshooting if something were to go wrong.
Will I use it?
If I find that time is on my side, then I will defiantly like to look into creating one for my game, as It would be a good thing to learn for any future projects.
No comments:
Post a Comment