A simple 2D game where the player attemps to reach the end of the level while avoiding enemies and collecting M&Ms.
Developed using JavaScript and the p5.js library.
This project can be accessed here.
I added platforms to my game, allowing my game character to jump over bigger canyons and avoid enemies. When making these I learnt how to use the factory pattern; this allowed me to write the code on how to draw the platforms one, and then push that code into an empty array with the arguments I wanted, so I didn’t have to write the code out multiple times. I was then able to draw all of them using a for loop in my draw function, so I didn’t have to draw them all individually.
I also created enemies and to do so I learn how to use constructor functions; this allowed me to create every enemy as a new object without having to write out the code for each one. I learnt how to use the this keyword to declare the properties of the new object the function would be creating. I also learnt how to create a method inside the function that would allow me to draw the enemy.
I added sound effects to my game, using loadSound. Sounds effects where added for when the character jumped, collected a collectable, died or won the game.