Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Jesse Chounard

Data structures and algorithms for falling blocks games.

This topic is 6927 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've recently written my first ever falling blocks game (see Bugz in the GameDev contest), and now I'm working on my second, and I have a few questions. First I'll explain my problem. In other games I've written (like Space Invaders), when the user presses a direction key (the left arrow, for example), I simply update the users movement velocities, and on the following frames the animation is smooth as that velocity is applied. However, in a falling blocks games (Columns for example), the only legal places for a block to exist is in one of the vertical columns with other blocks. This is so that when it falls to the bottom, it lines up nicely with other blocks. This doesn't make for very smooth movement, however. Does anybody know a nice solution? (Am I explaining the problem well enough?) And my other question: What is the best way to store the data? In Bugz, I used a 2d array of a structure called BugStruct, and when pieces moved, I simply shifted data around in the array. This isn't a very quick way to do things, and won't work very nicely if I try to implement the smooth movement I described above. I could use a linked list of all the blocks currently in play, but then I'd need to run collision tests with a high number of blocks constantly, and lose the efficiency I'm trying to gain. Any thoughts? Jesse Chounard Edited by - Jesse Chounard on 5/7/00 7:38:04 PM

Share this post


Link to post
Share on other sites
Advertisement
the way i handled it was such:
i divided up the playing-area into a kinda 10x20 matrix. each area coordinate ([0,0] to [9,19]) was mapped to a region of the screen. i had a 10x20 array for keeping track of all the blocks in the ''mass'', the stationary blocks. i think this is how you did it too..

this is where i think our methods differ, though..
each block was composed of four sub-blocks (a tetra-block), and i stored the playing-area coordinates of each sub-block in a 4x2 array (pos[4][2]). i drew the mass matrix first, then the current block.. when the block hit something, i copied it into the corresponding part of the mass matrix.. it worked pretty well...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!