Brick Game v1.0
Implementation of the game Tetris in the C programming language with a terminal user interface.
Loading...
Searching...
No Matches
game.h
Go to the documentation of this file.
1
6
7#ifndef BRICK_GAME_V1_0_BRICK_GAME_TETRIS_GAME_H_
8#define BRICK_GAME_V1_0_BRICK_GAME_TETRIS_GAME_H_
9
10#include <stdbool.h>
11
12#include "field.h"
13#include "piece.h"
14
16#define MAX_LEVEL 10
17
93
95typedef struct {
96 bool start;
97 bool pause;
98 bool terminate;
99 bool left;
100 bool right;
101 bool down;
102 bool rotate;
103} Inputs;
104
108typedef struct {
110 int lines[4];
112 int len;
114
167
174void update_game_data(GameData *game_data);
175
181PlayField get_combined_game_field(const GameData *game_data);
182
192int get_level(const GameData *game_data);
193
194#endif // #ifndef BRICK_GAME_V1_0_BRICK_GAME_TETRIS_STATE_H_
Defines the playfield and operations on it.
GameState
Enumeration of all states of the game's Finite State Machine.
Definition game.h:19
@ START
Start screen of the game.
Definition game.h:24
@ MOVING
Main state of the game, the player is in control of the piece.
Definition game.h:59
@ CLEARING
Full lines are cleared and points are awarded.
Definition game.h:85
@ ATTACHING
The played piece is attached to the field.
Definition game.h:67
@ GAME_OVER
Game over screen of the game.
Definition game.h:91
@ SPAWN
Spawn the next piece and generate a new random next piece.
Definition game.h:48
@ SPAWN_START
Spawn a random first piece and generate a random next piece.
Definition game.h:35
Defines pieces and operations on them.
PieceType
Possible piece types.
Definition piece.h:23
A list of indices of lines that are detected to be full.
Definition game.h:108
int len
Length of the initialized portions of the lines array.
Definition game.h:112
A structure containing all data about the current game session.
Definition game.h:116
bool top_score_loaded
Indicates if the top_score has been loaded from the file yet.
Definition game.h:165
int top_score
Current highscore.
Definition game.h:154
FilledLines filled_lines
Information about cleared lines.
Definition game.h:134
Inputs inputs
Inputs that are being pressed this frame.
Definition game.h:157
GameState state
Current state of the game's state machine.
Definition game.h:118
PlayedPiece played_piece
Information about the currently played piece.
Definition game.h:126
int score
Current score.
Definition game.h:149
PlayField field
Current Playfield.
Definition game.h:123
PieceType next_piece
The type of the next piece to spawn.
Definition game.h:129
int timer
Counter used for timing different things.
Definition game.h:141
int piece_land_y
The y position of the last attached piece.
Definition game.h:146
bool paused
Indicates if the game is currently paused.
Definition game.h:160
A bitfield describing active user inputs.
Definition game.h:95
State of the playfield.
Definition field.h:17
State of the currently played piece.
Definition piece.h:34