xTetris-Game
|
Go to the source code of this file.
Functions | |
int | randGen (int min, int max) |
Generates a random integer within a specified range. | |
int | clearFullRows (BoardPtr board) |
Change tetromino position as moved by the player. | |
void | makeMove (BoardPtr board, TetrominoPtr tetro, MovePtr storeMove) |
Change tetromino position as moved by the player. | |
int | validRotation (BoardPtr board, TetrominoPtr tetro, MovePtr storeMove, int direction) |
Check if the tetromino rotation is valid. | |
int | validMove (BoardPtr board, MovePtr storeMove, int move) |
Check if a move of the tetromino is valid. | |
int | fallingTetromino (BoardPtr board, MovePtr storeMove) |
Check if tetromino has landed or will move it one step down. | |
int | addTetromino (BoardPtr board, TetrominoPtr tetro, MovePtr storeMove) |
Drop a tetromino into the board. | |
void | startGame (int mode) |
Start the gameplay. | |
int addTetromino | ( | BoardPtr | board, |
TetrominoPtr | tetro, | ||
MovePtr | storeMove ) |
Drop a tetromino into the board.
[in] | board | Player board where the tetromino needs to be dropped. |
[in] | tetro | Store all tetrominoes possibible shapes. |
[in] | storeMove | Struct where all details of current move are stored. |
[out] | complete | Return a number based on tetromino addition (0 if it was added, 1 otherwise). |
Definition at line 186 of file gameCtrl.c.
int clearFullRows | ( | BoardPtr | board | ) |
Change tetromino position as moved by the player.
[in] | board | Player board that needs to be checked if rows are full and clear them. |
Definition at line 29 of file gameCtrl.c.
Check if tetromino has landed or will move it one step down.
[in] | board | Player board where the tetromino is falling or landed. |
[in] | storeMove | Struct where all details of current move are stored. |
[out] | fall | If not moved the value is 0, otherwise 1. |
Definition at line 146 of file gameCtrl.c.
void makeMove | ( | BoardPtr | board, |
TetrominoPtr | tetro, | ||
MovePtr | storeMove ) |
Change tetromino position as moved by the player.
[in] | board | Player board where the move needs to be verified. |
[in] | tetro | Store all tetrominoes possibible shapes. |
[in] | storeMove | Struct where all details of current move are stored. |
Definition at line 79 of file gameCtrl.c.
int randGen | ( | int | min, |
int | max ) |
Generates a random integer within a specified range.
This function generates a random integer within the range specified by the min
and max
parameters. The generated number is selected with equal probability from the range [min, max].
min | The lower bound of the range (inclusive). |
max | The upper bound of the range (inclusive). |
rand()
function is used to generate the random number. The modulo operator (%
) is used to scale the output of rand()
to fit within the desired range. Definition at line 16 of file gameCtrl.c.
void startGame | ( | int | mode | ) |
Start the gameplay.
[in] | mode | Singleplayer or Multiplayer (0 or 1). |
Definition at line 224 of file gameCtrl.c.
Check if a move of the tetromino is valid.
[in] | board | Player board where the move needs to be verified. |
[in] | storeMove | Struct where all details of current move are stored. |
[in] | move | Direction (left -1, right 1) where the tetromino is moved. |
[out] | move | If valid 1, otherwise 0. |
Definition at line 130 of file gameCtrl.c.
int validRotation | ( | BoardPtr | board, |
TetrominoPtr | tetro, | ||
MovePtr | storeMove, | ||
int | direction ) |
Check if the tetromino rotation is valid.
[in] | board | Player board where the move needs to be verified. |
[in] | tetro | Store all tetrominoes possibible shapes. |
[in] | storeMove | Struct where all details of current move to make are store. |
[in] | direction | Value of rotation, -1 for 90° counterclockwise, 1 for 90° clockwise. |
[out] | rotation | If valid return 1, otherwise 0. |
Definition at line 102 of file gameCtrl.c.