Go Down

Topic: TVOut - Game - Columns (Read 3000 times) previous topic - next topic


May 03, 2012, 03:27 pm Last Edit: May 03, 2012, 03:31 pm by winkleink Reason: 1
I posted this in the [Using Arduino :: Displays ::] forum and somebody suggested I put it in the Exhibition Forum, so I'm posting here also.  If I've done this the wrong way I'm sorry. 

I saw the TVOut ( http://code.google.com/p/arduino-tvout/ ) library about a year ago and finally got to do some hacking with it.
I decided that I would recreate the classic game Columns which has the fell of Tetris, but isn't
In columns it is always 3 blocks that fall vertically.  You can move the blocks left and right and rotate the 3 blocks, so the top one goes to the middle, the middle to the bottom and the bottom to the top.
The goal is get 3 in a row, either vertically, horizontally or diagonally.
Then those 3 pieces are removed and the blocks above fall down.

The code is still a bit of a mess, so needs a little bit of cleaning up before I make it public (which I will).  If you want a copy of the rough, nasty typo comment filled code let me know and I'd be happy to send it on.

The controls are just 3 tactile button on a breadboard, so this should work on any 328 based Arduino (needs 2K of SRAM as the display alone takes 1,440 bytes)

I have done a short video of it working on YouTube.


All I can say is Thank You to mdmetzle for creating a fantastic Library that made this possible.


Smooth, really cool.

It thing it must be possible to get lower sram use. Maybe you should check The games on hackvision or Wayne and layne's Video game shield. But probable you already did.

Nederlandstalige sectie - http://arduino.cc/forum/index.php/board,77.0.html -


Smooth, really cool.

It thing it must be possible to get lower sram use. Maybe you should check The games on hackvision or Wayne and layne's Video game shield. But probable you already did.

I expect your right in reducing the SRAM . My understanding is that the Hackvision and Wayne and Iayne's shield both use the TVOut Library by Myles Metzler and their games are far more complex then anything I am producing
You can store graphics in the 32K of FLASH memory on the Arduino so extra graphics to some extend reduces the memory usage.

My understanding is that a resolution of 120x96 uses 1,440 bytes (120x96/8), leaving 608 bytes for all other variables.
There are 2 byte arrays for the playing area 13x6 (78 bytes). One for the display and the other for when I'm checking for 3s.  Another 156 Bytes, leaving 452.
Any text on screen takes up SRAM as well.
There are about 50 Bytes used for the opening text and 27 for the GAME OVER screen, so another 72 BYTES
Leaving 380 bytes.

Then there is the SRAM used by the TVOut Library just to function. I have no idea how it uses.

So, it got pretty tight in there. 

Looking at that HackVision the closest program I would expect is Tetris. In that case all blocks once placed are the same so there is no need to record the different types of blocks at each position.  It would be possible to use the get_pixel(x,y) command to check if a block has been placed at a location.

That said I know my code is not optimised. I learned to code on a VIC-20/C64 back in the 80's and it's still the same coding practices I use now. One of these days I'll figure out how to program in C++ properly.   I looked at some of the HackVison code and it is way beyond what I have done.

That's the great thing about the Arduino.  Even basic programmers like me can put together something that works.  Then there is the opportunity to learn and refine and get even better without it being overwhelming at any time.


I did the clean up of the code.
Used one of the formatting tools to sorted out the indentatio and added more comments so it should (hopefully) be easy to understand.

I've put a link to the code on my blog (so I only have to manage 1 link)
So, if you want the code just follow the link below 


oké great, thanks ;-)

Nederlandstalige sectie - http://arduino.cc/forum/index.php/board,77.0.html -


Please upload the code here - dropbox give error 404 :-(


Go Up