Advertisement

Help in a Tetris Game

Started by January 03, 2003 08:55 PM
2 comments, last by ironbooker 21 years, 10 months ago
Hi to everyone, im a newbie in game programming i have been programming C++ Since 2 years ago, i want to try to make a very simple game, a tetris style game, since I read all of the articles that are in this site thats what they recommend. ok I Have decided to make it in OpenGL, now i have a big question and maybe dumb one, but the piezes of tetris, how can i make them? I thought of QUADS, but someone told me about arrays something like maps. Could you guys help me and tell what is the best approach of making those piezes?
Create an array for each piece that you want to include and initialise it with values to draw your pieces - OGL has functions t0 deal with rendering from vertex arrays.
For new blocks how about something like this:
int NewBlock()
{
int Block = rand()%7;
switch(Block)
{
case 1:
draw block 1;

case 2:
draw block 2;
}
}

etc,etc

Perhaps create functions to draw each piece then place calls to the relevant function inside the switch.
Advertisement
Thank your for your help let me show what i have now

ok i have an array like this for a pieze




{0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0}, rotations
{0,0,0,0, 1,1,1,1, 0,0,0,0, 0,0,0,0},
{0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0},
{0,0,0,0, 1,1,1,1, 0,0,0,0, 0,0,0,0},
this is for the piece that it is flat like a stick

i think this one easy way to handle the rotation to have the rotations predefined.
what do you think about?
=)
Best Regards
It will certainly make life easier by having already mapped out before hand - at least that way you can simply draw whichever piece is required with a single function call.
I dunno if you have checked it out already but there''s a forum here on GD.net called Hands On Interactive something (i forgot exactly) but in there TeeJ takes you through making a simple Tetris clone - might be of some use to you.

This topic is closed to new replies.

Advertisement