summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/functions.c834
-rw-r--r--src/include/common.h36
-rw-r--r--src/include/functions.h9
-rw-r--r--src/include/tet_conf.h3
-rw-r--r--src/main.c71
-rw-r--r--src/shape_maps.c148
6 files changed, 468 insertions, 633 deletions
diff --git a/src/functions.c b/src/functions.c
index 997bbc4..68cb377 100644
--- a/src/functions.c
+++ b/src/functions.c
@@ -2,24 +2,20 @@
#include "include/common.h"
/* Externs from main.c */
-int activeShape_s = 1; // Rotate state of activeShape
-int activeShape_t = 1; // Type of shape (look at shape_maps.c)
-extern sfVector2f textScore_pos;
-extern sfText* textScore;
-extern sfFont* font;
-extern int gameIsStarted;
-
-extern sfRectangleShape* fld[20][10]; // Array of field rectangles
-extern sfVector2f fld_rPos[20][10]; // Array of absolute coordinates of field rectangles
-extern int fld_rOutThick; // Field rectangles outline thickness
-extern sfVector2f fld_rSize; // Field rectangles size variable x/y
+extern sfRectangleShape *fld[20][10]; // Array of field rectangles
+extern sfVector2f fldCPos[20][10]; // Array of absolute coordinates of field rectangles
+extern sfVector2i fldSize;
+extern sfVector2i fldPos;
+extern sfVector2f fldCSize; // Field rectangles size variable x/y
+extern int fldCOutThick; // Field rectangles outline thickness
-extern sfVector2i actiShPos; // Active shape offset relative to field
+extern sfVector2f textScore_pos;
+extern sfText *textScore;
+extern sfFont *font;
+extern int gameIsStarted;
-extern sfVector2i fldSize, fldPos;
-extern sfVector2i actiShPos; // Offset active shape relative to field
-extern short arrKeys; // arrow keys states byte container
+extern uint8_t arrKeys; // arrow keys states byte container
/* arrKeys = ...n|7|6|5|4|3|2|1|0| (just a little bit of such called "bit fucking")
* 0 - Right arrow pushed and held
* 1 - Down arrow pushed and held
@@ -31,65 +27,66 @@ extern short arrKeys; // arrow keys states byte container
* 7 - Right arrow short repeat activated (after once long repeat)
*/
-sfClock* gameTick;
-sfClock* mTick;
-sfClock* repPushDown; // Clock for repeat latency when Down arrow long push
-sfClock* repPushLeft; // Clock for repeat latency when Left arrow long push
-sfClock* repPushRight; // Clock for repeat latency when Left arrow long push
+sfClock *gameTick;
+sfClock *mTick;
+sfClock *repPushDown; // Clock for repeat latency when Down arrow long push
+sfClock *repKeyLeft; // Clock for repeat latency when Left arrow long push
+sfClock *repKeyRight; // Clock for repeat latency when Left arrow long push
extern int lvlLatency;
extern int scoreCurrent;
-extern char* scoreDisp;
+extern char *scoreDisp;
/* Shapes maps */
-extern short arrShapeL_a1[4][4];
-extern short arrShapeL_a2[4][4];
-extern short arrShapeL_a3[4][4];
-extern short arrShapeL_a4[4][4];
-
-extern short arrShapeRL_a1[4][4];
-extern short arrShapeRL_a2[4][4];
-extern short arrShapeRL_a3[4][4];
-extern short arrShapeRL_a4[4][4];
-
-extern short arrShapeZ_a1[4][4];
-extern short arrShapeZ_a2[4][4];
-extern short arrShapeZ_a3[4][4];
-extern short arrShapeZ_a4[4][4];
-
-extern short arrShapeS_a1[4][4];
-extern short arrShapeS_a2[4][4];
-extern short arrShapeS_a3[4][4];
-extern short arrShapeS_a4[4][4];
-
-extern short arrShapeB_a1[4][4];
-extern short arrShapeB_a2[4][4];
-extern short arrShapeB_a3[4][4];
-extern short arrShapeB_a4[4][4];
-
-extern short arrShapeI_a1[4][4];
-extern short arrShapeI_a2[4][4];
-extern short arrShapeI_a3[4][4];
-extern short arrShapeI_a4[4][4];
-
-extern short arrShapeT_a1[4][4];
-extern short arrShapeT_a2[4][4];
-extern short arrShapeT_a3[4][4];
-extern short arrShapeT_a4[4][4];
+extern uint8_t arrShapeL_a1[4][4];
+extern uint8_t arrShapeL_a2[4][4];
+extern uint8_t arrShapeL_a3[4][4];
+extern uint8_t arrShapeL_a4[4][4];
+
+extern uint8_t arrShapeRL_a1[4][4];
+extern uint8_t arrShapeRL_a2[4][4];
+extern uint8_t arrShapeRL_a3[4][4];
+extern uint8_t arrShapeRL_a4[4][4];
+
+extern uint8_t arrShapeZ_a1[4][4];
+extern uint8_t arrShapeZ_a2[4][4];
+extern uint8_t arrShapeZ_a3[4][4];
+extern uint8_t arrShapeZ_a4[4][4];
+
+extern uint8_t arrShapeS_a1[4][4];
+extern uint8_t arrShapeS_a2[4][4];
+extern uint8_t arrShapeS_a3[4][4];
+extern uint8_t arrShapeS_a4[4][4];
+
+extern uint8_t arrShapeB_a1[4][4];
+extern uint8_t arrShapeB_a2[4][4];
+extern uint8_t arrShapeB_a3[4][4];
+extern uint8_t arrShapeB_a4[4][4];
+
+extern uint8_t arrShapeI_a1[4][4];
+extern uint8_t arrShapeI_a2[4][4];
+extern uint8_t arrShapeI_a3[4][4];
+extern uint8_t arrShapeI_a4[4][4];
+
+extern uint8_t arrShapeT_a1[4][4];
+extern uint8_t arrShapeT_a2[4][4];
+extern uint8_t arrShapeT_a3[4][4];
+extern uint8_t arrShapeT_a4[4][4];
/*
* Init routine. Performs once per program run
*
*/
-void initAll() {
+void initAll()
+{
/*
* Dimensions of every fld's block
* 19px - fill color 1px - for outline, 20 - at all
*
*/
- fld_rSize.x = 23;
- fld_rSize.y = 23;
+ fldCSize.x = 23;
+ fldCSize.y = 23;
fldPos.x = 10; // Field's bottom left corner coordinates
fldPos.y = 10+500-25;
@@ -102,24 +99,21 @@ void initAll() {
resetActiveShape();
/* Create field */
- for (int j=0;j<fldSize.y;j++){
- for(int i=0;i<fldSize.x;i++){
- fld_rAttr[j][i].fColor = uiColor1; // Fill empty color
- fld_rAttr[j][i].oColor = uiColor2; // Outlie empty color
- fld_rAttr[j][i].a = 0; // Inactive = empty
- fld_rPos[j][i].x = fldPos.x
- + (i * (fld_rSize.x + 2 * fld_rOutThick));
- fld_rPos[j][i].y = fldPos.y -
- (j * (fld_rSize.y + 2 * fld_rOutThick));
+ for (int j = 0; j < fldSize.y; j++) {
+ for(int i = 0; i < fldSize.x; i++) {
+ fldCAtt[j][i].a = 0; // Inactive = empty
+ fldCPos[j][i].x = fldPos.x
+ + (i * (fldCSize.x + 2 * fldCOutThick));
+ fldCPos[j][i].y = fldPos.y -
+ (j * (fldCSize.y + 2 * fldCOutThick));
fld[j][i] = sfRectangleShape_create();
- sfRectangleShape_setFillColor(fld[j][i],
- fld_rAttr[j][i].fColor);
- sfRectangleShape_setSize(fld[j][i], fld_rSize);
- sfRectangleShape_setPosition(fld[j][i], fld_rPos[j][i]);
+ sfRectangleShape_setFillColor(fld[j][i], uiColor1);
+ sfRectangleShape_setSize(fld[j][i], fldCSize);
+ sfRectangleShape_setPosition(fld[j][i], fldCPos[j][i]);
sfRectangleShape_setOutlineColor(fld[j][i],
- fld_rAttr[j][i].oColor);
+ uiColor3);
sfRectangleShape_setOutlineThickness(fld[j][i],
- fld_rOutThick);
+ fldCOutThick);
}
}
font = sfFont_createFromFile("dat/arial.ttf");
@@ -162,31 +156,23 @@ int linesRmScore()
int s = 0;
for (int j = 0; j < 20; j++) {
for (int i = 0; i < 10; i++) {
- if (fld_rAttr[j][i].a == 1)
+ if (fldCAtt[j][i].a != 0)
k++;
}
- if (k >= 10) { // If line is full
- s++; // Take scores for line
+ if (k >= 10) { // If line is full
+ s++; // Give scores for line
for (int n = j; n < 20; n++) { // Drop all lines down
if (n == 19) {
for (int m = 0; m < 10; m++) {
- fld_rAttr[n][m].a = 0;
- fld_rAttr[n][m].fColor
- = uiColor1;
- fld_rAttr[n][m].oColor
- = uiColor2;
- }
- } else {
- for (int m = 0; m < 10; m++) {
- fld_rAttr[n][m].a
- = fld_rAttr[n+1][m].a;
- fld_rAttr[n][m].fColor
- = fld_rAttr[n+1]
- [m].fColor;
- fld_rAttr[n][m].oColor
- = fld_rAttr[n+1]
- [m].oColor;
+ fldCAtt[n][m].a = 0;
+ fldCAtt[n][m].fColor = uiColor1;
}
+ break;
+ }
+ for (int m = 0; m < 10; m++) {
+ fldCAtt[n][m].a = fldCAtt[n+1][m].a;
+ fldCAtt[n][m].fColor
+ = fldCAtt[n+1][m].fColor;
}
}
j--; // Do not let loop to go to next line because
@@ -197,78 +183,87 @@ int linesRmScore()
return s; // Return number of deleted lines
}
+/*
+ * Inserts shape into field, runs filled lines searching, puts new shape
+ * into the game at the top.
+ *
+ */
void putShape()
{
for (int j = 0; j < 4; j++) {
for (int i = 0; i < 4; i++) {
- if (activeShape[j][i].a == 1) {
- fld_rAttr[j+actiShPos.y]
- [i+actiShPos.x].a
- = activeShape[j][i].a;
- if ((j+actiShPos.y >= 0)
- && (i+actiShPos.x >= 0)) {
- fld_rAttr[j+actiShPos.y]
- [i+actiShPos.x].fColor
- = activeShape[j][i].fColor;
- fld_rAttr[j+actiShPos.y]
- [i+actiShPos.x].oColor
- = activeShape[j][i].oColor;
+ if (actiSh.c[j][i]) {
+ fldCAtt[j+actiSh.y][i+actiSh.x].a
+ = actiSh.c[j][i];
+ if ((j+actiSh.y >= 0)
+ && (i+actiSh.x >= 0)) {
+ fldCAtt[j+actiSh.y][i+actiSh.x].fColor
+ = actiSh.fColor;
}
}
}
}
- resetActiveShape();
scoreCurrent += linesRmScore()*100; // Remove filled lines and
// get score;
+ resetActiveShape();
}
void resetActiveShape()
{
- actiShPos.x = 3;
- actiShPos.y = 16;
- activeShape_s = 1;
- activeShape_t = (rand()%7)+1; // Insert new random shape of 7 variants
- for (int j=0;j<4;j++) {
- for (int i=0;i<4;i++) {
- switch (activeShape_t) {; // Copy cell active/inactive state
- case 1 :
- activeShape[j][i].a = arrShapeL_a1[j][i];
- activeShape[j][i].fColor = tOrange;
- break;
- case 2 :
- activeShape[j][i].a = arrShapeRL_a1[j][i];
- activeShape[j][i].fColor = tBlue;
- break;
- case 3 :
- activeShape[j][i].a = arrShapeZ_a1[j][i];
- activeShape[j][i].fColor = tRed;
- break;
- case 4 :
- activeShape[j][i].a = arrShapeS_a1[j][i];
- activeShape[j][i].fColor = tGreen;
- break;
- case 5 :
- activeShape[j][i].a = arrShapeB_a1[j][i];
- activeShape[j][i].fColor = tYellow;
- break;
- case 6 :
- activeShape[j][i].a = arrShapeI_a1[j][i];
- activeShape[j][i].fColor = tCyan;
- break;
- case 7 :
- activeShape[j][i].a = arrShapeT_a1[j][i];
- activeShape[j][i].fColor = tMagneta;
- break;
- }
- activeShape[j][i].oColor = sfBlack;
- }
+ actiSh.x = 3;
+ actiSh.y = 16;
+ actiSh.r = 1;
+ actiSh.t = (rand()%7)+1; // Insert new random shape of 7 variants
+ switch (actiSh.t) { // Copy cell active/inactive state
+ case 1 :
+ memcpy(&actiSh.c[0][0],
+ &arrShapeL_a1[0][0],
+ sizeof(uint8_t)*4*4);
+ actiSh.fColor = tOrange;
+ break;
+ case 2 :
+ memcpy(&actiSh.c[0][0],
+ &arrShapeRL_a1[0][0],
+ sizeof(uint8_t)*4*4);
+ actiSh.fColor = tBlue;
+ break;
+ case 3 :
+ memcpy(&actiSh.c[0][0],
+ &arrShapeZ_a1[0][0],
+ sizeof(uint8_t)*4*4);
+ actiSh.fColor = tRed;
+ break;
+ case 4 :
+ memcpy(&actiSh.c[0][0],
+ &arrShapeS_a1[0][0],
+ sizeof(uint8_t)*4*4);
+ actiSh.fColor = tGreen;
+ break;
+ case 5 :
+ memcpy(&actiSh.c[0][0],
+ &arrShapeB_a1[0][0],
+ sizeof(uint8_t)*4*4);
+ actiSh.fColor = tYellow;
+ break;
+ case 6 :
+ memcpy(&actiSh.c[0][0],
+ &arrShapeI_a1[0][0],
+ sizeof(uint8_t)*4*4);
+ actiSh.fColor = tCyan;
+ break;
+ case 7 :
+ memcpy(&actiSh.c[0][0],
+ &arrShapeT_a1[0][0],
+ sizeof(uint8_t)*4*4);
+ actiSh.fColor = tMagneta;
+ break;
}
}
/*
* Game tick
*
- * */
+ */
void tTick()
{ // If tick exceeds current level tick latency
if (sfClock_getElapsedTime(gameTick).microseconds >= lvlLatency) {
@@ -276,155 +271,75 @@ void tTick()
/* if bottom not reached */
if ((wallCollisionCheck(0b0010) == 0) &&
(cellCollisionCheck(0b0010) == 0))
- actiShPos.y--; // Move
+ actiSh.y--; // Move
else
putShape(); // Just put the shape
}
}
-void rotateS1()
-{
- for (int j=0;j<4;j++) {
- for (int i=0;i<4;i++) {
- switch (activeShape_t) {
- case 1 :
- activeShape[j][i].a = arrShapeL_a1[j][i]; break; // Copy cell active/inactive state L type
- case 2 :
- activeShape[j][i].a = arrShapeRL_a1[j][i]; break; // Copy cell active/inactive state RL type
- case 3 :
- activeShape[j][i].a = arrShapeZ_a1[j][i]; break; // Copy cell active/inactive state Z type
- case 4 :
- activeShape[j][i].a = arrShapeS_a1[j][i]; break; // Copy cell active/inactive state S type
- case 5 :
- activeShape[j][i].a = arrShapeB_a1[j][i]; break; // Copy cell active/inactive state B type
- case 6 :
- activeShape[j][i].a = arrShapeI_a1[j][i]; break; // Copy cell active/inactive state I type
- case 7 :
- activeShape[j][i].a = arrShapeT_a1[j][i]; break; // Copy cell active/inactive state T type
- default : //If type is invalid
- activeShape_t = 1; //Set valid type
- }
- }
- }
-}
-void rotateS2()
+/*
+ * Rotate matrix left routine
+ *
+ */
+void rotateLeft()
{
- for (int j=0;j<4;j++) {
- for (int i=0;i<4;i++) {
- switch (activeShape_t) {
- case 1 :
- activeShape[j][i].a = arrShapeL_a2[j][i]; break; // Copy cell active/inactive state L type
- case 2 :
- activeShape[j][i].a = arrShapeRL_a2[j][i]; break; // Copy cell active/inactive state RL type
- case 3 :
- activeShape[j][i].a = arrShapeZ_a2[j][i]; break; // Copy cell active/inactive state Z type
- case 4 :
- activeShape[j][i].a = arrShapeS_a2[j][i]; break; // Copy cell active/inactive state S type
- case 5 :
- activeShape[j][i].a = arrShapeB_a2[j][i]; break; // Copy cell active/inactive state B type
- case 6 :
- activeShape[j][i].a = arrShapeI_a2[j][i]; break; // Copy cell active/inactive state I type
- case 7 :
- activeShape[j][i].a = arrShapeT_a2[j][i]; break; // Copy cell active/inactive state T type
- default : //If type is invalid
- activeShape_t = 1; //Set valid type
- }
- }
+ uint8_t arr[4][4];
+ memcpy(&arr[0][0], &actiSh.c[0][0], sizeof(uint8_t)*4*4);
+ if (actiSh.t == 5)
+ return;
+ if (actiSh.t == 6) {
+ for (int j = 3; j >= 0; j--)
+ for (int i = 0; i < 4; i++)
+ actiSh.c[j][i] = arr[3-i][3-j];
+ return;
}
+ for (int j = 3; j > 0; j--)
+ for (int i = 0; i < 3; i++)
+ actiSh.c[j][i] = arr[3-i][j-1];
}
-void rotateS3()
-{
- for (int j=0;j<4;j++) {
- for (int i=0;i<4;i++) {
- switch (activeShape_t) {
- case 1 :
- activeShape[j][i].a = arrShapeL_a3[j][i]; break; // Copy cell active/inactive state L type
- case 2 :
- activeShape[j][i].a = arrShapeRL_a3[j][i]; break; // Copy cell active/inactive state RL type
- case 3 :
- activeShape[j][i].a = arrShapeZ_a3[j][i]; break; // Copy cell active/inactive state Z type
- case 4 :
- activeShape[j][i].a = arrShapeS_a3[j][i]; break; // Copy cell active/inactive state S type
- case 5 :
- activeShape[j][i].a = arrShapeB_a3[j][i]; break; // Copy cell active/inactive state B type
- case 6 :
- activeShape[j][i].a = arrShapeI_a3[j][i]; break; // Copy cell active/inactive state I type
- case 7 :
- activeShape[j][i].a = arrShapeT_a3[j][i]; break; // Copy cell active/inactive state T type
- default : //If type is invalid
- activeShape_t = 1; //Set valid type
- }
- }
- }
-}
-void rotateS4()
+/*
+ * Rotate matrix right routine
+ *
+ */
+void rotateRight()
{
- for (int j=0;j<4;j++) {
- for (int i=0;i<4;i++) {
- switch (activeShape_t) {
- case 1 :
- activeShape[j][i].a = arrShapeL_a4[j][i]; break; // Copy cell active/inactive state L type
- case 2 :
- activeShape[j][i].a = arrShapeRL_a4[j][i]; break; // Copy cell active/inactive state RL type
- case 3 :
- activeShape[j][i].a = arrShapeZ_a4[j][i]; break; // Copy cell active/inactive state Z type
- case 4 :
- activeShape[j][i].a = arrShapeS_a4[j][i]; break; // Copy cell active/inactive state S type
- case 5 :
- activeShape[j][i].a = arrShapeB_a4[j][i]; break; // Copy cell active/inactive state B type
- case 6 :
- activeShape[j][i].a = arrShapeI_a4[j][i]; break; // Copy cell active/inactive state I type
- case 7 :
- activeShape[j][i].a = arrShapeT_a4[j][i]; break; // Copy cell active/inactive state T type
- default : //If type is invalid
- activeShape_t = 1; //Set valid type
- }
- }
- }
+ uint8_t arr[4][4];
+ memcpy(&arr[0][0], &actiSh.c[0][0], sizeof(uint8_t)*4*4);
+ if (actiSh.t == 5)
+ return;
+ if (actiSh.t == 6) {
+ for (int j = 3; j >= 0; j--)
+ for (int i = 0; i < 4; i++)
+ actiSh.c[j][i] = arr[3-i][3-j];
+ return;
+ }
+ for (int j = 3; j > 0; j--)
+ for (int i = 0; i < 3; i++)
+ actiSh.c[j][i] = arr[i+1][3-j];
}
+
+/*
+ * Rotates active shape with callling collision checkers
+ *
+ */
void rotateShape()
{
- switch (activeShape_s) {
- case 1 :
- rotateS2(); // Make rotate
- if ((wallRotCollisionCheck() == 1) || // If collision happens
- (cellRotCollisionCheck() == 1)) rotateS1(); // Just rotate back =)
- else activeShape_s++; // Change state to next
- break;
- case 2 :
- rotateS3(); // Make rotate
- if ((wallRotCollisionCheck() == 1) || // If collision happens
- (cellRotCollisionCheck() == 1)) rotateS2(); // Just rotate back =)
- else activeShape_s++; // Change state to next
- break;
- case 3 :
- rotateS4(); // Make rotate
- if ((wallRotCollisionCheck() == 1) || // If collision happens
- (cellRotCollisionCheck() == 1)) rotateS3(); // Just rotate back =)
- else activeShape_s++; // Change state to next
- break;
- case 4 :
- rotateS1(); // Make rotate
- if ((wallRotCollisionCheck() == 1) || // If collision happens
- (cellRotCollisionCheck() == 1)) rotateS4(); // Just rotate back =)
- else activeShape_s = 1; // Change state to next
- break;
- default: // If rotate state is invalid
- activeShape_s = 1; // Set valid state
- rotateShape(); // And repeat rotate function
- }
+ rotateRight(); // Make rotate
+ if ((wallRotCollisionCheck() == 1)
+ || (cellRotCollisionCheck() == 1))
+ rotateLeft(); // Just rotate back =)
}
int cellRotCollisionCheck()
{
- for (int j=0;j<4;j++) {
- for (int i=0;i<4;i++) {
- if ((activeShape[j][i].a == 1) && // If any active cell of shape meet any active cell
- (fld_rAttr[j+actiShPos.y][i+actiShPos.x].a == 1)) // of fld
+ for (int j = 0; j < 4; j++) {
+ for (int i = 0; i < 4; i++) {
+ if (actiSh.c[j][i]
+ && fldCAtt[j+actiSh.y][i+actiSh.x].a)
return 1; // Collision happens
}
}
@@ -433,55 +348,43 @@ int cellRotCollisionCheck()
int wallRotCollisionCheck()
{
- if(actiShPos.y < 0) { //If shape has crossed Bottom border
- for(int i=0;i<4;i++) {
- if (activeShape[-1-actiShPos.y][i].a != 0){ // If active cell is out of fld
+ if(actiSh.y < 0) //If shape has crossed Bottom border
+ for(int i = 0; i < 4; i++)
+ if (actiSh.c[-1-actiSh.y][i])
return 1; // Collision happens
- }
- }
- }
- if(actiShPos.x < 0) { //If shape has crossed Left border
- for(int i=0;i<4;i++) {
- if (activeShape[i][-1-actiShPos.x].a != 0){ // If active cell is out of fld
+ if(actiSh.x < 0) //If shape has crossed Left border
+ for(int i = 0; i < 4; i++)
+ if (actiSh.c[i][-1-actiSh.x])
return 1; // Collision happens
- }
- }
- }
- if(actiShPos.x > 6) { //If shape has crossed Right border
- for(int i=0;i<4;i++) {
- if (activeShape[i][3-(actiShPos.x-7)].a != 0){ // If active cell is out of fld
+ if(actiSh.x > 6) //If shape has crossed Right border
+ for(int i = 0; i < 4; i++)
+ if (actiSh.c[i][3-(actiSh.x-7)])
return 1; // Collision happens
- }
- }
- }
return 0; // If no conditions are met collision is absent
}
int cellCollisionCheck(int dir)
{
- for (int j=0;j<4;j++) {
- for (int i=0;i<4;i++) {
- if((dir & 0b0001) != 0){ // Check Right
- if ((j+actiShPos.y >= 0) && (i+actiShPos.x+1 >= 0)) { // Avoiding checking nonexisted fld cells
- if ((activeShape[j][i].a == 1) && // If any active cell of shape meet any active cell
- (fld_rAttr[j+actiShPos.y][i+actiShPos.x+1].a == 1)) // of fld
- return 1; // Collision happens
- }
- }
- if((dir & 0b1000) != 0){ // Check Left
- if ((j+actiShPos.y >= 0) && (i+actiShPos.x-1 >= 0)) { // Avoiding checking nonexisted fld cells
- if ((activeShape[j][i].a == 1) && // If any active cell of shape meet any active cell
- (fld_rAttr[j+actiShPos.y][i+actiShPos.x-1].a == 1)) // of fld
- return 1; // Collision happens
- }
- }
- if((dir & 0b0010) != 0){ // Check Bottom
- if ((j+actiShPos.y-1 >= 0) && (i+actiShPos.x >= 0)) { // Avoiding checking nonexisted fld cells
- if ((activeShape[j][i].a == 1) && // If any active cell of shape meet any active cell
- (fld_rAttr[j+actiShPos.y-1][i+actiShPos.x].a == 1)) // of fld
- return 1; // Collision happens
- }
- }
+ for (int j = 0; j < 4; j++) {
+ for (int i = 0; i < 4; i++) {
+ if ((dir & 0b0001) // Check Right
+ && (j+actiSh.y >= 0) // Avoiding nonexisting fld cells
+ && (i+actiSh.x+1 >= 0) // ---
+ && actiSh.c[j][i] // Check activity
+ && fldCAtt[j+actiSh.y][i+actiSh.x+1].a)
+ return 1; // Collision happens
+ if ((dir & 0b1000) // Check Left
+ && (j+actiSh.y >= 0) // Avoiding nonexisting fld cells
+ && (i+actiSh.x-1 >= 0) // ---
+ && actiSh.c[j][i] // Check activity
+ && fldCAtt[j+actiSh.y][i+actiSh.x-1].a)
+ return 1; // Collision happens
+ if ((dir & 0b0010) // Check Bottom
+ && (j+actiSh.y-1 >= 0) // Avoiding nonexisting fld cells
+ && (i+actiSh.x >= 0) // ---
+ && actiSh.c[j][i] // Check activity
+ && fldCAtt[j+actiSh.y-1][i+actiSh.x].a)
+ return 1; // Collision happens
}
}
return 0; // Else it do not
@@ -489,164 +392,223 @@ int cellCollisionCheck(int dir)
int wallCollisionCheck(int dir)
{
- if((dir & 0b0001) != 0) { // Right collision request
- if(actiShPos.x >= 6) { // If shape has reached Right boreder
- for(int i=0;i<4;i++) {
- if(activeShape[i][3-(actiShPos.x-6)].a != 0) {
+ if (dir & 0b0001) { // Right collision request
+ if (actiSh.x >= 6) // If shape has reached Right boreder
+ for (int i = 0 ; i < 4; i++)
+ if (actiSh.c[i][3-(actiSh.x-6)])
+ return 1; // Collision happens
+ } else if (dir & 0b0010) { // Bottom collision request
+ if (actiSh.y <= 0) //If shape has reached Bottom border
+ for (int i = 0; i < 4; i++)
+ if (actiSh.c[-actiSh.y][i])
+ return 1; // Collision happens
+ } else if (dir & 0b1000) // Left collision request
+ if (actiSh.x <= 0) // If shape has reached Left border
+ for (int i = 0; i < 4; i++)
+ if (actiSh.c[i][-actiSh.x])
return 1; // Collision happens
- }
- }
- }
- } else if((dir & 0b0010) != 0){ // Bottom collision request
- if(actiShPos.y <= 0) { //If shape has reached Bottom border
- for(int i=0;i<4;i++) {
- if (activeShape[-actiShPos.y][i].a != 0){
- return 1; // Collision happens
- }
- }
- }
- } else if((dir & 0b1000) != 0){ // Left collision request
- if(actiShPos.x <= 0) { // If shape has reached Left border
- for(int i=0;i<4;i++) {
- if(activeShape[i][-actiShPos.x].a != 0) {
- return 1; // Collision happens
- }
- }
- }
- } else {
- return -1;
- }
return 0;
}
-/* Control keys handle */
+/*
+ * Keys hold handler
+ *
+ */
void tKeyCtrl()
{
-
- /* Up arrow key */
- if (sfKeyboard_isKeyPressed(sfKeyUp) == 1){
- if ((arrKeys & 0b0100) == 0){ // If "Up arrow button hold" bit is not enabled
- arrKeys = arrKeys | 0b0100; // Enable the "Up arrow button hold" bit
+ /* Up arrow key 'hold' handler */
+ if (sfKeyboard_isKeyPressed(sfKeyUp) == 1) {
+ if ((arrKeys & 0b0100) == 0) {
+ arrKeys = arrKeys | 0b0100;
rotateShape();
}
- } else { // If Down arrow button not pressed
- if ((arrKeys & 0b0100) != 0){ // and if "Up arrow button hold" bit is enabled
- arrKeys = arrKeys & ~0b0100; // it means that button is already released
- } // So it is time to clear "Up arrow button hold" bit
+ } else {
+ if ((arrKeys & 0b0100) != 0) {
+ arrKeys = arrKeys & ~0b0100;
+ }
}
- /* Down Arrow Key */
- if (sfKeyboard_isKeyPressed(sfKeyDown) == 1){ // If Down arrow button is pressed
- if ((arrKeys & 0b0010) == 0){ // If "pushed down" key of Down arrow button not enabled
- arrKeys = arrKeys | 0b0010; // Enable "pushed down" key of down arrow button
- if ((wallCollisionCheck(0b0010) == 0) && // If collision do not happen
- (cellCollisionCheck(0b0010) == 0)) { // 0b0010 for "Down"
- actiShPos.y--; // then do move
- sfClock_restart(gameTick); // Avoid excess move down by gameTick
+ /* Down Arrow Key 'hold' handler */
+ if (sfKeyboard_isKeyPressed(sfKeyDown) == 1) {
+ if ((arrKeys & 0b0010) == 0) {
+ arrKeys = arrKeys | 0b0010;
+ if ((wallCollisionCheck(0b0010) == 0)
+ && (cellCollisionCheck(0b0010) == 0)) {
+ actiSh.y--;
+ // Avoid excess move down by gameTick
+ sfClock_restart(gameTick);
scoreCurrent++;
}
- repPushDown = sfClock_create(); // Create/restart clock
+ repPushDown = sfClock_create();
} else {
- if (sfClock_getElapsedTime(repPushDown).microseconds >= moveRepeatLatency2) arrKeys = arrKeys & ~0b0010;
+ if (sfClock_getElapsedTime(repPushDown).microseconds
+ >= moveRepeatLatency2)
+ arrKeys = arrKeys & ~0b0010;
}
- } else { // If Down arrow button not pressed
- if ((arrKeys & 0b0010) != 0){ // and if "pushed down" key is enabled
- arrKeys = arrKeys & ~0b0010; // it means that button is already released
+ } else {
+ if ((arrKeys & 0b0010) != 0) {
+ arrKeys = arrKeys & ~0b0010;
arrKeys = arrKeys & ~0b100000;
- } // So it is time to clear "down arrow pushed down" bit
+ }
}
- /* Left Arrow Key */
- if ((sfKeyboard_isKeyPressed(sfKeyLeft) == 1) && (sfKeyboard_isKeyPressed(sfKeyRight) == 0)){ // If left arrow button is pressed
- if ((arrKeys & 0b1000) == 0){ // If "pushed down" key of left arrow button disabled
- arrKeys = arrKeys | 0b1000; // Enable "pushed down" key of left arrow button
- if ((wallCollisionCheck(0b1000) == 0) && // If collision do not happen
- (cellCollisionCheck(0b1000) == 0)) // 0b1000 for "left"
- actiShPos.x--; // then do move
- repPushLeft = sfClock_create(); // Create/restart clock
- } else { // Push held action repeat handler
- if ((arrKeys & 0b10000000) == 0) { // If "push Left repeat" bit is not set
- if (sfClock_getElapsedTime(repPushLeft).microseconds >= moveRepeatLatency1) { // Wait long time
- arrKeys = arrKeys | 0b10000000; // set "push Left repeat" bit
- arrKeys = arrKeys & ~0b1000; // unset "pushed down" bit to repeat move
+ /* Left Arrow Key 'hold' handler */
+ if ((sfKeyboard_isKeyPressed(sfKeyLeft) == 1)
+ && (sfKeyboard_isKeyPressed(sfKeyRight) == 0)) {
+ if ((arrKeys & 0b1000) == 0){
+ arrKeys = arrKeys | 0b1000;
+ if ((wallCollisionCheck(0b1000) == 0)
+ && (cellCollisionCheck(0b1000) == 0))
+ actiSh.x--;
+ repKeyLeft = sfClock_create();
+ } else {
+ if ((arrKeys & 0b10000000) == 0) {
+ if (sfClock_getElapsedTime(repKeyLeft).microseconds
+ >= moveRepeatLatency1) {
+ arrKeys = arrKeys | 0b10000000;
+ arrKeys = arrKeys & ~0b1000;
}
- } else { // If "push Left repeat" bit is set
- if (sfClock_getElapsedTime(repPushLeft).microseconds >= moveRepeatLatency2) // Wait short time
- arrKeys = arrKeys & ~0b1000; // unset "pushed down" bit to repeat movse
+ } else {
+ if (sfClock_getElapsedTime(repKeyLeft).microseconds
+ >= moveRepeatLatency2)
+ arrKeys = arrKeys & ~0b1000;
}
}
- } else if (sfKeyboard_isKeyPressed(sfKeyLeft) == 0) { // If left arrow button is released
- if ((arrKeys & 0b1000) != 0){ // and if "pushed down" key is enabled
- arrKeys = arrKeys & ~0b1000; // it means that button is already released
- arrKeys = arrKeys & ~0b10000000;// So it is time to clear "right arrow pushed down" bit
- } // And "push repeat" bit
+ } else if (sfKeyboard_isKeyPressed(sfKeyLeft) == 0) {
+ if ((arrKeys & 0b1000) != 0){
+ arrKeys = arrKeys & ~0b1000;
+ arrKeys = arrKeys & ~0b10000000;
+ }
}
- /* Right Arrow Key */
- if ((sfKeyboard_isKeyPressed(sfKeyRight) == 1) && (sfKeyboard_isKeyPressed(sfKeyLeft) == 0)) { // If right arrow button is pressed
- if ((arrKeys & 0b0001) == 0){ // If "pushed down" key of right arrow button not enabled
- arrKeys = arrKeys | 0b0001; // Enable "pushed down" key of right arrow button
- if ((wallCollisionCheck(0b0001) == 0) && // If collision do not happen
- (cellCollisionCheck(0b0001) == 0)) // 0b0001 for "right"
- actiShPos.x++; // then do move
- repPushRight = sfClock_create();
- } else { // Push held action repeat handler
- if ((arrKeys & 0b10000) == 0) { // If "push Right repeat" bit is not set
- if (sfClock_getElapsedTime(repPushRight).microseconds >= moveRepeatLatency1) { // Wait long time
- arrKeys = arrKeys | 0b10000; // set "push Right repeat" bit
- arrKeys = arrKeys & ~0b0001; // unset "pushed down" bit to repeat move
+ /* Right Arrow Key 'hold' handler */
+ if ((sfKeyboard_isKeyPressed(sfKeyRight) == 1)
+ && (sfKeyboard_isKeyPressed(sfKeyLeft) == 0)) {
+ if ((arrKeys & 0b0001) == 0){
+ arrKeys = arrKeys | 0b0001;
+ if ((wallCollisionCheck(0b0001) == 0)
+ && (cellCollisionCheck(0b0001) == 0))
+ actiSh.x++;
+ repKeyRight = sfClock_create();
+ } else {
+ if ((arrKeys & 0b10000) == 0) {
+ if (sfClock_getElapsedTime(repKeyRight).microseconds
+ >= moveRepeatLatency1) {
+ arrKeys = arrKeys | 0b10000;
+ arrKeys = arrKeys & ~0b0001;
}
- } else if (sfKeyboard_isKeyPressed(sfKeyLeft) == 0) { // If "push Right repeat" bit is set
- if (sfClock_getElapsedTime(repPushRight).microseconds >= moveRepeatLatency2) // Wait short time
- arrKeys = arrKeys & ~0b0001; // unset "pushed down" bit to repeat movse
+ } else if (sfKeyboard_isKeyPressed(sfKeyLeft) == 0) {
+ if (sfClock_getElapsedTime(repKeyRight).microseconds
+ >= moveRepeatLatency2) // Wait short time
+ arrKeys = arrKeys & ~0b0001;
}
}
- } else { // If Right arrow button not pressed
- if ((arrKeys & 0b0001) != 0){ // and if "pushed down" key is enabled
- arrKeys = arrKeys & ~0b0001; // <---+ it means that button is already released
- arrKeys = arrKeys & ~0b10000; // <-+ +--So it is time to clear "right arrow pushed down" bit
- } // +-And "push repeat" bit
+ } else {
+ if ((arrKeys & 0b0001) != 0) {
+ arrKeys = arrKeys & ~0b0001;
+ arrKeys = arrKeys & ~0b10000;
+ }
}
}
+/*
+ * Colorize active cells of field
+ *
+ */
+void colorizeFld()
+{
+ for(int j = 0; j < 20; j++) {
+ for(int i = 0; i < 10; i++) {
+ if (fldCAtt[j][i].a) {
+ sfRectangleShape_setFillColor(
+ fld[j][i],
+ fldCAtt[j][i].fColor);
+ sfRectangleShape_setOutlineColor(
+ fld[j][i],
+ uiColor3);
+ } else {
+ sfRectangleShape_setFillColor(
+ fld[j][i],
+ uiColor1);
+ sfRectangleShape_setOutlineColor(
+ fld[j][i],
+ uiColor2);
+ }
+ }
+ }
+}
+
+
+/*
+ * Colorize active cells of active shape (overlay only
+ * active cells above background of fld)
+ *
+ */
+void colorizeActiSh()
+{
+ for(int j = 0; j < 4; j++) {
+ for(int i = 0; i < 4; i++) {
+ if (actiSh.c[j][i]) {
+ sfRectangleShape_setFillColor(
+ fld[j+actiSh.y][i+actiSh.x],
+ actiSh.fColor);
+ sfRectangleShape_setOutlineColor(
+ fld[j+actiSh.y][i+actiSh.x],
+ uiColor3);
+ }
+ }
+ }
+}
+
void menuTick()
{
if(sfClock_getElapsedTime(mTick).microseconds >= lvlLatency){
sfClock_restart(mTick);
- for (int j=0;j<fldSize.y;j++){
- for(int i=0;i<fldSize.x;i++){
- int a;
- a = rand()%7+1;
- switch (a) {;
- case 1 :
- fld_rAttr[j][i].fColor = tOrange;
- break;
- case 2 :
- fld_rAttr[j][i].fColor = tBlue;
- break;
- case 3 :
- fld_rAttr[j][i].fColor = tRed;
- break;
- case 4 :
- fld_rAttr[j][i].fColor = tGreen;
- break;
- case 5 :
- fld_rAttr[j][i].fColor = tYellow;
- break;
- case 6 :
- fld_rAttr[j][i].fColor = tCyan;
- break;
- case 7 :
- fld_rAttr[j][i].fColor = tMagneta;
- break;
- }
- fld_rAttr[j][i].oColor = sfBlack;
- sfRectangleShape_setFillColor(fld[j][i], fld_rAttr[j][i].fColor); // FillColor
- sfRectangleShape_setOutlineColor(fld[j][i], fld_rAttr[j][i].oColor); // Outline color
+ colorizeRandom();
+ }
+}
+
+
+void colorizeRandom()
+{
+ for (int j = 0; j < fldSize.y; j++) {
+ for (int i = 0; i < fldSize.x; i++) {
+ int a;
+ a = rand()%7+1;
+ switch (a) {;
+ case 1 :
+ sfRectangleShape_setFillColor(fld[j][i],
+ tOrange);
+ break;
+ case 2 :
+ sfRectangleShape_setFillColor(fld[j][i],
+ tBlue);
+ break;
+ case 3 :
+ sfRectangleShape_setFillColor(fld[j][i],
+ tRed);
+ break;
+ case 4 :
+ sfRectangleShape_setFillColor(fld[j][i],
+ tGreen);
+ break;
+ case 5 :
+ sfRectangleShape_setFillColor(fld[j][i],
+ tYellow);
+ break;
+ case 6 :
+ sfRectangleShape_setFillColor(fld[j][i],
+ tCyan);
+ break;
+ case 7 :
+ sfRectangleShape_setFillColor(fld[j][i],
+ tMagneta);
+ break;
}
+ sfRectangleShape_setOutlineColor(fld[j][i], uiColor3);
}
}
}
diff --git a/src/include/common.h b/src/include/common.h
index e7624c7..c606560 100644
--- a/src/include/common.h
+++ b/src/include/common.h
@@ -6,20 +6,40 @@
#include <SFML/System.h>
#include <SFML/Window/Keyboard.h>
#include <stdio.h>
-#include <time.h>
#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <time.h>
#include "functions.h"
#include "tet_conf.h"
-//#define EXIT_FAILURE -1
-//#define EXIT_SUCCESS 0
-
struct tCell {
- short a; // active/empty state of cell
- sfColor fColor, oColor; // fill and outline color of cell
+ uint8_t a; // active/empty state of cell
+ sfColor fColor; // fill color
+};
+struct tCell fldCAtt[20][10];// fld cells attributes
+
+
+/*
+ * shape coords
+ * y
+ * ^. . . .
+ * |. . . .
+ * |. . . .
+ * |. . . .
+ * 0------->x
+ *
+ */
+
+struct activeShape {
+ int x; // x coord of shape's left side
+ int y; // y coord of shape's bottom
+ int r; // rotate state, one of four
+ int t; // shape type
+ sfColor fColor; // shape color
+ uint8_t c[4][4]; // array of shape cells
};
-struct tCell activeShape[4][4]; // 4x4 block of active crawling shape
-struct tCell fld_rAttr[20][10];// fld cells attributes
+struct activeShape actiSh;
#endif
diff --git a/src/include/functions.h b/src/include/functions.h
index 3c54dfd..cb5bf09 100644
--- a/src/include/functions.h
+++ b/src/include/functions.h
@@ -11,13 +11,14 @@ int cellCollisionCheck(int dir);
int wallCollisionCheck();
int cellRotCollisionCheck();
int wallRotCollisionCheck();
+void rotateLeft();
+void rotateRight();
void rotateShape();
-void rotateS1();
-void rotateS2();
-void rotateS3();
-void rotateS4();
int linesRmScore();
void scoreDisplay();
+void colorizeFld();
+void colorizeActiSh();
void menuTick();
+void colorizeRandom();
#endif
diff --git a/src/include/tet_conf.h b/src/include/tet_conf.h
index f2f1871..9f632c4 100644
--- a/src/include/tet_conf.h
+++ b/src/include/tet_conf.h
@@ -1,6 +1,7 @@
#define windowName_conf "SFML" // Window name
#define uiColor1 sfColor_fromRGB(0, 0, 0) // Field background
-#define uiColor2 sfColor_fromRGB(80, 80, 80) // Field cell outline
+#define uiColor2 sfColor_fromRGB(80, 80, 80) // Field inactive cell outline
+#define uiColor3 sfColor_fromRGB(0, 0, 0) // Field active cell outline
#define tOrange sfColor_fromRGB(255, 130, 0) // Orange color of L shape
#define tBlue sfColor_fromRGB(0, 0, 255)
#define tGreen sfColor_fromRGB(0, 255, 0)
diff --git a/src/main.c b/src/main.c
index b0dadf9..b453b5b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,5 @@
#include "include/common.h"
+#include "include/functions.h"
/* --- Variables --- */
int gameIsStarted = 0;
@@ -6,20 +7,19 @@ sfVideoMode mode = {450, 520, 32};
sfRenderWindow* window;
sfEvent event;
sfText* textScore;
-sfFont* font;
+sfFont* font;
char *scoreDisp;
sfRectangleShape* fld[20][10];// Array of fld rectangles
-sfVector2f fld_rPos[20][10]; // Array of absolute coordinates of fld
+sfVector2f fldCPos[20][10]; // Array of absolute coordinates of fld
// rectangles
-int fld_rOutThick = 1; // Field rectangles outline thickness
-sfVector2f fld_rSize; // Field rectangles size variable x/y
-sfVector2i actiShPos; // Offset active shape relative to fld
+int fldCOutThick = 1; // Field rectangles outline thickness
+sfVector2f fldCSize; // Field rectangles size variable x/y
sfVector2i fldSize, fldPos;
sfVector2f textScore_pos;
-short arrKeys = 0b00000000; // Arrow keys states byte container
+uint8_t arrKeys = 0b00000000; // Arrow keys states byte container
int lvlLatency = 500000;
int scoreCurrent = 0;
@@ -39,6 +39,9 @@ int main()
if (!window)
return EXIT_FAILURE;
+ /* colorize field once at start */
+ colorizeRandom();
+
/* Start the game loop */
while (sfRenderWindow_isOpen(window))
{
@@ -56,50 +59,15 @@ int main()
tTick();
tKeyCtrl();
scoreDisplay(scoreCurrent, textScore);
-
- /* Colorize active cells of fld */
- for(int j=0;j<20;j++){
- for(int i=0;i<10;i++){
- sfRectangleShape_setFillColor(
- fld[j][i],
- fld_rAttr[j][i].fColor);
- sfRectangleShape_setOutlineColor(
- fld[j][i],
- fld_rAttr[j][i].oColor);
- }
- }
-
-
- /*
- * Colorize active cells of active shape (overlay only
- * active cells above background of fld)
- *
- */
- for(int j=0;j<4;j++){
- for(int i=0;i<4;i++){
- if (activeShape[j][i].a != 0){
- sfRectangleShape_setFillColor(
- fld[j
- +actiShPos.y]
- [i+actiShPos.x],
- activeShape[j][i].fColor
- );
- sfRectangleShape_setOutlineColor(
- fld[j
- +actiShPos.y]
- [i+actiShPos.x],
- activeShape[j][i].oColor
- );
- }
- }
- }
+ colorizeFld();
+ colorizeActiSh();
/*
* Draw all fld cells
*
*/
- for (int j=0;j<fldSize.y;j++){
- for(int i=0;i<fldSize.x;i++){
+ for (int j = 0; j < fldSize.y; j++){
+ for(int i = 0; i < fldSize.x; i++){
sfRenderWindow_drawRectangleShape(
window,
fld[j][i],
@@ -109,21 +77,20 @@ int main()
sfRenderWindow_drawText(window, textScore, NULL);
} else {
menuTick();
- if (sfKeyboard_isKeyPressed(sfKeyReturn) == 1) {
- gameIsStarted = 1;
- initAll();
- }
- menuTick();
/* Draw all fld cells */
- for (int j=0;j<fldSize.y;j++){
- for(int i=0;i<fldSize.x;i++){
+ for (int j=0; j < fldSize.y; j++){
+ for(int i = 0; i < fldSize.x; i++){
sfRenderWindow_drawRectangleShape(
window,
fld[j][i],
NULL);
}
}
+ if (sfKeyboard_isKeyPressed(sfKeyS) == 1) {
+ gameIsStarted = 1;
+ initAll();
+ }
}
/* Update the window */
sfRenderWindow_display(window);
diff --git a/src/shape_maps.c b/src/shape_maps.c
index e96ea8f..c89420d 100644
--- a/src/shape_maps.c
+++ b/src/shape_maps.c
@@ -1,4 +1,10 @@
-/* Shapes maps */
+#include "include/common.h"
+/*
+ * Shapes maps
+ *
+ * Arrays are mirrored upside-down
+ *
+ */
/*
* L #1 tYellow
@@ -7,29 +13,11 @@
* .... .##. #... .#..
* .... .... .... ....
*/
-short arrShapeL_a1[4][4] = {
+uint8_t arrShapeL_a1[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 1, 0},
{0, 0, 1, 0}};
-
-short arrShapeL_a2[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 1, 0},
- {0, 1, 0, 0},
- {0, 1, 0, 0}};
-
-short arrShapeL_a3[4][4] = {
- {0, 0, 0, 0},
- {1, 0, 0, 0},
- {1, 1, 1, 0},
- {0, 0, 0, 0}};
-
-short arrShapeL_a4[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 0, 0},
- {1, 1, 0, 0}};
/*
* RL #2 tBlue
@@ -39,29 +27,11 @@ short arrShapeL_a4[4][4] = {
* .... .... .... ....
*/
-short arrShapeRL_a1[4][4] = {
+uint8_t arrShapeRL_a1[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 1, 0},
{1, 0, 0, 0}};
-
-short arrShapeRL_a2[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 1, 0}};
-
-short arrShapeRL_a3[4][4] = {
- {0, 0, 0, 0},
- {0, 0, 1, 0},
- {1, 1, 1, 0},
- {0, 0, 0, 0}};
-
-short arrShapeRL_a4[4][4] = {
- {0, 0, 0, 0},
- {1, 1, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 0, 0}};
/*
* Z #3
@@ -70,29 +40,11 @@ short arrShapeRL_a4[4][4] = {
* .... .#.. .##. #...
* .... .... .... ....
*/
-short arrShapeZ_a1[4][4] = {
+uint8_t arrShapeZ_a1[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 1, 1, 0},
{1, 1, 0, 0}};
-
-short arrShapeZ_a2[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 1, 0},
- {0, 0, 1, 0}};
-
-short arrShapeZ_a3[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 1, 0},
- {1, 1, 0, 0},
- {0, 0, 0, 0}};
-
-short arrShapeZ_a4[4][4] = {
- {0, 0, 0, 0},
- {1, 0, 0, 0},
- {1, 1, 0, 0},
- {0, 1, 0, 0}};
/*
* S #4
@@ -101,60 +53,26 @@ short arrShapeZ_a4[4][4] = {
* .... ..#. ##.. .#..
* .... .... .... ....
*/
-short arrShapeS_a1[4][4] = {
+uint8_t arrShapeS_a1[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 0, 0},
{0, 1, 1, 0}};
-short arrShapeS_a2[4][4] = {
- {0, 0, 0, 0},
- {0, 0, 1, 0},
- {0, 1, 1, 0},
- {0, 1, 0, 0}};
-
-short arrShapeS_a3[4][4] = {
- {0, 0, 0, 0},
- {1, 1, 0, 0},
- {0, 1, 1, 0},
- {0, 0, 0, 0}};
-
-short arrShapeS_a4[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 0, 0},
- {1, 1, 0, 0},
- {1, 0, 0, 0}};
/*
* B #5
- * ##.. ##.. ##.. ##..
- * ##.. ##.. ##.. ##..
+ * .##. .##. .##. .##.
+ * .##. .##. .##. .##.
* .... .... .... ....
* .... .... .... ....
*/
-short arrShapeB_a1[4][4] = {
+uint8_t arrShapeB_a1[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 1, 1, 0},
{0, 1, 1, 0}};
-short arrShapeB_a2[4][4] = {
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 1, 1, 0},
- {0, 1, 1, 0}};
-
-short arrShapeB_a3[4][4] = {
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 1, 1, 0},
- {0, 1, 1, 0}};
-
-short arrShapeB_a4[4][4] = {
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 1, 1, 0},
- {0, 1, 1, 0}};
/*
* I #6
@@ -163,29 +81,12 @@ short arrShapeB_a4[4][4] = {
* .#.. .... .#.. ....
* .#.. .... .#.. ....
*/
-short arrShapeI_a1[4][4] = {
+uint8_t arrShapeI_a1[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 1, 1},
{0, 0, 0, 0}};
-short arrShapeI_a2[4][4] = {
- {0, 1, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 0, 0}};
-
-short arrShapeI_a3[4][4] = {
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {1, 1, 1, 1},
- {0, 0, 0, 0}};
-
-short arrShapeI_a4[4][4] = {
- {0, 1, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 0, 0}};
/*
* T #7
@@ -194,26 +95,9 @@ short arrShapeI_a4[4][4] = {
* .... .#.. .#.. .#..
* .... .... .... ....
*/
-short arrShapeT_a1[4][4] = {
+uint8_t arrShapeT_a1[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 1, 0},
{0, 1, 0, 0}};
-short arrShapeT_a2[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 0, 0},
- {0, 1, 1, 0},
- {0, 1, 0, 0}};
-
-short arrShapeT_a3[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 0, 0},
- {1, 1, 1, 0},
- {0, 0, 0, 0}};
-
-short arrShapeT_a4[4][4] = {
- {0, 0, 0, 0},
- {0, 1, 0, 0},
- {1, 1, 0, 0},
- {0, 1, 0, 0}}; \ No newline at end of file