http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Algorithm to Rotate a piece in Tetris?



    Oh,I'm also making a Tetris clone this week.I'v never refered any other guy's Tetris code,I planned to create a Tetris clone myself.,as to the algorithm for rotating a piece,I'v made out my algorithm(maybe it's not an algorithm in deed),but it really works.
    A basic Tetris has seven types of pieces,such as L,T,Z,etc,each of pieces has several status,e.g: "L",it has 4 status----
             0 0              0      0  0  0
0           0                 0              0
0 0 0     0              0 0
I'v made a [28][16] array to stroe all status of these seven piece(alough some picecs' status is less than 4),following is my array:
int Map[28][16]={
 0,3,3,3,0,3,3,3,1,1,1,1,3,3,0,0, file://type 0 status 0
 0,1,3,3,0,1,3,3,3,1,3,3,3,1,0,0, file://type 0 status 1
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 0 status 2
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 0 status 3
 0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1, file://type 1 status 0
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 1 status 1
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 1 status 2
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 1 status 3
 0,0,0,0,1,1,3,0,0,1,1,0,0,3,3,0, file://type 2 status 0
 0,0,0,0,3,3,1,0,0,1,1,0,0,1,3,0, file://type 2 status 1
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 2 status 2
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 2 status 3
 0,0,0,0,0,3,1,1,0,1,1,0,0,3,3,0, file://type 3 status 0
 0,0,0,0,0,1,3,3,0,1,1,0,0,3,1,0, file://type 3 status 1
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 3 status 2
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, file://type 3 status 3
 0,0,0,0,3,3,3,0,1,3,0,0,1,1,1,0, file://type 4 status 0
 0,0,0,0,3,1,1,0,3,1,3,0,3,1,0,0, file://type 4 status 1
 0,0,0,0,1,1,1,0,0,0,1,0,0,3,3,0, file://type 4 status 2
 0,0,0,0,0,0,1,0,3,0,1,0,3,1,1,0, file://type 4 status 3
 0,0,0,0,0,0,3,0,0,3,3,1,0,1,1,1, file://type 5 status 0
 0,0,0,0,0,0,1,3,0,3,1,3,0,3,1,1, file://type 5 status 1
 0,0,0,0,0,3,3,3,0,1,1,1,0,1,3,3, file://type 5 status 2
 0,0,0,0,0,1,1,3,0,0,1,3,0,3,1,3, file://type 5 status 3
 0,0,0,0,0,3,1,3,0,1,1,1,0,0,3,3, file://type 6 status 0
 0,0,0,0,0,0,1,3,0,3,1,1,0,3,1,3, file://type 6 status 1
 0,0,0,0,0,3,3,0,0,1,1,1,0,3,1,3, file://type 6 status 2
 0,0,0,0,0,3,1,3,0,1,1,3,0,3,1,0  file://type 6 status 3
};
in fact every status as a 4*4 square,0 indicates empty(don't draw tetris unit),1 indicates here has a tetris unit(draw it),and 3 indicates if here has a tetris unit(maybe dropped before),the current tetris would not be rotated(the rotation is blocked).
I'v said I'm new to game programming,this method maybe shabby,because it's lack of reflection(I'v worked out this way during my class).I wish it would make help.

chris tj

----- Original Message ----- 
From: Justin Todd <excuseme32@hotmail.com>
To: <GameProgrammer@gameprogrammer.com>
Sent: Sunday, April 16, 2000 12:27 PM
Subject: Algorithm to Rotate a piece in Tetris?


> I am creating a Tetris clone, and I was wondering if there is anyone who has 
> made this game in the past that has a good algorithm for rotating a piece.
> 
> Thankyou
> Justin Todd
> 
> Webpage: justin-todd.tripod.com
> 


Njg+ji*&x%b+݊.Ȩڟ+h'+zVyhyn",k
ښhzbجz^r&+hڞm"wgzVނ)z(Ǔ%H$HJ+PԔ  )zm z(XXf