Archived

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

ideas for my problem.

This topic is 5618 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

Didn't really think about it until now but i'm working on a directx tetris clone and i'm using direct8 sprites. I loaded a bitmap as a background and using the SetRect function for the pieces. So each time i move the piece to the side left or right it redraws each block using variables to figure out where it's on the screen. My question is when the pieces start stacking on the bottom how do i not have them overlap. Have them stack on top of each other. I have two ideas. 1) Creating a array and marking where each piece is after each move and checking the array making sure they don't overlap. 2) Figure out what color on a specific pixel and that will tell me what's there if anything. The problem with 2 is that i was told you have to lock and unlock each time you find a color and if i do this after each move could really slow down my program. What do you think? Thanks for your help!! Ryan [edited by - Ryanrk on July 26, 2002 1:31:30 AM] [edited by - Ryanrk on July 26, 2002 1:32:08 AM]

Share this post


Link to post
Share on other sites
Method 1, the array, is certainly the best as it will allow you to quickly and easily check for collisions and for completed lines.

Checking against colours raises a lot of issues when using DirectX on PCs, and is best avoided for many reasons.

Cheers,
John

Share this post


Link to post
Share on other sites
You could simply define a certain width and height each block has. A block is then the smallest unit from which the dropping stones are constructed.
In order to determine which positions are already filled you can keep a boolean array with an entry for each location a block can land on.

Im Anfang war die Tat...
Faust

Share this post


Link to post
Share on other sites