Lunar Lander

Lunar Lander is one of the earliest computer games, even though it is as much a simulation as a game. The premise of the game is that you are in control of a lunar lander ship, descending to the surface of the moon for a landing. Gravity steadily accelerates your ship faster and faster toward the surface of the moon. You, the astronaut piloting the ship, have a single control: a button with the label "thrust" on it. Applying thrust slows your ship down. Your goal is to get your ship to land on the moon at a slow enough speed so that it doesn't crash on impact. What's the catch? You have only a limited amount of fuel. If you slow down your ship too much too early, you will run out of fuel and crash into the surface of the moon.

With a proper choice of initial values, it is quite a bit of fun to play.

Specifications

You will be given a basic version of the game in which a ball starts at the top of the screen and falls, never stopping. There are two classes that you will modify as part of this game: LunarLander (the game) and LanderTracker (which moves the ship each step of the game).

In the class LunarLander, you should add code to make the lunar surface and a fuel gauge that indicates how much fuel is left in the ship (like the gauge showing the ship's current velocity). Then you should add code to detect when the ship intersects the lunar surface and determines if the player won or lost the game (i.e., hit the surface too fast). When the ship hits the surface, show the player whether they won or lost the game (i.e., display the string winner or loser in big bold letters across the screen) and play a winning sound or a losing sound. Finally, you should add interaction so that the player can press the "i" key to apply the ship's thrusters. Each time the key is pressed, a hrusting sound should play and the ship's velocity and fuel should be decreased once by a set amount, with these new values updated on the indicators on the game screen.

In the class LanderTracker, you should add code that simulates gravity being applied to increase the ship's velocity at each step by a set amount. Also, you should add code that actually applies the player's thrust to the ship's velocity.

Note, you will have to spend some time choosing fixed values for gravity, the thrust's effect, the amount of fuel burned for each thrust, and the speed threshold that determines a safe landing. If the ship falls so fast that it is impossible to land safely with your chosen thrust power, then the game will be no fun to play.

Extra Credit

Once you have the basic game working, you can add a variety of features to make your game more fun to play (listed below roughly in order of difficulty):

Submitting your work Electronically

When you are finished, you should submit your project for grading and update your course web portfolio.

  1. Submit your assignment using Eclipse.
  2. Update your web page by posting your program as an applet.