Home > News & Updates > Electronics News Updates > Space Invaders FPGA Game

Space Invaders FPGA Game

Summary of Space Invaders FPGA Game


This project implements a classic Space Invaders game on a Zedboard FPGA using Verilog. Developed for an Embedded Systems course, it features VGA output at 640×480 resolution, game logic controlling spaceships and aliens, sprite memory modules, and sound effects triggered by collisions.

Parts used in the Space Invaders FPGA Game:

  • Zedboard FPGA
  • VGA interface monitor
  • Verilog code
  • 50 MHz clock generator
  • Two movement buttons (left/right)
  • Firing button (upper)
  • Start button (bottom)
  • Sound module
  • Spriter memory modules

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

Quick Solutions to Questions related to Space Invaders FPGA Game:

  • How is the video signal generated?
    The system uses a 50 MHz clock derived from the 100 MHz input to generate Hsync and Vsync signals for a 640x480@60Hz resolution.
  • What controls the spaceship movement?
    Two buttons on the FPGA control left and right movement, while an upper button fires the bullet.
  • When does the game end?
    The game ends when all aliens are dead, the spaceship is hit twice, or an alien reaches the spaceship's height.
  • How many aliens can shoot simultaneously?
    Six aliens are capable of shooting based on their specific positions in the bottom, middle, and top rows.
  • What determines the points scored?
    Points are awarded as 3 for bottom row hits, 6 for middle row hits, and 9 for upper row hits.
  • How is sound implemented?
    A sound module produces an A note when an alien is hit and a G note when the spaceship is hit.
  • What happens if the player presses a movement button at the border?
    The spaceship remains at its current position and does not move further off-screen.
  • Under what condition do aliens fire rockets?
    An alien fires only if there is no living alien directly in front of it and after a fixed period of 3 seconds.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top