Emanuele Feronato writes: "Some days ago I published a pure JavaScript class to handle Match 3 games like Bejeweled or Candy Crush.
I received positive feedback because a code running without dependencies is always welcome as allows you to include the class in your projects no matter the framework you are using: the class does the hard job behind the curtains so you only need to handle input and how stuff is displayed and moved on the screen.
With the same concept in mind, I created a SameGame class which handles a SameGame game.
Like Match3 class, everything is managed by SameGame class which tells the main script what to move and how to move: an array of objects with item row, item column, and delta row – the amount of rows you have to move the item – is returned each time the player moves.
The class manages it all and returns this array, then you have to move stuff on the screen with your framework.
The class has been written in pure JavaScript, so it can be used together with any HTML5 framework and follows ECMAScript6 syntax.
This is the game I created with it using Phaser 3 to handle input and animations..."