In the next part of this series a new class is created that can generically handle any match 3 grid system.
Emanuele Feronato continues his series: "I was looking at all the Bejeweled prototypes I made during these years and I noticed each time I port the game in a new language or framework, I simply have to handle different ways to make the player interact and how to place and move stuff on the screen.
The rest of the engine basically remains the same. So I decided to split the prototype in two: a Match3 class which handles what happens under the hood and tells the framework how to move items on the screen, and the framework-specific part where I manage player input and move stuff around.
The class itself is still just a prototype because I have to add some more methods, but I was able to have my Bejeweled game running just by handling input and animations.
One feature I really like is the way the class tells the main script what to move and how to move: an array of objects with item row, item column, delta row – the amount of rows you have to move the item – and delta column – same concept applied to columns – is returned each time the player moves."