Problems in my very first game!!
Hello, to get started in gaming, I choose to make a Tetris Clone. It won''t be so fancy, but practical and straightforward.
However, I''m having a problem with one of the algorithms: The Tetraminoe rotation.
I just can''t find out how I should pass data from one array to another, and, I''m a begginer programer, so any help will be useful.
TNX
If you think about it, you''ll find the answer...somehow...
Whats a Tetraminoe rotation? Do you mean the how the shape of the blocks changes when you press the button?
what array?
Are you keeping the block information in a 3*3 or 4*4 array?
one way (but not the best) would be to make a 2D array:-
int BlockShapes[9][3] =
{
{0,0,0},
{1,0,0},
{1,1,1},
{1,1,0},
{1,0,0},
{1,0,0},
{1,1,1},
{0,0,1},
{0,0,0}, // it stores the patterns of the blocks in 1''s
}
I don''t know if this is what you wanted, but I hope it helps
DX++ The DirectX Programming Site
what array?
Are you keeping the block information in a 3*3 or 4*4 array?
one way (but not the best) would be to make a 2D array:-
int BlockShapes[9][3] =
{
{0,0,0},
{1,0,0},
{1,1,1},
{1,1,0},
{1,0,0},
{1,0,0},
{1,1,1},
{0,0,1},
{0,0,0}, // it stores the patterns of the blocks in 1''s
}
I don''t know if this is what you wanted, but I hope it helps
DX++ The DirectX Programming Site
My friend made a 3-d tetris and used matrix multiplication to do rotation. I don't remember what he did. I'll ask him later.
"Remember, I'm the monkey, and you're the cheese grater. So no messing around."
-Grand Theft Auto, London
"It's not whether I win or lose, as long as I piss you off"
-Morrigan, Super Puzzle Fighter II Turbo
Edited by - PsYcHoPrOg on August 20, 2000 8:43:20 PM
"Remember, I'm the monkey, and you're the cheese grater. So no messing around."
-Grand Theft Auto, London
"It's not whether I win or lose, as long as I piss you off"
-Morrigan, Super Puzzle Fighter II Turbo
Edited by - PsYcHoPrOg on August 20, 2000 8:43:20 PM
D:
For my first tetris implementation all I did was store each piece in its own array One array (either a 2x2, 3x3, or 4x4 depending on the piece) for each piece. So, when the piece was shown then I loaded it into a 4x4 array and mapped that array onto the game board. Whenever I needed a rotation to happen, I made the first row of that 4x4 matrix equal the last column of that same 4x4 matrix. Then I set the second row equal to the second to last column of that 4x4 matrix. And so on, until I set the last row to the first column of the 4x4 matrix. That should give you a rotated piece. It''s the same thing that stevenmarky suggested, but you do the rotations at runtime instead of saving them all in arrays.
-Dave
-Dave
I think if you tried to do it with some sort of matrix equation you would need an axis, which would fuck it up because it is a rectangle? I dunno, but maybe...
Maybe you could store an array of differently positioned blocks and have a pointer move up and down the array each time the user pushes a button on the keypad to rotate the block....
Maybe you could store an array of differently positioned blocks and have a pointer move up and down the array each time the user pushes a button on the keypad to rotate the block....
Thanks to every one for their help. I read through all of your replies and suddenly the idea came to my head. All I have to do is a for cicle with 2 nested for cicles. One to get the array in a column by column basis, and the other one to put it into the new position.
THANKS
THANKS
If you think about it, you''ll find the answer...somehow...
I want to try a tetris clone, but I cannot like hell find any docs for creating graphics!!! I''ve only ever used text before, so I''m stumped.
I''m using DJGPP, but may invest in MS VC++ soon.
Can anyone help?!?!?!?!?
Danny
I''m using DJGPP, but may invest in MS VC++ soon.
Can anyone help?!?!?!?!?
Danny
I made my own tetris clone too...
(you can see it at http://www.gtascene.com/~aqutiv/)
anyhow, my algrotihm for rotating was to have a structure
that include the brick map and the number of columns and rows..
like that:
Works like charm.
-Aqutiv
Edited by - Aqutiv on August 24, 2000 4:46:49 PM
(you can see it at http://www.gtascene.com/~aqutiv/)
anyhow, my algrotihm for rotating was to have a structure
that include the brick map and the number of columns and rows..
like that:
struct shape { unsigned short rows, columns; bool blockmap[maxsize][maxsize]; }; //then to rotate a piece:CurrentPiece = MatRotate(CurrentPiece); /*This is obviously done when the user has pressed some key or whatever/*shape MatRotate(shape lclBrck) { shape bricktmp = lclBrck; for (int row = 1; row <= lclBrck.rows; row++) for (int column = 0; column < lclBrck.columns; column++) bricktmp.blockmap[column][lclBrck.rows-row] = lclBrck.blockmap[row-1][column]; bricktmp.rows = lclBrck.columns; bricktmp.columns = lclBrck.rows; return bricktmp;}
Works like charm.
-Aqutiv
Edited by - Aqutiv on August 24, 2000 4:46:49 PM
AquDev - It is what it is.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement