Close

Game logic

A project log for Project Battlesnakes

A classic game of snake, but with a twist and added hardware constraints.

phil-weaselPhil Weasel 09/03/2024 at 07:340 Comments

We can now show something on the screen. Lets write the game 

-> You can find the game logic in the main.c

The game logic itself is pretty much straight forward but with one twist:
For the playing field every LED is numbered (0-63, bottom left = 0, top right =63) and every LED got an signed integer. (so its a 64Byte array)

This way the head position of each player is just a number instead of coordinates.
Moving up = position +8, down -8, left -1, right +1

Also the reason to use a signed integer:
Positive value = Player 1
Negative value = Player 2
-> Storing both players in one Array saving some data.

Discussions