Summary
In this chapter, we made WalkTheDog
more closely resemble a game by making RHB run into obstacles and jump onto platforms. We did all of this with axis-aligned bounding boxes and in a scene that looks like a real game, with a background, instead of an empty void. We also dealt with some quirks for dealing with trimmed sprite sheets, properly handled bounding boxes, and utilized the state machine we built in Chapter 4, Managing Animations with State Machines, to handle the new animations and manage the state of RedHatBoy
.
We also learned how collisions are more than just drawing a box around an image. Yes, it's the math behind intersecting boxes, but it's also checking to see whether the player is landing or crashing into the platform. We debugged our collision boxes with rectangles and used those rectangles to make a better fitting box. We even subdivided one image into multiple collision boxes!
This chapter was big, we did a lot, and I encourage you to fiddle...