diff options
author | Oxore <oxore@protonmail.com> | 2018-06-25 15:50:58 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2018-06-25 15:50:58 +0300 |
commit | bf0e5690a31d4c3cecd2ba512729a0b73989bbda (patch) | |
tree | 5b95c5a52c8a9025593231ee0285d81d40890f0f /include/common.h | |
parent | 63e929f7a23b44ff2b1e33ccf16307de20c2bdc8 (diff) |
Major refactoring
Fix memleak in KeyMap, fix memleak caused by loading a yaml file in
main.c. Change Copyright information. Rename functions.c and .h to
engine.c and .h. Take field and shape related functions to separate file
(still not all of them) and refactor them a lot. Refactor collision
detection. Add more warnings. Add sanitizer option commented out.
Diffstat (limited to 'include/common.h')
-rw-r--r-- | include/common.h | 77 |
1 files changed, 4 insertions, 73 deletions
diff --git a/include/common.h b/include/common.h index 773cb3f..275547a 100644 --- a/include/common.h +++ b/include/common.h @@ -1,82 +1,13 @@ -/* - * Types - * - * */ - -typedef struct Cell { - char a; // active/empty state of cell - sfColor fColor; // fill color -} Cell; - - -/* - * shape coords - * y - * ^. . . . - * |. . . . - * |. . . . - * |. . . . - * 0------->x - * - */ - -typedef struct Shape { - int x; // x coord of shape's left side - int y; // y coord of shape's bottom - int t; // shape type - sfColor fColor; // shape color - char c[4][4]; // array of logic shape cells - sfRectangleShape *p[4][4]; // array of physical shape cells - sfVector2f cSize; // shape rectangles size variable x/y -} Shape; - -typedef struct Field { - sfVector2i pos; - sfColor fColor; // shape color - Cell c[25][10]; // array of logic shape cells - sfRectangleShape *p[25][10]; // array of physical shape cells - int cOutThick; // Field rectangles outline thickness - sfVector2f cSize; // shape rectangles size variable x/y - sfVector2i size; -} Field; - -typedef struct Window { +struct window { sfVideoMode mode; sfRenderWindow *window; sfEvent event; -} Window; +}; -typedef struct Game { +struct game { int isStarted; int scoreCurrent; int level; int moveLatency; int lines; -} Game; - -/* ======== text.[c|h] types =========== */ - -typedef struct List { - void *obj; - void *next; - void *prev; -} List; - -typedef struct Pair { - void *k; - void *v; -} Pair; - -typedef struct KeyMap { - Pair *pair; - void *next; - void *prev; -} KeyMap; - -typedef struct Text { - char *font; - char *type; - char *scene; - char *text; - void *sfText; -} Text; +}; |