Homework 15: Lunar Lander

Assigned
Monday November 14, 2016
Due
5 p.m., Friday November 18, 2016
Goals
The goal of this assignment is to gain experience with object-oriented programming and interactive graphics.
Collaboration
Do this assignment alone or with a group of your choice (up to three people per group).
Submitting
Submit a Python program using the online turnin form. See below.
Scoring
12 points

Prerequisites

Download the modules lander.py and interfaces.py from the course site, and save it to a new lander directory. You will also want to put a copy of graphics.py and button.py in this directory. You’ll be reusing and extending the given LunarLander class.

Part 1: A Better Interface

The lander game is playable, and will run if you execute the lander.py module from the command line. Go ahead and play a few rounds.

The text version is a bit boring. Let’s update it so that it uses a graphical interface.

First, change your LanderGame’s constructor so that it initializes its interface to a GraphicLanderInterface(). Once you’ve done that, you should be able to play the game using the given bare-bones graphical interface.

There are a few problems with the current graphical interface, however: There is no way to set any thrust. Currently, any mouse click just inputs 0 for thrust amount. There is no display of lander information other than a shape drawn that shows a “lander” above a surface. When the lander lands, the program simply closes down in an unsatisfying way.

Fortunately, you are here to fix these problems! You will need to alter the GraphicLanderInterface() as follows:

  1. In the __init__ method, create two buttons using the Button class. Have one labeled “thrust” and the other labeled “no thrust”. Have the get_thrust method return either 0 or 1 depending on which button is clicked.

  2. In the __init__ method, create a Text object to show the current status. Have the show_info method update the contents of this Text object to show the current Fuel, Velocity, and Altitude.

  3. Change the end-game methods so that they move the lander shape to be on the moon’s surface, and then display a short status message. Also wait for the user to click the mouse before continuing.

If you’ve done all that, you should have a playable graphical lunar lander game.

Part 2: Above & Beyond

Implement at least two of the following extensions. For the possibility of extra credit, choose more complex extensions or implement additional extensions.

Use OOD techniques when adding to your design. More complex extensions may require you to implement new methods or classes; simpler extensions should be changes to existing methods of existing classes.

  • Provide a more versatile control system, e.g., buttons for thrust 2, 3, etc.

  • Draw a lunar lander that looks more like a lunar lander instead of a blue trapezoid.

  • Draw a more celebratory result of successful landing.

  • Draw a more illustrative result of crashing into the moon’s surface.

  • Draw a moon surface that isn’t just a gray rectangle.

  • Draw a background - stars, earth, sun, etc.

  • Develop a scoring system that gives a score based on fuel remaining and speed at impact.

  • Show an intro screen that allows the user to choose a difficulty level before starting the game.

Part 3: Final Project Proposal

Read about the final project and prepare a proposal as described.

Grading & Submission

When finished, submit your interfaces.py and lander.py modules via the turn-in tool. Also submit your project proposal as a PDF file.

  • Buttons - 4 points

  • Showing info - 2 points

  • Game end cleanup - 2 points

  • Style and following directions - 2 points

  • Above and Beyond - 2 points

  • Project proposal - 2 points towards your final project

Good luck, and have fun!



Janet Davis (davisj@whitman.edu).

Created November 14, 2016
Last revised November 14, 2016, 05:36:27 PM PST
CC-BY-NC-SA This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.