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.

Space Invaders FPGA Game

VGA technology

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.

Hsync timing

Vsync timing

For our project we had a resolution of 640×480@60Hz, 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.

Game Logic

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.

Game Sound

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.

Game Interface

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


About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation and engineering. My writing style is clear and simple, and I am skilled in using infographics and diagrams. I am a great researcher and am able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter
Scroll to Top