A simple variation of the famous snake game implemented in the serial terminal using stm32f446re, and FreeRTOS.
The game is very simple, the snake is represented as '&*' where the head is '&', and the body is '*'. The snake moves in the direction of the head, and the user can change the direction of the snake using the following keys:
1: left
2: down
3: right
5: up
The snake dies if it hits the wall, eats and enemy 'E', or if it hits itself. The user is first presented with a welcome message, and can start the game by pressing 's'. The user can reset the game by pressing 'r'.
Each level is 30 seconds, and the snake gets faster as the level increases.
max level: 5
The game is implemented using the Active Object design pattern on top of FreeRTOS. This pattern is used to eliminate most of the blocking typically found in traditional RTOS tasks. Credit to Dr. Miro Samek for the idea and explanation.
This active object encapsulates the attributes and logic of the game. This is a state diagram for the Game implemented in QM modeling tool.

This active object is responsible for sending the displayed frame to the serial terminal through UART communication. The frame is sent as a string of characters, and the screen is updated every 33ms (30fps). This is the state diagram for the ScreenFrame implemented in QM modeling tool.
