July 2015
Beginner
380 pages
9h 17m
English
Chapter 20
Interaction Between Game Objects
In this chapter, you are going to program the main gameplay for the Penguin Pairs game. You will learn how to move penguins around on the board and what to do when a penguin collides with another game object, such as a shark or another penguin.
Defining Operators
Since you will be dealing with moving and colliding penguins, you will be doing quite a lot of calculations with two-dimensional points and vectors (represented by CGPoint instances). At the moment, computing things with these points is a bit of a hassle. For example, in the LevelState class, this is how you have to position the Quit button:
quitButton.position = GameScreen.instance.topRightquitButton.position.x -= quitButton.center.x + 10 ...
Read now
Unlock full access