diff options
author | Oxore <oxore@protonmail.com> | 2018-12-06 05:24:30 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2018-12-06 07:59:07 +0300 |
commit | 80ff7b315a6b5a9f9c62de5c6b03f52ddf099837 (patch) | |
tree | b8b982e702ac5a64db40116e39fd453e998b3dbd /src/target | |
parent | 80325e9dfaece1316fa5cdc2b0551280369c4f7d (diff) |
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.
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/tetris.c | 25 |
1 files changed, 15 insertions, 10 deletions
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 <SFML/System/Clock.h> -#include <SFML/Window/Keyboard.h> #include <SFML/Graphics/RenderWindow.h> -#include <SFML/Graphics/Font.h> -#include <stdio.h> #include <stdlib.h> -#include <string.h> #include <time.h> #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; } |