Module that contains the primary game functionality.
More...
Module that contains the primary game functionality.
This module contains the game's main functionality. It contains the different tasks, for the main game, main menu & pause screen. It interacts with the Logic Module, the GUI Module , the State Machine Module and the Opponent Module.
- Authors
- Philipp Karg (phili.nosp@m.pp.k.nosp@m.arg@t.nosp@m.um.d.nosp@m.e)
- Date
- 04.02.2021
- Copyright
- Philipp Karg 2022
◆ PRINT_TASK_ERROR
#define PRINT_TASK_ERROR |
( |
|
task | ) |
PRINT_ERROR("Failed to print task ##task"); |
#include <game.h>
Print error message for task
.
- Parameters
-
[in] | task | (const char*): Task to print error message for. |
◆ buttonInput()
static void buttonInput |
( |
bool * |
buttonPressed | ) |
|
|
static |
#include <game.c>
Check for button input, give semaphores and write the pressed buttons in a queue.
- Parameters
-
[in,out] | buttonPressed | (bool): whether a button was pressed. |
◆ changeTimerPeriod()
static void changeTimerPeriod |
( |
TimerHandle_t |
timer, |
|
|
uint8_t |
level, |
|
|
int |
delay |
|
) |
| |
|
static |
#include <game.c>
Change a timer's period depending on the current level & start the timer.
- Parameters
-
[in,out] | timer | ( TimerHandle_t): Timer to change period for. |
[in] | level | (uint8_t): Current level. |
[in] | delay | (int): The delay for changing the period. |
◆ delayAtBottomTimerCallback()
static void delayAtBottomTimerCallback |
( |
TimerHandle_t |
DelayAtGroundTimer | ) |
|
|
static |
#include <game.c>
Callback function for the Timer that starts a delay if a Tetromino hits the bottom.
- Parameters
-
◆ gameTask()
#include <game.c>
Task that handles the Tetris gameplay.
- If the ResetGameSignal has been received, reset the game.
- At the beginning/if the game is reset, the first Tetromino is initialized.
- The Tetrominos position is updated, including x & y position & rotation.
- If a Tetromino hits the ground, start a Timer, so that the player can move around the Tetromino further.
- If the Tetromino is not moved anymore, initialize the next one & add the old one to the landed Tetrominos.
- Draw all aspects of the game, e.g. the falling Tetromino & the static elements.
- If the game is over, save the score & switch to the pause task.
◆ iGameInit()
#include <game.h>
Initialize the game.
- Returns
- (int): 0 upon successful initialization, -1 otherwise.
◆ mainMenuTask()
static void mainMenuTask |
( |
| ) |
|
|
static |
#include <game.c>
Task that handles the Main Menu.
This Task draws the following textures:
Furthermore, this task:
- sets the LevelQueue
- checks if the opponent is connected
- stops/resumes the UDP task depending on the opponents connection
◆ pauseTask()
static void pauseTask |
( |
| ) |
|
|
static |
◆ posUpdateTimerCallback()
static void posUpdateTimerCallback |
( |
TimerHandle_t |
PosUpdateTimer | ) |
|
|
static |
#include <game.c>
Callback function for the Timer that updates the position.
- Parameters
-