how to program the "snake game " on a teensy3.1/smartmatrix driven 32x32 LED panel

Status
Not open for further replies.
how to program the "snake game " on a teensy3.1/smartmatrix driven 32x32 LED panel

My 11YO daughter and I have been playing around with Arduind's and displays. she programmed an alarm clock and insulin reminder that I put in to a cigar box. If she forgets to open the box within 26 hours, an alarm goes off until she takes out the insulin. now she wants to program the "Snake game" into my new 32x32 LED display. I am driving it with a Teensy3.1 / SmartMatrix. I finally got the color wheel test example program going last night, so I am a bit new to LED panels, but i have been programming pro-minis for years to do stuff like destroy ribbon cables used on airborne weather radars with 300oz/in RC servoes. to make it easy for her (and me) i would hope to be able to read the color value in the MatrixArray(X,Y) and the value returned is the color...when done I would gladly post what my daughter and I come up with...
 
If the display hardware doesn't have the feature of reporting the color of an LED at (x, y), your program will have to store it. One way to do it is to declare an array of colors big enough to hold 32x32 = 1024 colors. Instead of calling the function to set the color at (x, y) directly, your program would call a new function that would first record the color in your array at index 32 * y + x, then it would set the color as before. Another new function would return the color at 32 * y + x. Look up 'address arithmetic' for more on how to represent a 2D array in C/C++.

I'd suggest you also search for some code examples of the snake game. I'd guess that examples in any C-like language would give you some good ideas. There's tons of tutorial information on the web about game development.

Hope this helps!
 
Depending on how far you've got I'd suggest making a driver for:
https://learn.adafruit.com/adafruit-gfx-graphics-library/overview
Or just loot the GFX code and the ddrawing routine into your own since I notice it that at least for the version I have it doesn't have a 'readpixel' which is odd. I thought it had last time I used it. In any case as Pictographer said your choices are either having a game memory array (which gives some options to record game information at a different scale to the pixels) or simply use your screen array to track what's going on and read from it each display cycle to get the game onto the matrix.

The early 8 bit game era offers a rich history of concepts for matrix games since they were working with the same memory and resolution limitations. Now wondering how an Teensy rogue-alike would go.
 
so, Array={bla bal} where i=32*y+x. the hard part is going to getting the dat to and from the LED panel. I had to use allot of matrix stuff with this:
it does a 9 day trend of barometric pressure. it interesting to watch as hurricanes go by. its all spark fun stuff....

9 day Barometric trend.jpg

I think it would be easy to start with the 8*8 RG led display and make the snake game with that first.
 
Status
Not open for further replies.
Back
Top