Games can be some of the most complicated types of software you can create. And the most fun.
It helps to use modern best practices to avoid messy bugs or more easily fix ones that come up.
Doing so saves you time and headaches. Most importantly it will help you make a better game.
In this article, we will show you how to create games in Phaser 3 using modern JavaScript and best practices.
We created a new project and added a GameScene in Part 1. Now we will create platforms and a player character using modern JavaScript. We also apply the DRY or Don't Repeat Yourself principle to string literals.
In Part 2 we added platforms and created a player character. Here we will handle collisions between the player and platforms as well as add keyboard controls using modern JavaScript. We also discuss pure functions and unintended side effects.
With collisions between the player and platforms taken care of in Part 3, we will tackle creating and keeping score of collected stars. We deviate from the official Phaser guide in how we handle score logic and display using a separate class.
In this final part we make the game more exciting with bombs created by a BombSpawner class. The code looks significantly different from the official Phaser 3 guide as we take everything we've learned in previous parts and apply it!