|rss / atom|
An irregular appearing blog about random LabVIEW topics.
Snake on FPGATuesday 10 December 2019
Here you can download the code to make any NI LabVIEW FPGA your own Snake game console. 800x600 60Hz 8 color VGA signal generation, joystick controlled and fancy graphics. It even features a graphics editor, so you can personalize the game to your liking. Sounds advanced, doesn't it? Well, it's surprisingly easy...
I stumbled across this YouTube video by Ben Eater, where he builds a graphics card using only a breadboard, a crystal oscillator, an EEPROM and some logic ICs. It turns out that generating 800x600 60Hz VGA signals requires a pixel clock of 40 Mhz. That number made me smile. As you all might know, it matches perfect with the clock of the FPGA! You only need 3 digital outputs to generate the VGA signal, 5 to get 8 colors. But my colleagues were not impressed.
I had the VGA signal down. I was drawing squares and I let pixels jump around the screen, but my co-workers were yawning in the background. Danielle challenged me to do a version of the old Snake game that used to be on our phones. Yeah sure, I thought sarcastically, maybe I can add some fancy 3D graphics while I'm at it. But the more I thought about it, the more I could see how it's actually possible. And it works, there is even no code running on RT! Now it's your turn... what can you do? What can you make?
Get the the complete source code for Snake on FPGA from GitHub! It contains the code for generating the VGA signal, the graphics editor, Atari CX40 Joystick support, random item placement and 1 and 2 player game modes. The code was written for a NI MyRIO-1900 in LabVIEW FPGA 2018, but you can easily make it work on any other NI LabVIEW FPGA target. The code on GitHub contains it all.
You can modify the project library so it will run Snake on FPGA on your LabVIEW FPGA target.
You can change the graphics of the game, using the easy to use tileset editor.
You can implement additional gameplay features. More than 2 snakes, obstacles on the game map, what can you come up with?
Or maybe you just want to extract the VGA VIs and start developing your own game?
If you visited NIDays Europe 2019 or the Dutch LabVIEW User Group (DutLUG), you maybe have seen this great 3D printed enclosure my colleague Koen Teeuwen designed. If you fancy some 3D printing, you can download the .STL files in from GitHub repository.
If you have any questions, please don’t hesitate to contact me: firstname.lastname@example.org
Neither I nor VI Technologies are responsible for any damage caused to monitors or other hardware. The attached Code is provided As Is. It has not been tested or validated as a product. You assume all risks for use of the code. Make sure that electrical connections are correct and proper.