Space Invaders FPGA Game
This two person project was completed through the course of Embedded Systems at the University of Thessaly, Department of Computer Engineering. In the context of this game we implemented the classic space invaders game using a zedboard fpga. The code is in Verilog and you can find it on github . The project consists of 3 parts. First the connection with the monitor through the vga interface, the game logic and the sprite memory modules.
Each line of the video begins with an active video region, in which RGB values are output for each pixel in the line. Then a blanking region follows in which a horizontal sync pulse is transmitted in the middle of the blanking interval. The interval before the sync pulse is known as front porch and after the sync pulse back porch.
For our project we had a resolution of 640×[email protected], so we created a 50 MHz clock, from the 100 MHz clock input of the Zedboard and the horizontal and the vertical count have a total value of 800 and 524 respectively. Based on these numbers we calculate the exact time that the hsync and vsync are set active high (both signals on this resolution must be active high) and we connect them to the FPGA pins.
The game elements are the spaceship, the 15 aliens (5 per row), the spaceship and alien rockets(6 of them are shooting). The movement of the spaceship is controlled by 2 buttons of the fpga(left and right) and the upper one is for firing the bullet. The bullet moves vertically with a fixed speed until it collides with an alien( or spaceship) or reaches the upper(or lower) border of the screen (screenY/X == 0). The aliens move horizontally and then vertically when they reach the side borders of the screen. Finally the game ends when all the aliens are dead(victory), or the spaceship is destroyed(been hit twice), or if one(or more) alien reach the height of the spaceship.
The spaceship movement is limited by the side borders so if it has reached the left border for example and we press the left button, it will remain at its position.
The spaceship rocket launches when the fire button(upper one) is pressed. It is positioned at the center of the spaceship and flies vertically with the speed of 10 pixels/25mhzClk.
The alien rocket launches with a fix period(3s) from the center of the alien only if there is not alive alien in front of the one who launches it. The aliens that can shoot are the first and last of the bottom row, the second and fourth of the middle and top row.
In order to add some sound effects to the game, we used a sound module that in case of an alien hit produces the A note and a G note at a spaceship hit.
When the game starts, the startup screen is printed of the vga output. After when we press the start button(bottom), we proceed to the game screen. There in the upper left corner is a progress bar which indicates how many aliens have been killed. The points are 3 for the bottom row, 6 for the middle and 9 for the upper row adding up to the 90 points(90 pixels printed) total. At the upper right corner is the remaining life the player has. In case of an alien hit one life is reduced and the remaining life indicator disappears. The background of the game is a starry sky suited to the concept of the game. If the player wins a victory screen appears. In case of defeat the gameover screen appears.
Read more: Space Invaders FPGA Game
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