From 80ff7b315a6b5a9f9c62de5c6b03f52ddf099837 Mon Sep 17 00:00:00 2001 From: Oxore Date: Thu, 6 Dec 2018 05:24:30 +0300 Subject: Add simple documentation in comments, refactor. Change all `unsigned int` and `unsigned long` types to `size_t`. Fix names alignment in headers. Add documentation and simple description: Painter - painter.h Main - tetris.c Unicode - unicode.h IDList - idlist.h Engine - engine.c Minor changes: tetris.c - fix indentation and code blocks separation with newlines, remove unused includes. idlist.h - fix structure field name alignment. field.h, engine.c - define aliases for ghost and active shapes indexes in the field. engine.c - rename menuTick to snake case, fix curly braces style of functions. Makefile - switch SFML deprecated warnings off. --- src/target/tetris.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/target/tetris.c') diff --git a/src/target/tetris.c b/src/target/tetris.c index 2419c8d..eab3c7d 100644 --- a/src/target/tetris.c +++ b/src/target/tetris.c @@ -1,10 +1,13 @@ +/* + * tetris.c + * + * The main file. Here all the resources are initialized, run and destroyed. + * + * */ + #include -#include #include -#include -#include #include -#include #include #include "common.h" @@ -17,10 +20,9 @@ #include "tet_conf.h" sfRenderWindow *window; -struct idlist *texts; - -struct field fld, nxt; -struct game game = { +struct idlist *texts; +struct field fld, nxt; +struct game game = { .started = 0, .paused = 0, .scoreCurrent = 0, @@ -51,10 +53,12 @@ int main() game.repPushDown = sfClock_create(); game.repKeyLeft = sfClock_create(); game.repKeyRight = sfClock_create(); + painter_load_font("dat/arial.ttf"); sfVideoMode mode = (sfVideoMode){450, 570, 32}; - window = sfRenderWindow_create(mode, windowName_conf, sfResize | sfClose, NULL); + window = sfRenderWindow_create(mode, windowName_conf, sfResize | sfClose, + NULL); if (!window) exit(EXIT_FAILURE); sfRenderWindow_setFramerateLimit(window, 60); @@ -84,7 +88,6 @@ int main() painter_update_field(nxt.id, &nxt); texts = load_texts("dat/texts.yaml"); - list_foreach(texts, register_text); transition_init(); @@ -105,11 +108,13 @@ int main() window = 0; } painter_destroy_font(); + sfClock_destroy(game.gameTick); sfClock_destroy(game.putTick); sfClock_destroy(game.mTick); sfClock_destroy(game.repPushDown); sfClock_destroy(game.repKeyLeft); sfClock_destroy(game.repKeyRight); + return EXIT_SUCCESS; } -- cgit v1.2.3