The game Pong was the world’s first video game in the early 70’s, it is a tennis lookalike game where a ball is played with two rackets, which are moved up and down by each player. The ball can bounce at the floor and the ceiling. This version is implemented with the virtual game system It was the first game I made for the system.
Some special features of the game is that it is possible to change ball direction and speed, and that it can be played Human vs. Human, Human vs. Computer and Computer vs. Computer. The computer is not very intelligent though, it just checks if the ball is below or above the racket, making it quite easy to beat.
Most of the code is written in C and compiled with Hi-tech PIC-C. It is the best c-compiler available for the PIC, but it comes with really shitty DOS IDE. However, it is possible to integrate the compiler with MPLAB and then you’ll have an extremely powerful easy-to-use development environment. It is this combination that I’ve used developing the virtual pong game, and it is what I recommend you to use when developing stuff for PIC. It is amazing to see how tight code it produces.
It is quite easy to write the game pong in C, it is just a lot “if-statements” that check if the ball should bounce, and also keep track of the players. The communication is not very frequent, each frame there is one screen clear, two horizontal lines (ceiling and floor), two vertical lines (the players), and one pixel set (the ball). Each only causing a few bytes to be sent.
The software is built as a state machine with different states for different screens.
The game also has some simple sound effects. These are generated by an interrupt about 8000 times per second. By sending out a triangle wave in different speeds, different frequencies can be generated.
How to play
When turning on the game, a greeting message says “Virtual Pong © Rickard Gunee” until fire button on joystick 1 is pressed. (Joystick 1 is used in all menus) Then the selection screen appears. This shows “H-H”, meaning “Human vs. Human”, this can be selected by moving the joystick downwards. If the joystick is moved to the left, then it shows “H-C”, meaning “Human vs. Computer” and finally you can select Computer vs. Computer, “C-C” by moving the joystick to the right. The game starts when the fire button is pressed.
In the game view a player serves by pressing fire. Moving the joystick up and down moves the racket. When the ball bounces at the racket, moving the joystick while pressing fire can change speed and direction. When a player misses, a screen showing the score comes up for a couple of seconds before the game continues. The line under one of the numbers shows whose got the serve.
For more detail: Virtual Pong.
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w
Current Project / Post can also be found using:
- virtual led space pong with rackets