Snake Game on the FRDM-KL25Z with Nokia 5110 Display
Join the DZone community and get the full member experience.
Join For Freeso 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:
summary
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 :-)
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Top 10 Pillars of Zero Trust Networks
-
Testing Applications With JPA Buddy and Testcontainers
-
MLOps: Definition, Importance, and Implementation
-
How To Use the Node Docker Official Image
Comments