Chapter    26

Adding Player Interaction

In this chapter, you will add more interaction between the player and the objects in the level. Currently, the player can walk around, and a basic physics system allows the player to jump, collide with wall tiles, or fall out of the screen. First, you will look at a very simple kind of interaction: collecting water drops. Then you will see how to create the behavior that allows the player to slide over ice. You will also focus on the part of the program that deals with the various player-enemy interactions in the game. Finally, you will add vertical and horizontal scrolling to the game.

Collecting Water Drops

The first thing to add is the possibility for the player to collect water drops. A player collects ...

Get Swift Game Programming for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.