Chapter    13

Game Physics

In the Painter game, you created a very basic mechanism for objects moving around in the game world and colliding with each other. In Tut’s Tomb, this is no longer sufficient. Objects need to fall according to gravity, they need to bounce off walls, and they need to handle collisions differently. In this chapter, you are going to adapt your game structure so that it is more suitable for these advanced interactions. You will see that it’s quite simple to add physically correct behavior to your game objects in SpriteKit.

A Basic Class for Game Objects

Most games have a complicated structure of game objects. First, there might be a background consisting of various layers of moving objects (mountains, air, trees, and so ...

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.