Display Player Character and Gem Objects

Introduction

In the previous lesson, we created three enemy objects that move vertically at different speeds. Now, we are going to do the same for the player character and the gem objects. However, in contrast to the enemy objects, the player character object will only move horizontally while the mouse button is clicked and stop when when it is released. For the gem object, there does not need to be any movement, because it is going to be a fixed component in the game.

Create the player character object

Now let's create the structure of the player character object in a similar way as we did for the enemy. The player character object will contain the position of the player character (PC), the speed at which the player character object will move horizontally, a flag to track whether the PC is moving or not, and the health of the PC. Let's build the structure now.

Get hands-on with 1200+ tech skills courses.