summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-04-10 17:16:27 -0400
committerAndrew Opalach <andrew@akon.city> 2019-04-10 17:16:27 -0400
commit64bd072a1ef349fedc1364a221a19ce71c368e72 (patch)
treeeceb68dcf0a54ba3ec676a3f9cc72378b37001d9 /core/include
parent60699af63f92f43cc4b4b9e3050fcdd2a8468281 (diff)
downloadcetris-64bd072a1ef349fedc1364a221a19ce71c368e72.tar.gz
cetris-64bd072a1ef349fedc1364a221a19ce71c368e72.tar.bz2
cetris-64bd072a1ef349fedc1364a221a19ce71c368e72.zip
add shorthand int types and cleanup
Diffstat (limited to 'core/include')
-rw-r--r--core/include/cetris.h37
-rw-r--r--core/include/input.h3
-rw-r--r--core/include/matrix.h4
-rw-r--r--core/include/types.h15
4 files changed, 35 insertions, 24 deletions
diff --git a/core/include/cetris.h b/core/include/cetris.h
index 8264842..e51b8c4 100644
--- a/core/include/cetris.h
+++ b/core/include/cetris.h
@@ -1,6 +1,7 @@
#pragma once
#include <stdint.h>
+#include <stdbool.h>
#include "types.h"
@@ -43,13 +44,13 @@ struct tetrimino {
color c;
piece_matrix m;
vec2 pos;
- int lock_tick;
+ u32 lock_tick;
};
typedef struct {
- uint8_t occupied;
- uint8_t constant;
- int remove_tick;
+ bool occupied;
+ bool constant;
+ u32 remove_tick;
color c;
} slot;
@@ -62,30 +63,30 @@ struct cetris_game {
/* current tetrimino */
struct tetrimino current;
- uint8_t current_index;
+ u8 current_index;
/* input_manager */
- uint8_t held_moves[7];
- int das_repeat;
+ bool held_moves[7];
input_t prev_das_move;
- int das_move_tick;
- int down_move_tick;
+ u8 das_repeat;
+ u32 das_move_tick;
+ u32 down_move_tick;
/* internal game tick */
- int tick;
- int next_drop_tick;
+ u32 tick;
+ u32 next_drop_tick;
/* progress trackers */
- int lines;
- uint8_t level;
- uint8_t game_over;
+ u32 lines;
+ u32 level;
+ bool game_over;
/* scoring flags */
- uint8_t tspin;
- uint8_t mini_tspin;
+ bool tspin;
+ bool mini_tspin;
- /* long int just incase */
- long int score;
+ /* score counter */
+ u64 score;
};
void next_piece(struct cetris_game* g);
diff --git a/core/include/input.h b/core/include/input.h
index 0092bb4..1199991 100644
--- a/core/include/input.h
+++ b/core/include/input.h
@@ -1,8 +1,9 @@
#pragma once
#include <stdint.h>
+#include <stdbool.h>
struct cetris_game;
-uint8_t handle_inputs(struct cetris_game* g);
+bool handle_inputs(struct cetris_game* g);
void clear_held_key(struct cetris_game* g);
diff --git a/core/include/matrix.h b/core/include/matrix.h
index 3ab0252..5b6a74c 100644
--- a/core/include/matrix.h
+++ b/core/include/matrix.h
@@ -11,5 +11,5 @@ extern const vec2 basic_movements[4];
void move_current(struct cetris_game* g, vec2 offset);
void overlay_current_matrix(struct cetris_game* g);
void hard_drop(struct cetris_game* g);
-void rotate_matrix(struct cetris_game* g, int clockwise);
-int8_t check_new_matrix(struct cetris_game* g, piece_matrix m);
+void rotate_matrix(struct cetris_game* g, bool clockwise);
+i8 check_new_matrix(struct cetris_game* g, piece_matrix m);
diff --git a/core/include/types.h b/core/include/types.h
index 2ce97c7..a20773b 100644
--- a/core/include/types.h
+++ b/core/include/types.h
@@ -2,13 +2,22 @@
#include <stdint.h>
-typedef uint8_t piece_matrix[4][4];
+#define u8 uint8_t
+#define u16 uint16_t
+#define u32 uint32_t
+#define u64 uint64_t
+#define i8 int8_t
+#define i16 int16_t
+#define i32 int32_t
+#define i64 int64_t
typedef struct {
- int8_t x;
- int8_t y;
+ i8 x;
+ i8 y;
} vec2;
+typedef u8 piece_matrix[4][4];
+
typedef enum {
DOWN = 1,
RIGHT = 2,