Archived

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

Tetris help

This topic is 5381 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''m having trouble creating multiple blocks. As of now I just created an array of block objects, and each time a block hits the ''floor''. I increment the counter for the array, and create a new block in that array spot. The problem is that either the new block isn''t being created, or exactly the same block is being created, because once the block hits the ''floor'', it appears to jump back to the top of the screen and fall again. http://sfpiano.netfirms.com/tetrisDX9.zip

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think once the block hits the ''floor'' it should not be a block anymore, but become part of the ''block pile'' with other blocks that also touched the floor. That way, you will only need 1 active block at one time

Share this post


Link to post
Share on other sites
How would I go about changing it from a block to a member of the block pile? Because I fixed my original problem, but now whenever I alter the current block, the entire pile gets altered also.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The most important skill for a programmer: debugging!

Put a breakpoint where you change the block type. Trace through the code. Look at what variables you''re changing. Then trace through where blocks get drawn, and compare to the variables you were just looking for. Soon, it''ll become clear what the problem is.


I''d suggest having one active block, and as soon as it hits an obstacle, imprint it onto the game board. The game board can be an array of color. If you try to hold on to block instances, you''ll get into trouble when parts of blocks are deleted when you get a full row.

Share this post


Link to post
Share on other sites
you don't need a pile of block in my opinion, just two blocks you swap around (like for double buffer rendering), for your current moving block and the 'next' block. I remember coding a tetris, about 10 years ago, and I just modelled the bucket thing with a 20x11 2D array, and scanned the lines in the array from the top when a block dropped. you get a full row, drop the rows above by one.

you can use a stack, for 2 players battle mode, where the two players play with the same stack blocks. It's quite simple, when one of the payers block hits the pile, check if the player's next block is at the top of the stack. If not, get the next block in the stack using the index+1, else add a new block in the stack.

my bocks were 2D arrays of 4x4 cells, and I 'precomputed' the animation of each possible tetris shape in 4 of those 2D arrays. When you pressed space, check if you are allowed to rotate, and rotate the shape by pointing to the next 4x4 array.

well, this is my opinion, as the saying says, "opinions are like a**holes, everybody's got to have one".

non!

[edited by - oliii on March 24, 2003 6:05:49 AM]

Share this post


Link to post
Share on other sites