Join us today!
Arcade games
Here is a sample project that I ported over to TwinCAT for running the classic snake game. I used this as a sample to start out learning the ST language from ladder logic. There is a 2D boolean array that stores pixels of the screen and another array set that has a shifting index for moving the snake between tiles. The 'ball' or 'food' is a flashing bit that gets scanned and checked if the head of the 'snake' is in contact with it, then shifts down the tail array. A random generator gets new x/y coordinates for the next 'ball' location, and is validated that it is not already part of the tail.
Some items of note:
- Uses a GVL 2-d array and the block checks bounds. Dimensions on the array can be changed to whatever size as long as the visualization is updated
- Uses latching HMI buttons to set the direction in X or Y (-1 or +1 makes cursor go left or right)
- Setup variables initializes and resets all variables on bootup
- Option for autoscrolling where the 'snake' will continue in a loop around the border of the screen
- Option for enable crashes let me disable the end of game when debugging the initial programming
- Option for scan time on a slider permits the game speed to change
- High score and current score display
Other arcade games that I wrote at this time were something similar to the PONG/tennis game as well as the stacking block tower. All of these were running on an HMI for a machine that was being built and I had the opportunity to use a joystick that was required for normal machine operation - much more fun than clicking on the visualization screen!
-
Array Comparison
2 years ago
-
Measuring the scan cycle of PLC
2 years ago
-
Momentary Push Button and LED - Programming Challenge
2 years ago
-
Traffic Simulation
2 years ago
-
Adjustable Flowing LEDs - PLC Programming Challenge
2 years ago
- 17 Forums
- 267 Topics
- 942 Posts
- 4 Online
- 722 Members