Lunar lander game on an FPGA

The atari lunar lander game made with hardware


A lunar lander game hardware design in synthesis-able VHDL. Designed to be implemented on a Spartan3 FPGA, and done using Xilinx ISE webpack 14.3. The VHDL code is intended to be as understandable as possible (e.g., process are written to be as close as the rt diagram, instead of wrapping various components in one process).


There are two possible gameplay styles, which can be selected using a switch from the fpga board. Those are:

  1. sile style: the ship goes down the sile, and then it refuels at the bottom of it.
  2. base style: the ship lands on a base, and refuels there. If it goes down at too much velocity (red velocity at the indicator) it crashes. beware, the ship can slip at the base, be careful when landing and don’t go out of the base.


Random positions of bases and world

A Linear Feedback Shift Register (LSFR) is used for implementing a pseudo-random number generator, as seen in this paper. The pseudo random generator is used for generating the world and bases.

Ship movement with inertia and gravity

The movement of the ship is rendered in two steps:

  1. Velocities: The ship has vertical (up-down) and horizontal (left-right) velocities, which allow to have acceleration and correctly simulate the behaviour of the ship. This is implemented with two counters (the vertical counter is descending at a steady pace for simulating the gravity).
  2. Position in the screen: 2 counters, one for vertical, and the other for horizontal pixels, render the ship in the screen. The counters always change in +-1 pixel, but the values of the velocity counters determine the rate, and thus, the ship moves faster or slower in the screen.

World generation

The world is stored in a RAM, column by column. The first pixel of current column is randomly generated by summing/subtracting a fixed amount of pixels to the first pixel of the last painted column. For this, a FSM iterates each column, reading the first pixel of the last column from a register, which stores it.

PS2 module for interfacing with a keyboard

A little FSM with flag registers is used for taking into account the key presses.

VGA sync and screen painting

2 counters are used for creating the vertical and horizontal sync, and are also used for addressing the ram for painting the screen.


Technologies used

RT level HW design, VHDL


gplv3 All the source code present here is under the GPLv3 license. Please see the attached to the repo for more information.