Bejewelled logic

Posting this here as I think there seem to be more people replying in this thread.

https://developer.anscamobile.com/forum/2011/02/05/collisions-multiple-objects

I’m looking to setup Bejewelled logic where if more than 3 of the same object collide they will all be detroyed, however any less and they stay put.

Any advice? [import]uid: 31694 topic_id: 6336 reply_id: 306336[/import]

bejewelled doesnt use collisions [import]uid: 6645 topic_id: 6336 reply_id: 21929[/import]

got flash? check this code out…
http://krazydad.com/bestiary/bestiary_gummies.html
[import]uid: 6645 topic_id: 6336 reply_id: 21930[/import]

I don’t know how to describe the logic any better than “Bejewelled” but it’s not exactly what I want. I want random objects to fall down under gravity to the bottom of the screen. When any 3 of the same type touch, they disappear. [import]uid: 31694 topic_id: 6336 reply_id: 22019[/import]

there is a Box2D “match 3” flash game source here http://www.kongregate.com/forums/4-programming/topics/81112-match-3-type-game-with-box2d-trouble-with-the-match-3?page=2

you can convert that to Lua, since the same physics properties are available (maybe with slightly different names)

basically when an object touches you add it to a group (list) of all connected objects of the same type and store that list against each object. then when an object disconnects you break the list into 2 groups (the ones still connected to it and the ones not connected to it) and then store the list against the relevant objects again. by checking the length of this list you can check which are connected to at least 2 others, and do your match [import]uid: 6645 topic_id: 6336 reply_id: 22099[/import]