Week 7 (21-27 Nov 2022)

The deadline for our projects was this week, and seeing as I was unwell last week I really needed to get a move on with my code. This week I added many new features such as a camera overlay, shooting, a collectible key, an escape hatch and death for the player.

Starting out with making the player mortal, I gave them a health total where if it were to decrease past a certain point it would kill them.

Setting the players health total
Creates collider between player and enemy
Creating collisions between enemy and player which calls to the function below
Function which removes health from the player and kills the player if the health goes below zero

Now that the player had their (in game) life on the line, I needed to create a way for the player to defend themselves while they search for a way to win. This led to me creating a weapon function;

Loads the bullet image

Constructing the bullet class so that it can be called to in the players functions

Creating physics for the bullets class
Creates collider between bullet and enemy
Creates bullet on the click of left mouse button
Function for when the enemy gets hit

After sending the game out to others for testing, it seems that I have overlooked the enemy speed mechanic, as the enemy’s speed will invert when it goes low enough making it run away from the player. This was an oversight in code and I can only learn from this mistake.

The player now needed a way to escape the level, so I create the key and escape hatch. The player could not leave through the escape hatch until they had the key;

Variable to check if player has the key
Loads the images for the key and the exit
Spawns the key and exit at random locations within the map, also makes the exit an unmovable object
Set the origin for the images, display size and world collision bounds
Adds collision between the player and the two objects, then refers them to functions
Sets the player tool check to true meaning that they can now use the exit
Checks to see if the player has the key, if they do it disables the character and displays a victory message, does nothing otherwise

End of project and future goals

Now that the project has come to an end, I have a few thoughts about how it went. Firstly JavaScript and Phaser can be annoying to work with at some times, main problem I had was the random collision feedback as two objects would collide but not do their designated functions. Secondly I think I spent too much time trying to fix problems myself when I should’ve asked other people more to get that second perspective on my code.

Over the coming weeks I think I may get a little head start on Unreal Engine 5, as I am not the biggest fan of Phaser and I think UE5 is a very promising game engine which will be used to make many of the upcoming game titles releasing in the coming years.

Leave a comment

Your email address will not be published.