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

Implementation of game logic module with low level state machine. More...

#include <stdlib.h>
#include <stdbool.h>
#include "snake.h"
Include dependency graph for snake.c:

Functions

void snake_move (void)
void snake_fruit_check (void)
void snake_game_init (void)
void snake_update (void)
 snake logic state machine function.
void snake_direction_request (direction_t requested_direction)
 Requests change of current snake direction in state machine.
void snake_init_request (int fruit_seed)
 Requests initialization of the snake game in state machine.
void snake_move_request (void)
 Requests 1-tile move of snake in state machine.
bool snake_is_over (void)
 Checks if snake game state is GAME_OVER.
const snake_statesnake_get_state (void)
 Passes current snake game state.
void fruit_pick_position (void)

Detailed Description

Implementation of game logic module with low level state machine.

Author
bslrd
Date
2026

SPDX-License-Identifier: MIT

Function Documentation

◆ fruit_pick_position()

void fruit_pick_position ( void )

◆ snake_direction_request()

void snake_direction_request ( direction_t requested_direction)

Requests change of current snake direction in state machine.

Parameters
requested_directionDirection requested by input system.
Note
Called by game.c state machine.

◆ snake_fruit_check()

void snake_fruit_check ( void )
Here is the call graph for this function:

◆ snake_game_init()

void snake_game_init ( void )
Here is the call graph for this function:

◆ snake_get_state()

const snake_state * snake_get_state ( void )

Passes current snake game state.

Note
The pointer represents valid state until next snake_update() function use.

◆ snake_init_request()

void snake_init_request ( int fruit_seed)

Requests initialization of the snake game in state machine.

Parameters
fruit_seedSeed used for random fruit position generator.
Note
Called by game.c state machine.

◆ snake_is_over()

bool snake_is_over ( void )

Checks if snake game state is GAME_OVER.

◆ snake_move()

void snake_move ( void )

◆ snake_move_request()

void snake_move_request ( void )

Requests 1-tile move of snake in state machine.

Note
Called by game.c state machine.

◆ snake_update()

void snake_update ( void )

snake logic state machine function.

Handles three snake game states (INIT, GAME_OVER, RUNNING).

Note
Called by game.c state machine.
Here is the call graph for this function: