Swipe to navigate through the chapters of this book
In the previous chapter, you saw how to create an animated character. You also saw how you can load levels and level status from the local storage and how to build a tile-based game world. One of the most important aspects is still missing: defining how the character interacts with the game world. You can make a character move from left to right, but if you simply place the character in the level, it can only walk on the bottom of the screen. This isn’t enough. You want the character to be able to jump on top of wall tiles and fall down if it moves off a wall tile, and you don’t want the character to fall off the edge of the screen. For these things, you need to implement a basic physics system. Because it’s the character interacting with the world, you implement this physics in the Player class. There are two aspects to dealing with physics: giving the character the ability to jump or fall, and handling collisions between the character and other game objects and responding to these collisions.
Please log in to get access to this content
To get access to this content you need the following product:
- Game Physics
- Sequence number
- Chapter number
- Chapter 26