The main class will be LunarLanderUI. You'll run it with:
java LunarLanderUI
A sample can be found in ~/../public/P8/LunarLanderUI.jar. Run it with
java -jar ~/../public/P8/LunarLanderUI.jarNote that this sample gives an idea of what needs to be done, but doesn't follow the requirements in detail. Press the spacebar to fire the engines; release to turn off the engines. Press the escape key to start a new game.
Lunar lander is a game with a spacecraft with a certain amount of fuel trying to land on the moon. The object of the game is to land the craft safely (not exceeding some maximum velocity) without running out of fuel.
In the actual arcade game, you could control both the throttle, as well as rotate the spacecraft so as to move horizontally. In our version of the game, there is no rotation; the only control is the throttle. (See this on-line Lunar Lander game for an idea of what the arcade game looks like).
We give you the physics of the game in a class called LunarLander. It handles keeping track of gravity, fuel remaining, mass of the lander, impulse of the fuel (how much oomph it gives), height and velocity of the lander, and whether or not the lander has landed, or crashed.
However, the LunarLander class is not a model because it doesn't notify observers of changes. Your first task will be to make the LunarLander class a model.
There is a sample implementation of this application in a jar file: LunarLanderUI.jar.
The file LunarLander.java contains the class that handles the physics. There's a unit test TestLunarLander.java that tests LunarLander.java. Use it to help see how to use the class (and verify that it works).
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
manager.addKeyEventDispatcher(new MyKeyEventDispatcher());
Your KeyEventDispatcher should ovverride dispatchKeyEvent.
bundleP8If it is before the due deadline and all necessary assignment files are present, this will turn in your solution files. You can run bundleP8 more than once if you want; only the last one will count.
The assignment is worth 20 points.
Extra credit points of up to 4 points are available for significant additions to the game. Possibilities include: