Jump to content
  • Advertisement
Sign in to follow this  
spx2

buggy tetris game

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

Hi, I've recently wrote a tetris game. I have a bug in it concerning the proper re-drawing of the last line on the screen. (apart from the obvious design problems) I've tried multiple times to correct the bug but I cannot find the cause. I'd be grateful if any of you would like to have a look and tell me. It's written in C++ and SDL. The game and source can be found here http://perlhobby.googlecode.com/svn/trunk/tetris/ the second version.

Share this post


Link to post
Share on other sites
Advertisement
Hi MikeTacular,

Thank you very much for taking a look.
Yes of course I can describe:
The console has the matrix of the active cells on the grid.
When you make a full row that row collapses and let all the rows above it
fall into it(that's how tetris works).
Now,if you will do this(make a full row) , it will indeed collapse but some
of the cells of the row that should collapse will not be updated properly
(in particular,some that should be now empty are still filled with color).
You can try that out and also if you try it ,please tell me if that behaviour
is also present on your system.

Thank you MikeTacular

Share this post


Link to post
Share on other sites
Oh wow, ok, now I notice it. It seems to only clear the bottom row, and it only does it once (actually, sometimes it doesn't clear it). If you fill the bottom row and then fill it again, it doesn't clear it again. Do you think you could post your code? It's easy to see that something is wrong, but it's impossible to tell you why it's wrong without seeing any code.

Share this post


Link to post
Share on other sites
Oh duh, I totally saw the source folder when I downloaded the binaries. Okay, I'm going through it now...

Holy... You make the player not just fill the row, but fill the row with the exact same color? You do realize that this makes it impossible to play the game for very long? Also try to use less macros. A lot less macros. #define for4(x) for(int x=0;x<4;x++) is scary.

Share this post


Link to post
Share on other sites
Quote:
Original post by MikeTacular
Oh duh, I totally saw the source folder when I downloaded the binaries. Okay, I'm going through it now...

Holy... You make the player not just fill the row, but fill the row with the exact same color? You do realize that this makes it impossible to play the game for very long? Also try to use less macros. A lot less macros. #define for4(x) for(int x=0;x<4;x++) is scary.


QFT
bool Grid::RowIsFull(int r) {// see if all colors and active attributes of all cells on that row are the same
Uint32 SameColor = GridCells[0][r].Color;
bool SameActive = GridCells[0][r].active;
for(int x=1;x<WIDTH;x++)
SameColor &=GridCells[x][r].Color,
SameActive &=GridCells[x][r].active;
return ( (SameColor == GridCells[0][r].Color)&&
(SameActive== GridCells[0][r].active)&&
(SameActive!=false)
);
}
doesnt get excecuted at all so it never finds any full rows.

also

void Grid::ImplodeRow(int r) {//this implodes a row so that it disappears and all other rows fall under
//the effect of "gravity"
for(int y=r;y>=FirstUnemptyRow;y--) {
for(int x=0;x<WIDTH;x++) {
GridCells[x][y] = GridCells[x][y-1];
};
};
}


You set FirstUnemptyRow to 19 yet y is never going to be greater than FirstUnemptyRow.

Share this post


Link to post
Share on other sites
Sorry,it seems I've not explained the code properly.
Grid::RowIsFull(int) is called by Grid::CheckForFullRows() is called by Piece::Move(int) .
So it does get called.
About the second part.The numbering of the rows are increasing from the top
of the screen to the bottom of the screen.
FirstUnemptyRow will always be the first counting from top of the screen to the
bottom of the screen which has at least one active gridcell.
The row which will be full will always be Unempty so it will always be after
the FirstUnemptyRow and because of the numbering of the rows that we have
stated before FirstUnemptyRow will always be less or equal to the full row(r in this case).

Share this post


Link to post
Share on other sites
Quote:
Original post by spx2
Sorry,it seems I've not explained the code properly.
Grid::RowIsFull(int) is called by Grid::CheckForFullRows() is called by Piece::Move(int) .
So it does get called.
About the second part.The numbering of the rows are increasing from the top
of the screen to the bottom of the screen.
FirstUnemptyRow will always be the first counting from top of the screen to the
bottom of the screen which has at least one active gridcell.
The row which will be full will always be Unempty so it will always be after
the FirstUnemptyRow and because of the numbering of the rows that we have
stated before FirstUnemptyRow will always be less or equal to the full row(r in this case).



It gets called but does not detect a full row if the colors are different.






bool Grid::RowIsFull(int r)

Does not detect a full row if the color of the blocks are different. When you complete a row with the same colored blocks it works fine.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tha_HoodRat

Does not detect a full row if the color of the blocks are different. When you complete a row with the same colored blocks it works fine.


Yes of course,and that's the intended behaviour
The problem appears after the detection has been made and after the
ImplodeRow(int) routine has been called.
There must be some part where some cleaning of the screen is not done..probably

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!