Coding the platforms
To get started, create the two classes we will need first in this chapter. They are PlatformUpdate
, which extends Update
, and PlatformGraphics
, which extends Graphics
. We already have the player-related classes, and we will add more code to them once we are done with the platforms. We will, however, need an Animator
class that will control the animations of the player, and later in the project, it will also control the animations of the fireballs. Feel free to create an empty Animator
class now or wait until we code it.
Coding the PlatformUpdate class
Most of what the platform will do is handle collisions with the player. If the player’s feet are touching the top of the platform, then they should not be able to pass through. If the right side of the player touches the left side of the platform, then it should not pass through, and so on. This next image shows a representation of what the PlatformUpdate
class will achieve.
Figure 18.1: Platform...