Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tetris Array type question...i think

Status
Not open for further replies.

Scifiintel

Programmer
Jan 9, 2002
4
US
im making a tetris game out of these...[]
[]
[]
[][] ...so, a tetris game area is 10 by 20 blocks big. How can I relatively easily make integer variables for each block so that i can be able to know whether the space has a block or not, and then easily be able to manipulate the block left and right and down so it doesn't hit anything(just think of tetris)? Any suggestions would be greatly appreciated...
Thanks
Sci
 
::) Sounds like a possible school project, so only one clue: use a two dimensional integer array. Check it before each move and then be sure to update it.
 
i would go about it a different way (as it is a school project only a small tip from me as well)

Because the width of the playing area will never exceed 32 why not make an array of unsigned integers

unsigned int rows[x]; where x is the number of rows. Then you could set each bit depending on if there is something there. Also it provided an easy way to "CLEAR" the row (simple setting it to zero, and then moving down a row (i.e. you clear the bottom row and everything falls down) would be a simple loop.

Just a thought

Matt

P.S. That sounds like morning jibberish and it is because im on my first cup of coffee... i think the idea is represented properly though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top