Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
game_task.h File Reference

Header file for the ADC task system. More...

#include <stdint.h>
#include "stm32f4xx_hal.h"

Go to the source code of this file.

Data Structures

struct  GameTask
 Structure that represents the game task state and configuration. More...

Typedefs

typedef struct SoundTask SoundTask
 Forward declaration for SoundTask.
typedef struct GameTask GameTask
 Forward declaration for GameTask.
typedef void(* game_fcn_t) (GameTask *game_task)
 Function pointer type for ADC state functions.

Functions

void game_task_state_0_init (GameTask *game_task)
 Initializes the game task (state 0).
void game_task_run (GameTask *game_task)
 Executes the current game task state.
void game_task_state_1_home (GameTask *game_task)
 Waits for player to initiate the game (state 1).
void game_task_state_2_play (GameTask *game_task)
 Handles gameplay logic and scoring (state 2).
void game_task_state_3_end (GameTask *game_task)
 Displays game over screen and resets (state 3).

Detailed Description

Header file for the ADC task system.

Author
Andrew Carr and Kai De La Cruz

Created on: May 22, 2025

Typedef Documentation

◆ game_fcn_t

typedef void(* game_fcn_t) (GameTask *game_task)

Function pointer type for ADC state functions.

Each state function must take a pointer to ADCTask as its argument.

◆ GameTask

typedef struct GameTask GameTask

Forward declaration for GameTask.

Forward declaration of GameTask structure.

Function Documentation

◆ game_task_run()

void game_task_run ( GameTask * game_task)

Executes the current game task state.

Parameters
game_taskPointer to the GameTask instance.

Executes the current game task state.

Checks whether the current state index is valid. If so, it calls the corresponding state function from the task's function pointer array.

Parameters
game_taskPointer to the GameTask instance.

◆ game_task_state_0_init()

void game_task_state_0_init ( GameTask * game_task)

Initializes the game task (state 0).

Clears and sets up the LCD, then advances to state 1.

Parameters
game_taskPointer to the GameTask instance.

◆ game_task_state_1_home()

void game_task_state_1_home ( GameTask * game_task)

Waits for player to initiate the game (state 1).

Displays title and instructions. When play_flag is set, transitions to the next state and triggers the start sound.

Parameters
game_taskPointer to the GameTask instance.

◆ game_task_state_2_play()

void game_task_state_2_play ( GameTask * game_task)

Handles gameplay logic and scoring (state 2).

Increments scores based on photoresistor hit flags, updates LCD with score, and transitions to end state when a score threshold is reached.

Parameters
game_taskPointer to the GameTask instance.

◆ game_task_state_3_end()

void game_task_state_3_end ( GameTask * game_task)

Displays game over screen and resets (state 3).

Shows a winning message based on who reached the score threshold first. After a delay, resets the game state and variables.

Parameters
game_taskPointer to the GameTask instance.