diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/functions.c | 295 | ||||
-rw-r--r-- | src/include/common.h | 4 | ||||
-rw-r--r-- | src/include/tet_conf.h | 10 | ||||
-rw-r--r-- | src/main.c | 85 |
4 files changed, 236 insertions, 158 deletions
diff --git a/src/functions.c b/src/functions.c index c3bdbb9..997bbc4 100644 --- a/src/functions.c +++ b/src/functions.c @@ -9,17 +9,17 @@ extern sfText* textScore; extern sfFont* font; extern int gameIsStarted; -extern sfRectangleShape* field[20][10]; // Array of field rectangles -extern sfVector2f field_rPos[20][10]; // Array of absolute coordinates of field rectangles +extern sfRectangleShape* fld[20][10]; // Array of field rectangles +extern sfVector2f fld_rPos[20][10]; // Array of absolute coordinates of field rectangles -extern int field_rOutThick; // Field rectangles outline thickness -extern sfVector2f field_rSize; // Field rectangles size variable x/y +extern int fld_rOutThick; // Field rectangles outline thickness +extern sfVector2f fld_rSize; // Field rectangles size variable x/y -extern sfVector2i offsetActiveShape; // Offset active shape relative to field +extern sfVector2i actiShPos; // Active shape offset relative to field -extern sfVector2i fieldSize, fieldPos; -extern sfVector2i offsetActiveShape; // Offset active shape relative to field -extern short arrKeys; // arrow keys states byte container +extern sfVector2i fldSize, fldPos; +extern sfVector2i actiShPos; // Offset active shape relative to field +extern short 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 @@ -77,18 +77,24 @@ extern short arrShapeT_a3[4][4]; extern short arrShapeT_a4[4][4]; -/* Miscellaneous functions */ +/* + * Init routine. Performs once per program run + * + */ void initAll() { - /* --- Initialization --- */ - - field_rSize.x = 23; // Dimensions of every field block - field_rSize.y = 23; // 19px - fill color 1px - for outline, 20 - at all + /* + * Dimensions of every fld's block + * 19px - fill color 1px - for outline, 20 - at all + * + */ + fld_rSize.x = 23; + fld_rSize.y = 23; - fieldPos.x = 10; // Field bottom left corner coordinates - fieldPos.y = 10+500-25; - fieldSize.x = 10; // Field size in blocks - fieldSize.y = 20; + fldPos.x = 10; // Field's bottom left corner coordinates + fldPos.y = 10+500-25; + fldSize.x = 10; // Field size in blocks + fldSize.y = 20; srand( time(NULL) ); gameTick = sfClock_create(); @@ -96,99 +102,130 @@ void initAll() { resetActiveShape(); /* Create field */ - for (int j=0;j<fieldSize.y;j++){ - for(int i=0;i<fieldSize.x;i++){ - field_rAttr[j][i].fColor = hudColor1_conf; // Fill empty color - field_rAttr[j][i].oColor = hudColor2_conf; // Outlie empty color - field_rAttr[j][i].a = 0; // Inactive = empty - field_rPos[j][i].x = fieldPos.x + (i * (field_rSize.x + 2 * field_rOutThick)); // Coordinates of every - field_rPos[j][i].y = fieldPos.y - (j * (field_rSize.y + 2 * field_rOutThick)); // rectangle - field[j][i] = sfRectangleShape_create(); // Creating - sfRectangleShape_setFillColor(field[j][i], field_rAttr[j][i].fColor); // FillColor - sfRectangleShape_setSize(field[j][i], field_rSize); // Size - sfRectangleShape_setPosition(field[j][i], field_rPos[j][i]); // Position - sfRectangleShape_setOutlineColor(field[j][i], field_rAttr[j][i].oColor); // Outline color - sfRectangleShape_setOutlineThickness(field[j][i], field_rOutThick); // Outline thickness + 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)); + 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_setOutlineColor(fld[j][i], + fld_rAttr[j][i].oColor); + sfRectangleShape_setOutlineThickness(fld[j][i], + fld_rOutThick); } } font = sfFont_createFromFile("dat/arial.ttf"); - if (!font) { + if (!font) { printf("dat/arial.ttf font load failed"); exit(-1); } textScore_pos.x = 250+10+10; textScore_pos.y = 485; textScore = sfText_create(); - sfText_setFont(textScore, font); - sfText_setCharacterSize(textScore, 20); + sfText_setFont(textScore, font); + sfText_setCharacterSize(textScore, 20); sfText_setPosition(textScore, textScore_pos); } -void scoreDisplay() { +/* + * Refreshes score + * + */ +void scoreDisplay(int score, sfText *textScore) +{ char a[64]; char b[8]; sprintf(b, "Score: "); - sprintf(a, "%d", scoreCurrent); - for (int i=63;i>=7;i--) { + sprintf(a, "%d", score); + for (int i = 63; i >= 7; i--) a[i] = a[i-7]; - } - for (int i=0;i<7;i++) { + for (int i = 0; i < 7; i++) a[i] = b[i]; - } - scoreDisp = (char *)&a; - sfText_setString(textScore, scoreDisp); + sfText_setString(textScore, (char *)&a); } -int linesRmScore() { - int k = 0; // "Filled line" indicator +/* + * Removes line when cells all are in row in it + * + */ +int linesRmScore() +{ + int k = 0; // "Filled line" indicator int s = 0; - for (int j=0;j<20;j++) { // Passing all lines - for (int i=0;i<10;i++) { // Passing all elements of current line - if (field_rAttr[j][i].a == 1) k++; // Check all the elements of current line + for (int j = 0; j < 20; j++) { + for (int i = 0; i < 10; i++) { + if (fld_rAttr[j][i].a == 1) + k++; } if (k >= 10) { // If line is full s++; // Take scores for line - for (int n=j;n<20;n++) { // Drop all lines down + for (int n = j; n < 20; n++) { // Drop all lines down if (n == 19) { - for (int m=0;m<10;m++) { - field_rAttr[n][m].a = 0; // Top line clear - field_rAttr[n][m].fColor = hudColor1_conf; - field_rAttr[n][m].oColor = hudColor2_conf; + 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++) { - field_rAttr[n][m].a = field_rAttr[n+1][m].a; //Drop every line down - field_rAttr[n][m].fColor = field_rAttr[n+1][m].fColor; - field_rAttr[n][m].oColor = field_rAttr[n+1][m].oColor; + 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; } } } - j--; // Do not let loop to go to next line because next line go down itself =) + j--; // Do not let loop to go to next line because + // next line go down by itself =) } - k = 0; // Clear line fill indicator + k = 0; // Clear line fill indicator } return s; // Return number of deleted lines } -void putShape() { - for (int j=0;j<4;j++) { - for (int i=0;i<4;i++) { +void putShape() +{ + for (int j = 0; j < 4; j++) { + for (int i = 0; i < 4; i++) { if (activeShape[j][i].a == 1) { - field_rAttr[j+offsetActiveShape.y][i+offsetActiveShape.x].a = activeShape[j][i].a; - if ((j+offsetActiveShape.y >= 0) && (i+offsetActiveShape.x >= 0)) { - field_rAttr[j+offsetActiveShape.y][i+offsetActiveShape.x].fColor = activeShape[j][i].fColor; - field_rAttr[j+offsetActiveShape.y][i+offsetActiveShape.x].oColor = activeShape[j][i].oColor; + 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; } } } } resetActiveShape(); - scoreCurrent += linesRmScore()*100; // Remove filled lines and get score; + scoreCurrent += linesRmScore()*100; // Remove filled lines and + // get score; } -void resetActiveShape() { - offsetActiveShape.x = 3; - offsetActiveShape.y = 16; +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++) { @@ -228,19 +265,25 @@ void resetActiveShape() { } } -void tTick() { - if (sfClock_getElapsedTime(gameTick).microseconds >= lvlLatency){ // If tick exceeds current level tick latency - sfClock_restart(gameTick); // Restart gameTick +/* + * Game tick + * + * */ +void tTick() +{ // If tick exceeds current level tick latency + if (sfClock_getElapsedTime(gameTick).microseconds >= lvlLatency) { + sfClock_restart(gameTick); // Restart gameTick + /* if bottom not reached */ if ((wallCollisionCheck(0b0010) == 0) && - (cellCollisionCheck(0b0010) == 0)) { // If bottom not reached - offsetActiveShape.y--; // Move - } else { // If bottom reached - putShape(); // Just put the shape - } + (cellCollisionCheck(0b0010) == 0)) + actiShPos.y--; // Move + else + putShape(); // Just put the shape } } -void rotateS1() { +void rotateS1() +{ for (int j=0;j<4;j++) { for (int i=0;i<4;i++) { switch (activeShape_t) { @@ -265,7 +308,8 @@ void rotateS1() { } } -void rotateS2() { +void rotateS2() +{ for (int j=0;j<4;j++) { for (int i=0;i<4;i++) { switch (activeShape_t) { @@ -290,7 +334,8 @@ void rotateS2() { } } -void rotateS3() { +void rotateS3() +{ for (int j=0;j<4;j++) { for (int i=0;i<4;i++) { switch (activeShape_t) { @@ -315,7 +360,8 @@ void rotateS3() { } } -void rotateS4() { +void rotateS4() +{ for (int j=0;j<4;j++) { for (int i=0;i<4;i++) { switch (activeShape_t) { @@ -340,7 +386,8 @@ void rotateS4() { } } -void rotateShape() { +void rotateShape() +{ switch (activeShape_s) { case 1 : rotateS2(); // Make rotate @@ -372,35 +419,37 @@ void rotateShape() { } } -int cellRotCollisionCheck() { +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 - (field_rAttr[j+offsetActiveShape.y][i+offsetActiveShape.x].a == 1)) // of field + (fld_rAttr[j+actiShPos.y][i+actiShPos.x].a == 1)) // of fld return 1; // Collision happens } } return 0; // Else it do not } -int wallRotCollisionCheck() { - if(offsetActiveShape.y < 0) { //If shape has crossed Bottom border +int wallRotCollisionCheck() +{ + if(actiShPos.y < 0) { //If shape has crossed Bottom border for(int i=0;i<4;i++) { - if (activeShape[-1-offsetActiveShape.y][i].a != 0){ // If active cell is out of field + if (activeShape[-1-actiShPos.y][i].a != 0){ // If active cell is out of fld return 1; // Collision happens } } } - if(offsetActiveShape.x < 0) { //If shape has crossed Left border + if(actiShPos.x < 0) { //If shape has crossed Left border for(int i=0;i<4;i++) { - if (activeShape[i][-1-offsetActiveShape.x].a != 0){ // If active cell is out of field + if (activeShape[i][-1-actiShPos.x].a != 0){ // If active cell is out of fld return 1; // Collision happens } } } - if(offsetActiveShape.x > 6) { //If shape has crossed Right border + if(actiShPos.x > 6) { //If shape has crossed Right border for(int i=0;i<4;i++) { - if (activeShape[i][3-(offsetActiveShape.x-7)].a != 0){ // If active cell is out of field + if (activeShape[i][3-(actiShPos.x-7)].a != 0){ // If active cell is out of fld return 1; // Collision happens } } @@ -408,27 +457,28 @@ int wallRotCollisionCheck() { return 0; // If no conditions are met collision is absent } -int cellCollisionCheck(int dir) { +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+offsetActiveShape.y >= 0) && (i+offsetActiveShape.x+1 >= 0)) { // Avoiding checking nonexisted field cells + 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 - (field_rAttr[j+offsetActiveShape.y][i+offsetActiveShape.x+1].a == 1)) // of field + (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+offsetActiveShape.y >= 0) && (i+offsetActiveShape.x-1 >= 0)) { // Avoiding checking nonexisted field cells + 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 - (field_rAttr[j+offsetActiveShape.y][i+offsetActiveShape.x-1].a == 1)) // of field + (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+offsetActiveShape.y-1 >= 0) && (i+offsetActiveShape.x >= 0)) { // Avoiding checking nonexisted field cells + 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 - (field_rAttr[j+offsetActiveShape.y-1][i+offsetActiveShape.x].a == 1)) // of field + (fld_rAttr[j+actiShPos.y-1][i+actiShPos.x].a == 1)) // of fld return 1; // Collision happens } } @@ -437,27 +487,28 @@ int cellCollisionCheck(int dir) { return 0; // Else it do not } -int wallCollisionCheck(int dir) { +int wallCollisionCheck(int dir) +{ if((dir & 0b0001) != 0) { // Right collision request - if(offsetActiveShape.x >= 6) { // If shape has reached Right boreder + if(actiShPos.x >= 6) { // If shape has reached Right boreder for(int i=0;i<4;i++) { - if(activeShape[i][3-(offsetActiveShape.x-6)].a != 0) { + if(activeShape[i][3-(actiShPos.x-6)].a != 0) { return 1; // Collision happens } } } } else if((dir & 0b0010) != 0){ // Bottom collision request - if(offsetActiveShape.y <= 0) { //If shape has reached Bottom border + if(actiShPos.y <= 0) { //If shape has reached Bottom border for(int i=0;i<4;i++) { - if (activeShape[-offsetActiveShape.y][i].a != 0){ + if (activeShape[-actiShPos.y][i].a != 0){ return 1; // Collision happens } } } } else if((dir & 0b1000) != 0){ // Left collision request - if(offsetActiveShape.x <= 0) { // If shape has reached Left border + if(actiShPos.x <= 0) { // If shape has reached Left border for(int i=0;i<4;i++) { - if(activeShape[i][-offsetActiveShape.x].a != 0) { + if(activeShape[i][-actiShPos.x].a != 0) { return 1; // Collision happens } } @@ -470,7 +521,8 @@ int wallCollisionCheck(int dir) { /* Control keys handle */ -void tKeyCtrl() { +void tKeyCtrl() +{ /* Up arrow key */ if (sfKeyboard_isKeyPressed(sfKeyUp) == 1){ @@ -490,7 +542,7 @@ void tKeyCtrl() { 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" - offsetActiveShape.y--; // then do move + actiShPos.y--; // then do move sfClock_restart(gameTick); // Avoid excess move down by gameTick scoreCurrent++; } @@ -511,7 +563,7 @@ void tKeyCtrl() { 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" - offsetActiveShape.x--; // then do move + 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 @@ -537,7 +589,7 @@ void tKeyCtrl() { 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" - offsetActiveShape.x++; // then do move + 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 @@ -560,39 +612,40 @@ void tKeyCtrl() { -void menuTick() { +void menuTick() +{ if(sfClock_getElapsedTime(mTick).microseconds >= lvlLatency){ sfClock_restart(mTick); - for (int j=0;j<fieldSize.y;j++){ - for(int i=0;i<fieldSize.x;i++){ + 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 : - field_rAttr[j][i].fColor = tOrange; + fld_rAttr[j][i].fColor = tOrange; break; case 2 : - field_rAttr[j][i].fColor = tBlue; + fld_rAttr[j][i].fColor = tBlue; break; case 3 : - field_rAttr[j][i].fColor = tRed; + fld_rAttr[j][i].fColor = tRed; break; case 4 : - field_rAttr[j][i].fColor = tGreen; + fld_rAttr[j][i].fColor = tGreen; break; case 5 : - field_rAttr[j][i].fColor = tYellow; + fld_rAttr[j][i].fColor = tYellow; break; case 6 : - field_rAttr[j][i].fColor = tCyan; + fld_rAttr[j][i].fColor = tCyan; break; case 7 : - field_rAttr[j][i].fColor = tMagneta; + fld_rAttr[j][i].fColor = tMagneta; break; } - field_rAttr[j][i].oColor = sfBlack; - sfRectangleShape_setFillColor(field[j][i], field_rAttr[j][i].fColor); // FillColor - sfRectangleShape_setOutlineColor(field[j][i], field_rAttr[j][i].oColor); // Outline color + 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 } } } diff --git a/src/include/common.h b/src/include/common.h index bef85f2..e7624c7 100644 --- a/src/include/common.h +++ b/src/include/common.h @@ -19,7 +19,7 @@ struct tCell { sfColor fColor, oColor; // fill and outline color of cell }; -struct tCell activeShape[4][4], // 4x4 block of active crawling shape - field_rAttr[20][10];// field cells attributess +struct tCell activeShape[4][4]; // 4x4 block of active crawling shape +struct tCell fld_rAttr[20][10];// fld cells attributes #endif diff --git a/src/include/tet_conf.h b/src/include/tet_conf.h index 0b37d65..f2f1871 100644 --- a/src/include/tet_conf.h +++ b/src/include/tet_conf.h @@ -1,6 +1,6 @@ #define windowName_conf "SFML" // Window name -#define hudColor1_conf sfColor_fromRGB(0, 0, 0) // Field background -#define hudColor2_conf sfColor_fromRGB(80, 80, 80) // Field cell outline +#define uiColor1 sfColor_fromRGB(0, 0, 0) // Field background +#define uiColor2 sfColor_fromRGB(80, 80, 80) // Field 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) @@ -78,9 +78,3 @@ * .... .... .... .... */ - - - -char *aaa; -char* aaa; - @@ -9,13 +9,14 @@ sfText* textScore; sfFont* font; char *scoreDisp; -sfRectangleShape* field[20][10]; // Array of field rectangles -sfVector2f field_rPos[20][10]; // Array of absolute coordinates of field rectangles +sfRectangleShape* fld[20][10];// Array of fld rectangles +sfVector2f fld_rPos[20][10]; // Array of absolute coordinates of fld + // rectangles -int field_rOutThick = 1; // Field rectangles outline thickness -sfVector2f field_rSize; // Field rectangles size variable x/y -sfVector2i offsetActiveShape; // Offset active shape relative to field -sfVector2i fieldSize, fieldPos; +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 +sfVector2i fldSize, fldPos; sfVector2f textScore_pos; short arrKeys = 0b00000000; // Arrow keys states byte container @@ -30,7 +31,11 @@ int main() initAll(); /* Create main window */ - window = sfRenderWindow_create(mode, windowName_conf, sfResize | sfClose, NULL); + window = sfRenderWindow_create(mode, + windowName_conf, + sfResize | sfClose, + NULL + ); if (!window) return EXIT_FAILURE; @@ -50,36 +55,59 @@ int main() if (gameIsStarted == 1) { tTick(); tKeyCtrl(); - scoreDisplay(); + scoreDisplay(scoreCurrent, textScore); - /* Colorize active cells of field */ + /* Colorize active cells of fld */ for(int j=0;j<20;j++){ for(int i=0;i<10;i++){ - sfRectangleShape_setFillColor(field[j][i], field_rAttr[j][i].fColor); - sfRectangleShape_setOutlineColor(field[j][i], field_rAttr[j][i].oColor); + 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 field) */ + /* + * 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(field[j+offsetActiveShape.y][i+offsetActiveShape.x], activeShape[j][i].fColor); - sfRectangleShape_setOutlineColor(field[j+offsetActiveShape.y][i+offsetActiveShape.x], activeShape[j][i].oColor); + 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 + ); } } } - /* Draw all field cells */ - for (int j=0;j<fieldSize.y;j++){ - for(int i=0;i<fieldSize.x;i++){ - sfRenderWindow_drawRectangleShape(window, field[j][i], NULL); + /* + * Draw all fld cells + * + */ + for (int j=0;j<fldSize.y;j++){ + for(int i=0;i<fldSize.x;i++){ + sfRenderWindow_drawRectangleShape( + window, + fld[j][i], + NULL); } } sfRenderWindow_drawText(window, textScore, NULL); - } - else { + } else { menuTick(); if (sfKeyboard_isKeyPressed(sfKeyReturn) == 1) { gameIsStarted = 1; @@ -87,10 +115,13 @@ int main() } menuTick(); - /* Draw all field cells */ - for (int j=0;j<fieldSize.y;j++){ - for(int i=0;i<fieldSize.x;i++){ - sfRenderWindow_drawRectangleShape(window, field[j][i], NULL); + /* Draw all fld cells */ + for (int j=0;j<fldSize.y;j++){ + for(int i=0;i<fldSize.x;i++){ + sfRenderWindow_drawRectangleShape( + window, + fld[j][i], + NULL); } } } @@ -102,9 +133,9 @@ int main() printf("%d\n", scoreCurrent); /* Cleanup resources */ - for (int j=0;j<fieldSize.y;j++){ - for(int i=0;i<fieldSize.x;i++){ - sfRectangleShape_destroy(field[j][i]); + for (int j=0;j<fldSize.y;j++){ + for(int i=0;i<fldSize.x;i++){ + sfRectangleShape_destroy(fld[j][i]); } } |