Now that I’ve got a nice little development setup to work with It’s finally time to start making the games. The first on the list is the 2d puzzle platformer with two independently controlled players.
I’m going to cheese this one a bit by making use of the assets and code from the tutorial game and build upon it, I’ll just need to work on implementing it with my development space and see how that works.
I managed to split this up into two files, putting the config for the game in index.js and the other parts for it (preload(), create() etc) have been put in a scene.js file stored in a scenes folder for use of later. It didn’t end up working initally since the code was unable to find the collectStar() function in the same way it did when everything was stored in the one html file. The exporting and importing that I’m doing for the scene as a class is probably what’s interferring with it, however setting the reference of collectStar() to this.collectStar() fixes the issues the code was having with finding the function (which would now be a method since it’s contained with a class).
Great I have the tutorial working in my setup fine, now it’s time to figure out how to define the keys used for the controls so that I can have one player controlled with WASD and the other with the arrow keys. After searching through the API documentation I found exactly what I was looking for: this.input.keyboard.addKeys(‘W,S,A,D”); Now in the update function where the controls were being put in as left.isDown it can be changed to A.isDown.
Now with that set I went on to create a second player, altering the code where needed and set different tints to them and seperate controls. I’ve also played about with the platforms and added a pickup for each player that can only be picked up if it corresponds with their colour. Overall it’s a decent base for the game now which looks a bit like this:

Next up is to work on scene switching and a bit of level design so that it starts getting it’s puzzle aspect which will mostly be playing about with doors that can only opened when one of the pickups are collected.

