|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: How did you make tetris...please help
OK, the way I programmed my Tetris clone is like this:
ARRAYS:
I used a 16x9 array for the Tetris "board," - this means that every
non-moving block that is displayed is defined in this array.
I used an ACTIVEBLOCK array of variable size. Here I put all the
locations, orientation (how they're rotated), and speed of all the MOVING
blocks (my program had variable speed). Non-moving blocks - ones stored in
the board, are never changing and therefore do not need to be defined in
ACTIVEBLOCK, as long as they are on the screen.
FUNCTIONS:
TestLine() - This function tested to see if a horizontal row of blocks
was created. (Did the player make a complete line across the board?) If so,
then we need to remove it, award points, and redefine the board. This
function also tested to see if there were multiple horizontal lines in a row
- more points!
MoveBlocks() - This function moved all the blocks in ACTIVEBLOCK down a
space. It also tests for blocks that can't go down anymore, therefore
removing them from ACTIVEBLOCK and just declaring them in board.
UserInput() - Tests user input
RotateBlock() - This rotates a certain block in a certain direction. For
this, I just stored all the different rotations/orientations of the blocks in
an array and called it as necessary. It is possible to calculate rotations,
though. (look through the gameprogrammer archives for that).
DelayTimer() - This function was jsut a countdown until MoveBlocks() was
called.
ShowBlocks() - This displays all the blocks on the screen from the board
and from ACTIVEBLOCK.
Plus there was music, animations, sound effects, and 3D-morphing, but you
don't need to worry about that for a simple tetris game. :) Good luck. Sorry
I didn't explain much, it's just that I don't have the code with me, so I
can't really give a walkthrough of how it worked. But, it isn't THAT
complicated and you should do just fine.
-Ender Wiggin
=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once
To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html
|
|