Snake Game on the FRDM-KL25Z with Nokia 5110 Display
So I have a graphics driver for a Nokia display (see “Zero Cost 84×48 Graphical LCD for the Freedom Board“), I have a joystick shield (see “JoyStick Shield with the FRDM Board“) and I do have a Freescale Freedom board: why not creating a simple game for it? Snake!
My first mobile phone was a Nokia with a 84×48 black/white display, and I loved it for many reasons, including having the ‘Snake’ game (see http://en.wikipedia.org/wiki/Snake_%28video_game%29). An ARM Cortex M0+ is way overpowered for that simple game, still it is fun to make and game it :-).
The game is very simple: A snake is running around, and I can control it with the cursor/joystick with up, down, left and right. The snake has to ‘eat’ the ‘food’, and the snake gets longer the more food is eaten. But the snake shall *not* touch the outside border.
:idea: Usually there is another rule that the snake shall not touch itself. But I was too lazy to make it.
For the project I ordered a black joystick shield for $11.27, as the soldering quality of the previous ‘white’ one was very bad. The Nokia 5110 LCD I ordered from DX.com for $3.87 so it would directly match with the joystick shield. So makes $30 in total including the FRDM-KL25Z board.
The video shows the game in action:
The Snake game runs as a FreeRTOS task. The drawing and graphics including fonts are implemented with Processor Expert components:
So I have another nice usage for my boards and the joystick shields :-). I need to admit that I’m not very good at the game. My daughter reached level 4 in the first attempt, while my max level is 2, maybe it is just the age ;-). But I’m too honest *not* to build in a cheat mode, or should I? Maybe ;-)
As always, the sources are available on GitHub.
Happy Snaking :-)