Brick Game v1.0
Implementation of the game Tetris in the C programming language with a terminal user interface.
|
A structure containing all data about the current game session. More...
#include <game.h>
Public Member Functions | |
void | update_game_data (GameData *game_data) |
Advance the game by one frame. | |
PlayField | get_combined_game_field (const GameData *game_data) |
Get the copy of the current playfield combined with the current piece. | |
int | get_level (const GameData *game_data) |
Get the current level of the game. | |
Static Public Member Functions | |
static void | transition_state (GameData *game_data, GameState new_state) |
Transition the current game state to the given one. | |
static void | reset_game_data (GameData *game_data) |
Reset game state between play sessions. | |
Data Fields | |
GameState | state |
Current state of the game's state machine. | |
PlayField | field |
Current Playfield. | |
PlayedPiece | played_piece |
Information about the currently played piece. | |
PieceType | next_piece |
The type of the next piece to spawn. | |
FilledLines | filled_lines |
Information about cleared lines. | |
int | timer |
Counter used for timing different things. | |
int | piece_land_y |
The y position of the last attached piece. | |
int | score |
Current score. | |
int | top_score |
Current highscore. | |
Inputs | inputs |
Inputs that are being pressed this frame. | |
bool | paused |
Indicates if the game is currently paused. | |
bool | top_score_loaded |
Indicates if the top_score has been loaded from the file yet. | |
A structure containing all data about the current game session.
void update_game_data | ( | GameData * | game_data | ) |
Advance the game by one frame.
If the game is not paused, the code for the current FSM state will be executed.
Get the copy of the current playfield combined with the current piece.
A wrapper for playfield_merge_piece.
int get_level | ( | const GameData * | game_data | ) |
Get the current level of the game.
Level is fully depended on score. Starting at 1, it increases by one for every 600 points earned, until level 10.
Because level depends on score, it is not stored, instead it can just be calculated.
Transition the current game state to the given one.
Resets the GameData::timer.
|
inlinestatic |
Reset game state between play sessions.
Preserves top score so it does not need to be reloaded.
PlayField GameData::field |
Current Playfield.
Does not include the blocks of the played piece.
FilledLines GameData::filled_lines |
int GameData::timer |
Counter used for timing different things.
Used to time piece falling, clearing animation and spawn delay.
Reset to 0 on state transition.
int GameData::piece_land_y |
The y position of the last attached piece.
Used to calculate spawn delay.
int GameData::top_score |
Current highscore.
It is stored in a file and thus, persists through games.
bool GameData::top_score_loaded |