Skip to content

Commit

Permalink
Added T-Spin
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Israel Orta Orta committed Apr 30, 2024
1 parent ccea65d commit 1e294ec
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tetris.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ char GameOn = TRUE;
suseconds_t timer = 400000; // decrease this to make it faster
int decrease = 1000;
int newLines = 0;
char TSpin = 0;

typedef struct {
char array[MAXWIDTH][MAXWIDTH];
Expand Down Expand Up @@ -71,11 +72,19 @@ char **getHoldPiece(){
char CopyMem(char *dst, char *org, unsigned int size){
int i, j;
long long *orgL = (long long*)org, *dstL = (long long*)dst;
int *orgI = (int*)org, *dstI = (int*)dst;
short *orgS = (short*)org, *dstS = (short*)dst;
if (dst == NULL)
return 0;
for (i = 0; i < size / sizeof(long long); i++)
dstL[i] = org != NULL ? orgL[i] : 0;
i = i * sizeof(long long);
i = i * 2;
for (i = i; i < size / sizeof(int); i++)
dstI[i] = org != NULL ? orgI[i] : 0;
i = i * 2;
for (i = i; i < size / sizeof(short); i++)
dstS[i] = org != NULL ? orgS[i] : 0;
i = i * 2;
for (i = i; i < size; i++)
dst[i] = org != NULL ? org[i] : 0;
return 1;
Expand Down Expand Up @@ -248,6 +257,7 @@ void ManipulateCurrent(int action){
RemoveFullRowsAndUpdateScore();
SetNewRandomShape();
AddPendingLines();
TSpin = 0;
break;
case 's':
if (newLines < 0)
Expand All @@ -256,10 +266,13 @@ void ManipulateCurrent(int action){
if(CheckPosition(temp))
current.row++;
else {
WriteToTable();
RemoveFullRowsAndUpdateScore();
SetNewRandomShape();
AddPendingLines();
if (TSpin > 2){
WriteToTable();
RemoveFullRowsAndUpdateScore();
SetNewRandomShape();
AddPendingLines();
TSpin = 0;
} else TSpin++;
}
break;
case 'd':
Expand Down

0 comments on commit 1e294ec

Please sign in to comment.