summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/common.h23
-rw-r--r--include/functions.h6
-rw-r--r--include/text.h3
-rw-r--r--src/functions.c47
-rw-r--r--src/main.c12
-rw-r--r--src/shape_maps.c15
-rw-r--r--src/text.c9
7 files changed, 58 insertions, 57 deletions
diff --git a/include/common.h b/include/common.h
index 136edaa..4452bf0 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1,19 +1,10 @@
-#ifndef TCOMMON_H
-#define TCOMMON_H
-
-#include <SFML/Audio.h>
-#include <SFML/Graphics.h>
-#include <SFML/System.h>
-#include <SFML/Window/Keyboard.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <time.h>
-#include "tet_conf.h"
+/*
+ * Types
+ *
+ * */
typedef struct Cell {
- uint8_t a; // active/empty state of cell
+ char a; // active/empty state of cell
sfColor fColor; // fill color
} Cell;
@@ -34,7 +25,7 @@ typedef struct Shape {
int y; // y coord of shape's bottom
int t; // shape type
sfColor fColor; // shape color
- uint8_t c[4][4]; // array of logic shape cells
+ 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;
@@ -87,5 +78,3 @@ typedef struct Text {
char *text;
void *sfText;
} Text;
-
-#endif
diff --git a/include/functions.h b/include/functions.h
index 8658aa5..73979e5 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -1,7 +1,3 @@
-#ifndef TFUNCTIONS_H
-#define TFUNCTIONS_H
-
-/* Prototypes of functions*/
void tKeyCtrl();
void initFld();
void tTick();
@@ -26,5 +22,3 @@ void genNextShape();
void copyShape(Shape *localSh);
void drawNextShape();
void freeFld();
-
-#endif
diff --git a/include/text.h b/include/text.h
index 7948c51..1171a51 100644
--- a/include/text.h
+++ b/include/text.h
@@ -1,6 +1,3 @@
-#include <SFML/Graphics.h>
-#include "common.h"
-
FILE *openFile(char *filename);
void checkArgs(int argc, char **argv);
KeyMap *KeyMap_getLast(KeyMap **keyMap);
diff --git a/src/functions.c b/src/functions.c
index 7637289..a573266 100644
--- a/src/functions.c
+++ b/src/functions.c
@@ -1,4 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <SFML/System/Clock.h>
+#include <SFML/Graphics/RenderWindow.h>
+#include <SFML/Graphics/Text.h>
+#include <SFML/Graphics/RectangleShape.h>
+
#include "common.h"
+#include "tet_conf.h"
#include "functions.h"
/* Externs from main.c */
@@ -8,7 +17,7 @@ extern Field fld;
extern sfFont *fontScore;
-extern uint8_t arrKeys; // Arrow keys states byte container
+extern char arrKeys; // Arrow keys states byte container
/* arrKeys = ...n|7|6|5|4|3|2|1|0| (just a bit of so called "bit fucking")
* 0 - Right arrow pushed and held
* 1 - Down arrow pushed and held
@@ -28,13 +37,13 @@ extern sfClock *repKeyLeft; // Clock for repeat latency when Left arrow long pus
extern sfClock *repKeyRight; // Clock for repeat latency when Left arrow long push
/* Shapes maps */
-extern uint8_t arrShapeL[4][4];
-extern uint8_t arrShapeRL[4][4];
-extern uint8_t arrShapeZ[4][4];
-extern uint8_t arrShapeS[4][4];
-extern uint8_t arrShapeB[4][4];
-extern uint8_t arrShapeI[4][4];
-extern uint8_t arrShapeT[4][4];
+extern char arrShapeL[4][4];
+extern char arrShapeRL[4][4];
+extern char arrShapeZ[4][4];
+extern char arrShapeS[4][4];
+extern char arrShapeB[4][4];
+extern char arrShapeI[4][4];
+extern char arrShapeT[4][4];
/* Field init routine */
@@ -209,8 +218,8 @@ void tTick()
*/
void rotateLeft()
{
- uint8_t arr[4][4];
- memcpy(&arr[0][0], &active.c[0][0], sizeof(uint8_t)*4*4);
+ char arr[4][4];
+ memcpy(&arr[0][0], &active.c[0][0], sizeof(char)*4*4);
if (active.t == 5)
return;
if (active.t == 6) {
@@ -231,8 +240,8 @@ void rotateLeft()
*/
void rotateRight()
{
- uint8_t arr[4][4];
- memcpy(&arr[0][0], &active.c[0][0], sizeof(uint8_t)*4*4);
+ char arr[4][4];
+ memcpy(&arr[0][0], &active.c[0][0], sizeof(char)*4*4);
if (active.t == 5)
return;
if (active.t == 6) {
@@ -553,31 +562,31 @@ void copyShape(Shape *localSh)
{
switch (localSh->t) { // Copy cell active/inactive state
case 1 :
- memcpy(&localSh->c[0][0], &arrShapeL[0][0], sizeof(uint8_t)*4*4);
+ memcpy(&localSh->c[0][0], &arrShapeL[0][0], sizeof(char)*4*4);
localSh->fColor = tOrange;
break;
case 2 :
- memcpy(&localSh->c[0][0], &arrShapeRL[0][0], sizeof(uint8_t)*4*4);
+ memcpy(&localSh->c[0][0], &arrShapeRL[0][0], sizeof(char)*4*4);
localSh->fColor = tBlue;
break;
case 3 :
- memcpy(&localSh->c[0][0], &arrShapeZ[0][0], sizeof(uint8_t)*4*4);
+ memcpy(&localSh->c[0][0], &arrShapeZ[0][0], sizeof(char)*4*4);
localSh->fColor = tRed;
break;
case 4 :
- memcpy(&localSh->c[0][0], &arrShapeS[0][0], sizeof(uint8_t)*4*4);
+ memcpy(&localSh->c[0][0], &arrShapeS[0][0], sizeof(char)*4*4);
localSh->fColor = tGreen;
break;
case 5 :
- memcpy(&localSh->c[0][0], &arrShapeB[0][0], sizeof(uint8_t)*4*4);
+ memcpy(&localSh->c[0][0], &arrShapeB[0][0], sizeof(char)*4*4);
localSh->fColor = tYellow;
break;
case 6 :
- memcpy(&localSh->c[0][0], &arrShapeI[0][0], sizeof(uint8_t)*4*4);
+ memcpy(&localSh->c[0][0], &arrShapeI[0][0], sizeof(char)*4*4);
localSh->fColor = tCyan;
break;
case 7 :
- memcpy(&localSh->c[0][0], &arrShapeT[0][0], sizeof(uint8_t)*4*4);
+ memcpy(&localSh->c[0][0], &arrShapeT[0][0], sizeof(char)*4*4);
localSh->fColor = tMagneta;
break;
}
diff --git a/src/main.c b/src/main.c
index c429ca9..0677e11 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <SFML/System/Clock.h>
+#include <SFML/Window/Keyboard.h>
+#include <SFML/Graphics/RenderWindow.h>
+#include <SFML/Graphics/Font.h>
+
#include "common.h"
#include "functions.h"
#include "text.h"
+#include "tet_conf.h"
/* --- Variables --- */
Window w = {.mode = {450, 520, 32}};
@@ -10,7 +20,7 @@ sfFont *fontScore;
Shape active, next;
Field fld;
-uint8_t arrKeys = 0b00000000; // Arrow keys states byte container
+char arrKeys = 0b00000000; // Arrow keys states byte container
/* --- Variables End --- */
sfClock *gameTick;
diff --git a/src/shape_maps.c b/src/shape_maps.c
index 9de04d2..50061e3 100644
--- a/src/shape_maps.c
+++ b/src/shape_maps.c
@@ -1,4 +1,3 @@
-#include "common.h"
/*
* Shapes maps
*
@@ -13,7 +12,7 @@
* .... .##. #... .#..
* .... .... .... ....
*/
-uint8_t arrShapeL[4][4] = {
+char arrShapeL[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 1, 0},
@@ -27,7 +26,7 @@ uint8_t arrShapeL[4][4] = {
* .... .... .... ....
*/
-uint8_t arrShapeRL[4][4] = {
+char arrShapeRL[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 1, 0},
@@ -40,7 +39,7 @@ uint8_t arrShapeRL[4][4] = {
* .... .#.. .##. #...
* .... .... .... ....
*/
-uint8_t arrShapeZ[4][4] = {
+char arrShapeZ[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 1, 1, 0},
@@ -53,7 +52,7 @@ uint8_t arrShapeZ[4][4] = {
* .... ..#. ##.. .#..
* .... .... .... ....
*/
-uint8_t arrShapeS[4][4] = {
+char arrShapeS[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 0, 0},
@@ -67,7 +66,7 @@ uint8_t arrShapeS[4][4] = {
* .... .... .... ....
* .... .... .... ....
*/
-uint8_t arrShapeB[4][4] = {
+char arrShapeB[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 1, 1, 0},
@@ -81,7 +80,7 @@ uint8_t arrShapeB[4][4] = {
* .#.. .... .#.. ....
* .#.. .... .#.. ....
*/
-uint8_t arrShapeI[4][4] = {
+char arrShapeI[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 1, 1},
@@ -95,7 +94,7 @@ uint8_t arrShapeI[4][4] = {
* .... .#.. .#.. .#..
* .... .... .... ....
*/
-uint8_t arrShapeT[4][4] = {
+char arrShapeT[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{1, 1, 1, 0},
diff --git a/src/text.c b/src/text.c
index 8932496..20b9797 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1,9 +1,12 @@
-#include <yaml.h>
-#include <SFML/Graphics.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdio.h>
+#include <SFML/Graphics/Font.h>
+#include <SFML/Graphics/Text.h>
+#include <SFML/Graphics.h>
+#include <yaml.h>
+#include "common.h"
#include "text.h"
extern sfFont *fontScore;