This Pong Game program is an extension of the previous 'Bouncing Ball' project, wherein a paddle is added to the system. Pong was built through Vivado VHDL on the XILINX Digilent A7-100T FPGA board. The project uses five VHDL source files (clk_wiz_0.vhd, clk_wiz_0_clk_wiz.vhd, vga_sync.vhd, bat_n_ball.vhd, adc_if.vhd, and pong.vhd) and one Vivado constraint file (pong.xdc) to generate a game of pong on a 800x600 Video Graphics Array (VGA) monitor.
Once synthesizing, implementing and programming the FPGA with the baseline program, a blue paddle of size 3x20 will be initialized on the screen. By pressing BTNC on the FPGA, a red, circular pong ball of size 8 will be initialized through the VGA output monitor, bouncing around on two axis of motion and bouncing off the top, left & right walls, as well as the paddle - the bottom screen is off-limits, and allowing the ball to touch is game over. The user must move the paddle to prevent it from touching the bottom screen
This project was completed in self-quarantine during the 2020 global COVID-19 pandemic - the necessary PMOD ADC and Potentiometer hardware to move the paddle around the screen was inaccessible to the designer. As such, the code was redesigned to use the BTNL/BTNR buttons to move the paddle - details can be found on the project page.
The first client-requested revision was to change the speed at which the ball appears to travel around the screen as it bounces off the bat and sides. The motion of the ball is controlled entirely within the bat_n_ball.vhd source. As shown to the left, the speed of the ball is set by a constant standard vector, initially configured to equal 6. We can change this initial value to 24, quadrupling the number of pixels traversed per frame.
The other client-requested revision was to change the width of the bat, first making it larger to make the game easier, then adding a functionality to shrink with each successful bounce to increase difficulty. As it turns out, this addition is rather simple - to do so, we must open up the bat_n_ball.vhd source and edit a signal in its architecture declaration, just above the ball speed signal addressed above. Shown to the left is this code snippet, where the width of the bat has been increased by 10x - how ridiculously easy this makes the Pong game to play! Note that the 'CONSTANT' bat width has been changed to a 'SIGNAL' - this allows us to edit its value below.
To add a little challenge, we might wish to decrease the width of the bat with every successful bounce off the bat - this way, the multistage aerobic capacity test gets progressively more difficult as it continues. This addition can take place in the same source file, within the 'mball' process responsible for triggering actions as the ball hits obstacles & boundaries. Shown to the left is the relevant code snippet, executed only when the ball comes in contact with the bat - by adding a simple decrement line as commented, the bat will now shrink as desired!