Skip to main content
GameDev.net gamedev.net
🔒 Locked

Data structures and algorithms for falling blocks games.

Started by Jesse Chounard May 7, 2000 at 7:35 PM 0 replies 2k views
Original Post
Jesse Chounard
Jesse Chounard
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
fuzzyai
fuzzyai
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...

Topic Locked

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

Sign in to reply to this topic.