Chapter 4: Managing Animations with State Machines
In the last chapter, we created a minimal game engine, allowing for moving our main character around and playing a simple animation, but it's far from full-featured. There's no world to navigate, the only animation that plays is running, and Red Hat Boy (RHB) doesn't respond to any physics. At this point, if we wanted to retitle our game, it would be called Red Hat Boy and the Empty Void.
While that might be a fun title, it wouldn't make for a fun game. Ultimately, we'll want RHB to chase his dog through a forest with platforms to jump on and slide under, and to do that we'll need to make sure he slides, jumps, and runs. We'll also need to make sure that he looks, acts, and behaves differently when he does those things.
In this chapter, we're going to introduce a common game development pattern to manage all that, the state machine, implemented in Rust. Rust gives us powerful constructs...