Phaser Development: Maze Game

This week we made the basis of a procedurally generated maze game with the task to customize it with 2 new features. This week I thought i would work on the UI and sound since I didn’t touch on them last week.

First thing I did was to make a few variables to outline when I needed text to display, the 3 things that I planned to implement was a score counter, some text that notifies you that you have speed boost active and a message at the end of the level to say that it’s complete. With that in place I worked on them in that order, so first up was the score.

Nothing fancy, but gets the job done well

Of course that won’t update by itself so I needed to add that functionality to the gems (worth 250 points) and power-ups (worth 50 points) so that it will display the score variable.

Gem collected. 250 points gained.

The speed power-up was just the points code edited to be relevant to the situation, however I needed it to dissapear after a certain amount of time once its effect wore off, so I used the update function as a timer to disable the text after so many runs of update. This took some altering to get the time right but 300 seemed to be the sweet spot.

This makes sure the text is gone after the effect is over. Also a sneek peek into some music code!
Just in case the player didn’t know, they are going extra fast!

The final bit of UI was the maze complete text, code wasn’t anything new, just another alteration of the score text except it only displays once all the gems are collected .

4 Gems? Check. Home reached? Check. Text dispalyed? Check.

Next on the agenda was to implement some music. This was easier than I thought it would be but of course before we start coding, we need to put it in preload! With that quickly done it was time to make an object with all the music and sounds I plan to use.

I also made sure that the background music was playing too.

After this it was simply a case of repeating the line whenever I needed something to play so there isn’t anything else major to document, and sadly images cannot play music so showing it off is a bit difficult.

Overall I had a lot of fun implementing these customisations into the game and it also turned out to be a lot easier than I thought, this does incentivise me to try some more ambitious things in the future as they may not be as difficult as I thought.