diff options
Diffstat (limited to 'core/include')
| -rw-r--r-- | core/include/cetris.h | 35 | ||||
| -rw-r--r-- | core/include/input.h | 6 | ||||
| -rw-r--r-- | core/include/matrix.h | 10 | ||||
| -rw-r--r-- | core/include/test.h | 8 |
4 files changed, 32 insertions, 27 deletions
diff --git a/core/include/cetris.h b/core/include/cetris.h index 9e3cf83..1606f2a 100644 --- a/core/include/cetris.h +++ b/core/include/cetris.h @@ -10,16 +10,18 @@ #define CETRIS_INITIAL_X 3
#define CETRIS_INITIAL_Y 0
#define CETRIS_INITIAL_Y_OFFSET 2
-//#define CETRIS_BOARD_VISABLE 21
#define CETRIS_HZ 60
#define CETRIS_DAS_DELAY 11
#define CETRIS_DAS_PERIOD 3
#define CETRIS_DROP_PERIOD 2
+#define CETRIS_NEXT_PIECE_DELAY 40
#define CETRIS_LINE_CLEAR_DELAY 40
#define CETRIS_LOCK_DELAY 40
#define CETRIS_WAIT_ON_CLEAR 0
+#define CETRIS_STARTING_LEVEL 1
+
typedef enum {
O, I, S, Z, L, J, T
} type;
@@ -42,15 +44,16 @@ typedef enum { TWICE
} rstate;
-struct tetrimino {
+typedef struct {
type t;
rstate r;
color c;
piece_matrix m;
- u8 ghost_y;
+ i8 ghost_y;
vec2 pos;
u32 lock_tick;
-};
+ bool locked;
+} tetrimino;
typedef struct {
bool occupied;
@@ -60,15 +63,15 @@ typedef struct { color c;
} slot;
-struct cetris_game {
+typedef struct {
/* playfield represented by a 2d array */
slot board[CETRIS_BOARD_X][CETRIS_BOARD_Y];
/* constant queue of all 7 possible tetrimino */
- struct tetrimino piece_queue[7];
+ tetrimino piece_queue[7];
/* current tetrimino */
- struct tetrimino current;
+ tetrimino current;
u8 current_index;
/* input_manager */
@@ -81,6 +84,7 @@ struct cetris_game { /* internal game tick */
u32 tick;
u32 next_drop_tick;
+ u32 next_piece_tick;
/* progress trackers */
u32 lines;
@@ -92,15 +96,16 @@ struct cetris_game { bool mini_tspin;
/* score counter */
- u64 score;
-};
+ u32 score;
+} cetris_game;
-void next_piece(struct cetris_game* g);
-void update_board(struct cetris_game* g);
+void next_piece(cetris_game* g);
+void update_board(cetris_game* g);
+void lock_current(cetris_game* g);
/* API PROTOTYPES FUNCTIONS */
-void init_game(struct cetris_game* g);
-void update_game_tick(struct cetris_game* g);
-void move_piece(struct cetris_game* g, input_t move);
-void stop_holding(struct cetris_game* g, input_t move);
+void init_game(cetris_game* g);
+void update_game_tick(cetris_game* g);
+void move_piece(cetris_game* g, input_t move);
+void stop_holding(cetris_game* g, input_t move);
diff --git a/core/include/input.h b/core/include/input.h index 3cfa947..95cb2aa 100644 --- a/core/include/input.h +++ b/core/include/input.h @@ -3,7 +3,7 @@ #include <stdint.h>
#include <stdbool.h>
-struct cetris_game;
+#include "cetris.h"
-bool handle_inputs(struct cetris_game* g);
-void clear_held_key(struct cetris_game* g);
+bool handle_inputs(cetris_game *g);
+void clear_held_key(cetris_game *g);
diff --git a/core/include/matrix.h b/core/include/matrix.h index 050a32e..eb9e272 100644 --- a/core/include/matrix.h +++ b/core/include/matrix.h @@ -7,8 +7,8 @@ extern const piece_matrix default_matrices[7];
-void move_current(struct cetris_game* g, input_t move);
-void hard_drop(struct cetris_game* g);
-void rotate_matrix(struct cetris_game* g, bool clockwise);
-void set_matrix(struct cetris_game* g, piece_matrix *m);
-i8 check_matrix(struct cetris_game* g, piece_matrix *m);
+void move_current(cetris_game* g, input_t move);
+void hard_drop(cetris_game* g);
+void rotate_matrix(cetris_game* g, bool clockwise);
+void set_matrix(cetris_game* g, piece_matrix* m);
+i8 check_matrix(cetris_game* g, piece_matrix* m);
diff --git a/core/include/test.h b/core/include/test.h index d700627..4b8622e 100644 --- a/core/include/test.h +++ b/core/include/test.h @@ -1,8 +1,8 @@ -struct cetris_game;
+#include "cetris.h"
-enum tests {
+typedef enum {
TSPIN,
TSPIN_NO_LINES
-};
+} test;
-void apply_test_board(struct cetris_game* g, enum tests t);
+void apply_test_board( cetris_game* g, test t);
|