Skip to main content
gamedev.net
🔒 Locked

Block falling algorithm.....

Started by Dark Star Aug 31, 2003 at 7:22 AM 0 replies 550+ views
Original Post
Dark Star
Dark Star
Hi all, been playing mr driller lately to study for a project, Im making a remake of it soon I was puzzled by how they make the blocks fall when the level is being re-adjusted, by that I mean when a block below ceases to exist, how do they make the others fall? I know how Id do it, but I dont get how they do it when u got connected blocks. To see what I mean check out the illustration below:

    1
    2345
      6
    X
say the numbers one to six are the coloured blocks (all with same colour and connected to each other) and X is another colour block. all the coloured blocks (the same number) should fall until block 2 sits on top of block X. like so
    1
    2345
    x 6
Mr Driller does this and I got no idea how I would design an algorithm to do this....blocks 3,4,5,6 and 1 dont fall all because they are connected to block 2 that is sitting on a block (x) which cannot fall. Thanks for your help Dark Star UK [edited by - dark star on August 31, 2003 8:27:08 AM]
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
PhiberOptic
PhiberOptic
Easy.. if I got it right..

Loop through all connected blocks and check if they are blocked by a X-block. If so, don''t do anything else and the other blocks won''t fall too..

if no X-block are detected, then move each block one unit down.

Done! =)


----------------------------------------------
Petter Nordlander

"There are only 10 kinds of people in the world. The who understand binary and those who don''t"
----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. They who understand binary and those who do not"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.