SNAKE_STM32F3
Loading...
Searching...
No Matches
game.c File Reference

Implementation of high-level game state machine module. More...

#include <stdbool.h>
#include "game.h"
#include "snake.h"
#include "Joystick.h"
#include "game_renderer.h"
Include dependency graph for game.c:

Enumerations

enum  { MENU , GAME }

Functions

void game_loop (void)
 Main game state machine function.
void game_init (void)
 Main game init function.
void game_start_request (int game_seed)
 Requests start of the game in state machine.
void game_tick_request (void)
 Requests one tick game progression (one snake move) in state machine.

Detailed Description

Implementation of high-level game state machine module.

Author
bslrd
Date
2026

SPDX-License-Identifier: MIT

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MENU 
GAME 

Function Documentation

◆ game_init()

void game_init ( void )

Main game init function.

Note
Should be called from main() to initialize first menu.
Here is the call graph for this function:

◆ game_loop()

void game_loop ( void )

Main game state machine function.

Handles two application states (MENU, GAME).

Note
Should be called from main() while loop.
Here is the call graph for this function:

◆ game_start_request()

void game_start_request ( int game_seed)

Requests start of the game in state machine.

Parameters
game_seedSeed used for random fruit position generator.
Note
Should be called from start button interrupt.

◆ game_tick_request()

void game_tick_request ( void )

Requests one tick game progression (one snake move) in state machine.

Note
Should be called from timer interrupt with desired snake movement frequency.