diff options
author | Oxore <oxore@protonmail.com> | 2017-06-07 07:38:52 +0700 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2017-06-07 07:38:52 +0700 |
commit | 6016191f7f9c470cbb4c791d0e35670d04c3487d (patch) | |
tree | 746be15d8f635139a89a8fe285770933df4fd0e6 /src | |
parent | 982152f3bade5e91e8971e55bab1c305ac02eba2 (diff) |
minor refactor
Diffstat (limited to 'src')
-rw-r--r-- | src/functions.c | 2 | ||||
-rw-r--r-- | src/main.c | 53 |
2 files changed, 28 insertions, 27 deletions
diff --git a/src/functions.c b/src/functions.c index a0a72e4..c3bdbb9 100644 --- a/src/functions.c +++ b/src/functions.c @@ -113,7 +113,7 @@ void initAll() { } font = sfFont_createFromFile("dat/arial.ttf"); if (!font) { - //printf("dat/arial.ttf font load failed"); + printf("dat/arial.ttf font load failed"); exit(-1); } textScore_pos.x = 250+10+10; @@ -31,27 +31,27 @@ int main() /* Create main window */ window = sfRenderWindow_create(mode, windowName_conf, sfResize | sfClose, NULL); - if (!window) - return EXIT_FAILURE; + if (!window) + return EXIT_FAILURE; /* Start the game loop */ - while (sfRenderWindow_isOpen(window)) - { - /* Process events */ - while (sfRenderWindow_pollEvent(window, &event)) - { - /* Close window : exit */ - if (event.type == sfEvtClosed) - sfRenderWindow_close(window); - } - /* Clear the screen */ - sfRenderWindow_clear(window, sfBlack); - + while (sfRenderWindow_isOpen(window)) + { + /* Process events */ + while (sfRenderWindow_pollEvent(window, &event)) + { + /* Close window : exit */ + if (event.type == sfEvtClosed) + sfRenderWindow_close(window); + } + /* Clear the screen */ + sfRenderWindow_clear(window, sfBlack); + if (gameIsStarted == 1) { tTick(); tKeyCtrl(); scoreDisplay(); - + /* Colorize active cells of field */ for(int j=0;j<20;j++){ for(int i=0;i<10;i++){ @@ -77,8 +77,9 @@ int main() sfRenderWindow_drawRectangleShape(window, field[j][i], NULL); } } - sfRenderWindow_drawText(window, textScore, NULL); - } else { + sfRenderWindow_drawText(window, textScore, NULL); + } + else { menuTick(); if (sfKeyboard_isKeyPressed(sfKeyReturn) == 1) { gameIsStarted = 1; @@ -86,7 +87,7 @@ int main() } menuTick(); - /* Draw all field cells */ + /* 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); @@ -94,20 +95,20 @@ int main() } } /* Update the window */ - sfRenderWindow_display(window); - } - + sfRenderWindow_display(window); + } + /* Just senseless printf */ printf("%d\n", scoreCurrent); - - /* Cleanup resources */ + + /* Cleanup resources */ for (int j=0;j<fieldSize.y;j++){ for(int i=0;i<fieldSize.x;i++){ sfRectangleShape_destroy(field[j][i]); } } - - sfRenderWindow_destroy(window); - + + sfRenderWindow_destroy(window); + return EXIT_SUCCESS; } |