From 73ec96ee907f0a8ebdeec20f2058de705b00d65d Mon Sep 17 00:00:00 2001 From: Oxore Date: Mon, 9 Jul 2018 01:06:04 +0300 Subject: Finish painter, refactor game logic & keys handling Add dependencies in Makefile: now it tracks headers too! Introduce texts in painter. Delegate all the window painting to the painter. Refactor texts from yaml parsing. Remove overcomplicated keymaps and lists of keymaps of... Whatever! Just let em go! Simple idlist with foreach is more than enough. Make displayable values be separate text objects which consists only of a number value that rendered every tick and then displayed. Refactor game logic: make state machine look much obvious with transition functions. Refactor long if-else and switch-case statement chains: replace them with arrays of values (it actually takes more lines of code :P) Refactor keys handling: shorten and separate shape moving code to functions. --- include/text.h | 50 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) (limited to 'include/text.h') diff --git a/include/text.h b/include/text.h index 73285bf..c1de778 100644 --- a/include/text.h +++ b/include/text.h @@ -1,39 +1,15 @@ -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; +#define TXT_ATTR_INVISIBLE (1 << 0) + +typedef struct text { + char *type; + char *scene; + char *font; + char *text; + unsigned int size; + struct vector2ui pos; + unsigned int attr; + unsigned long id; } Text; -FILE *openFile(char *filename); -void checkArgs(int argc, char **argv); -KeyMap *KeyMap_getLast(KeyMap **keyMap); -KeyMap *KeyMap_new(KeyMap **keyMap); -KeyMap *KeyMap_get(KeyMap **keyMap, const void *key); -KeyMap *KeyMap_put(KeyMap **keyMap, const void *key, const void *value); -List *List_getLast(List **list); -List *List_new(List **list); -List *ListOfKeyMapOfString_getFromYaml(char *filename); -void KeyMapOfString_free(KeyMap *keyMap); -void ListOfKeyMapOfString_free(List **list); -List *ListOfText_getFromListOfKeyMapOfString(List *list); -void Text_free(Text *obj); -void ListOfText_free(List **list); +struct idlist *load_texts(char *filename); +void text_destroy(void *text); -- cgit v1.2.3