Link and Switch

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!

11 Likes

Sweet implementation :slight_smile:

Discovered a bug with the linker. Sometimes when removing 2 sets of links and the elements are still falling down, the game spawns another table full of elements right over the existing ones. Switching from linker to switcher keeps those elements in the background.

The pause state where you can’t take any action in the switcher might be preventing this bug from happening in that case.

Anyway, this is awesome.

Fuscy

1 Like

Hmm, I’m unable to reproduce this. Are you able to remove another set of links before the ones removed from the first link has stopped falling?

1 Like

Ah silly me. The Linker and Switcher buttons from the menu were still active underneath so you probably managed to switch game mode. I’ve fixed this. Thanks for reporting it!

2 Likes