Chapter 9
In-Game Movement
In the preceding chapter, you looked at several methods for detecting whether a player has interacted with the screen. In this chapter, you will have your character react to that movement. Let’s look at the Hero class from Chapter 7 again.
The Hero class is a spaceship that a player can move around the screen. Moving the image on the screen is going to be easier than it sounds. All you need to do is increment (or decrement) a single value in the transformation matrix when the Hero is drawn. You are updating only one value in this case, because you are going to be moving the ship on only one axis. If you were moving the ship on two axes, you would need to update two values in the matrix.
Let’s start by adding a getter ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access