There was a question a while back on the forum about how to deal with the data structure of a linker or match 3 game (switcher) and it got me thinking how I would go about creating such a game myself. In my previous attempts I have always gone with a grid like data structure to hold the blocks on the game board, but this time I thought I would try to do something else. The example I’m sharing here keeps a single list of spawned blocks and then relies on the physics system to detect when a block should fall or which neighbours it has. This system proves to be a lot simpler to work with than trying to keep a grid-like data structure up-to-date when blocks are removed, spawned and falling.
The example is available here: https://github.com/britzl/linkandswitch and a playable version here: https://britzl.github.io/linkandswitch/
Enjoy!