diff options
author | Oxore <oxore@protonmail.com> | 2017-12-01 05:28:10 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2017-12-01 05:28:10 +0300 |
commit | e949a49287b38574c7372c9a6c1c759eafa3266c (patch) | |
tree | 206266cae6a0cf9703d3b09110f0165ff29200b3 /include | |
parent | 027a94b74a2ff36eddbffc1cce4dcdc14126c813 (diff) |
Wrap global variables into structures
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 37 | ||||
-rw-r--r-- | include/functions.h | 4 | ||||
-rw-r--r-- | include/tet_conf.h | 2 |
3 files changed, 33 insertions, 10 deletions
diff --git a/include/common.h b/include/common.h index 5a3d63e..37ede42 100644 --- a/include/common.h +++ b/include/common.h @@ -12,11 +12,10 @@ #include <time.h> #include "tet_conf.h" -typedef struct tCell { +typedef struct Cell { uint8_t a; // active/empty state of cell sfColor fColor; // fill color -} tCell; -tCell fldCAtt[25][10];// fld cells attributes +} Cell; /* @@ -30,13 +29,37 @@ tCell fldCAtt[25][10];// fld cells attributes * */ -typedef struct shapeSt { +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 - uint8_t c[4][4]; // array of shape cells -} shapeSt; -shapeSt actiSh, nxtShape; + uint8_t 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; +Shape active, next; + +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 { + sfVideoMode mode; + sfRenderWindow *window; + sfEvent event; +} Window; + +typedef struct Text { + sfFont *font; + sfText *text; + sfVector2f pos; +} Text; #endif diff --git a/include/functions.h b/include/functions.h index ef9d42f..8f7618e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -15,7 +15,7 @@ void rotateLeft(); void rotateRight(); void rotateShape(); int linesRmScore(); -void scoreDisplay(); +void scoreDisplay(int s, Text *textScore); void colorizeFld(); void colorizeActiSh(); void drawFld(sfRenderWindow *window); @@ -23,7 +23,7 @@ void menuTick(); void colorizeRandom(); void gameover(); void genNextShape(); -void copyShape(struct shapeSt *localSh); +void copyShape(Shape *localSh); void drawNextShape(); void cleanupFld(); diff --git a/include/tet_conf.h b/include/tet_conf.h index 4896a56..50b17ff 100644 --- a/include/tet_conf.h +++ b/include/tet_conf.h @@ -1,4 +1,4 @@ -#define windowName_conf "SFML" // Window name +#define windowName_conf "Tetris CSFML" // Window name #define uiColor1 sfColor_fromRGB(0, 0, 0) // Field background #define uiColor2 sfColor_fromRGB(80, 80, 80) // Field inactive cell outline #define uiColor3 sfColor_fromRGB(0, 0, 0) // Field active cell outline |