I have recreated Snake in LabVIEW using event-based producer consumer architecture. This is a fun example of the producer consumer architecture that uses user events to send messages from the consumer to the producer. The consumer loop is structured using states and executes similar to how a state machine would. I was able to take advantage of inlining sub VI’s, giving me the ability to really clean up my block diagram without taking a performance hit. A custom menu was created to give the VI a nice finished feel while it’s running. This project also demonstrates the ability of a project to organize more than just your code. I have included screenshots, project documentation, and VI Analyzer results all within the project file.
This VI recreates the classic Snake game as well as has a custom mode, Grow, to give the classic a new twist. For instructions on game play simply go to Help -> Instructions while the main VI is running.
1 Extract the zip file
2 Open the project file Snake.lvproj
3 Run Snake Main.vi
4 For game instructions see Help->Instructions while running Snake Main.vi
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
This is really cool - I used to love this game as a kid.
Really nice, I'm giving kudos.