In our game, the entity that will transition between states the most is our racing bike. It's under the player's control; it interacts with almost every element in the environment, including obstacles and enemy drones. Therefore, it will never stay in the same state for long.Â
The following diagram showcases a shortlist of finite states for our bike:
Figure 5.2 – Diagram illustrating the finite states of the bike
And now let's define some expected behaviors for some of the listed states:
- Stop: In this state, the bike is not moving. Its current speed is at zero. Its gears are set to neutral. If we decide that the engine should be on, but running in idle mode in that state, we could have an animation of the chassis of the bike vibrating to show that the motor is running.
- Start: In this state, the bike moves at full speed, and the wheels turn to match the forward motion.
- Turn: In the turning state, the bike turns to the left or...