Sign in to follow this  

Problem with Tetris-clone blocks

This topic is 4761 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 am using Dark Basic to create a Tetris-clone called "Stacker" for my game programming course at a local university. I am having a problem with setting the bricks. Ok, here's what I'm doing: The game runs through a user input loop, and at the end of the loop, it moves the piece down. It checks to see if it is colliding with the bricks below it, and if it is, it sets the brick down. However, when I set a brick, if the graphic I am using overlaps the graphic below it, the first one clears out the second one. ..+-+ ..| | +-+-+ | | | +-+-+ | | +-+ | V ..+-+ ..| | +-+-+ | | | +-+-+ | | +-+ Results in: ..+-+ ..| | +-+-+ | | | +-+-+ | | <- Brick should be here +-+-+ | | | +-+-+ | | +-+ Any ideas or tips to help me fix this problem? Thank you in advance.

Share this post


Link to post
Share on other sites
Once you've detected a collision you have to move the piece back up, out of the collision.

Share this post


Link to post
Share on other sites
Is your brick one big image?

If yes, either make the image have a colorkey (one color being transparent) or split the big block in the small blocks and draw them separately.

You usually use method B, since you need the smaller tiles for collision detection anyway.

Share this post


Link to post
Share on other sites
Endurion: Each brick is 30 x 30 pixels, and each piece consists of 4 of these blocks. The piece as a whole is saved as a bitmap with a black background. When the piece is used, it is loaded as a sprite. When the piece is set, the game copies the bitmap over the sprite's final location and uses a new sprite up at the top. The problem is that Dark Basic doesn't support transparency for bitmaps.

And yes, now I am using single blocks and a 10x18 array to hold what color of block is in that location. This also makes it much easier to check for full rows to clear, and it takes less than a system cycle to update all 180 squares.

Morbo: When the piece is falling down, it is actually offset by 2 pixels to test for overlap, but when the piece detects collision, it moves it back up to put the piece in its place. So yes, it only detects for collision once.

Share this post


Link to post
Share on other sites
Sign in to follow this