The year is 2022. Personal space transport is common and you have taken your space ship out exploring. You find an ancient abandoned planet and decided to land and investigate. There was a huge storm as you landed and your ship now lies in pieces on a landing pad. There is no oxygen in air but you are able to move around in your rover. You have a repair manual, which tells you how to fix your ship, but you don't have the needed spare parts.
You see strange items scattered around on the ground. Maybe they will be useful. You also see strange glowing orbs big enough to swallow your rover. When you touch one, you get sucked in and appear in another place with items and orbs. The orb was a portal! When you re-enter the same portal, it takes you back where you came from.
Your goal is to move about the portal system and collect enough spare parts to fix your ship.
First, copy the code from the following directory: ~csci204/2019-fall/student/projects/p2Dancy/
We have provided an executable prototype of the game. You should see the following set of files in your project folder:
Game.py
the file you need to edit. Contains the framework for the game. Also contains code that communicates with the GUI (Graphical User Interface)gameboard.py
and graphics.py
contains the remainder of the GUI code. You should not have to edit these files..ppm
files that provide the image files for the gameThe GUI makes use of a Point
class - a basic data structure that simply holds an x
and y
attribute. This class is used in the get_rover_location()
and get_image()
methods.
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
go_up
, go_down
, go_left
, and go_right
methods. When the arrow buttons are pushed in the user interface, these methods are automatically called. Your Rover
should move one space in the direction specified.
Look carefully at the implementation of get_image
in Game.py
. It accepts a Point
as the input, which (as we showed earlier) contains Point.x
and Point.y
.
get_image
function for every single coordinate point in the room. This is similar to how Ecosystem's get_inhabitant(self, index)
functioned in your previous project. Now, we are operating in two dimensions, and instead of returning an object, we are directly returning the image name.Point.x
and Point.y
. For example, if a portal is at point x
and y
, return "portal.ppm"
."rover.ppm"
here.get_rover_location
: this function should return the current position of your rover - expressed as a Point
object
There are a lot more methods that you'll eventually need to complete as we progress through the game development.
The goal of part 1 is to focus on your class design and to build movement into the system.
Tasks
, Inventory
, and rest of the buttons do not have to work.The rover must start at a random location in the room.
The ship must have at least 3 different kinds of ship components and at least 6 ship components in total.
There will be a random assortment of parts (gears, screws, cake, etc.) scattered around the room. There must be at least 4 different kinds of parts.
There will be at least 2 portals. Use randomness for both the number and location of the portals
No two items (ship components, parts, portals) may be in the same location
Although the design is largely up to you this time, think carefully about how you will structure your program. We are going to progressively expect better design from you each project, and a portion of your grade will be based on this design. Here are a few things to consider
Portals
, Parts
, and ShipComponents
all have certain things in common. How should you express that relationship?Room
that you are in. Keep in mind that you will have to create many rooms in future parts of this project.Rover
Think carefully about the relationships between these objects. This is the hard part of design! But if you do it right, it will make all your future parts go much smoother.
The universe is infinite. This means that you could constantly walk through portals into new rooms. The objective of phase 2 is to make the portal system functional.
Portals are inter-dimensional doorways to other rooms. If the rover steps on a portal, it must go through the portal. It will arrive on a portal in another room (and not get sucked back through until it steps off and on again).
current_room
data attribute to the Game
class. Always keep this variable updated with a reference to Room
the rover is currently in. You'll have to think carefully how you will keep this reference updated as the Rover goes through portals.Portal
class. Think about what information the Portal class needs to know about (what other objects in your game).The objective of phase 3 is to make the inventory and 'pick up' button work. Whenever the 'pick up' button is clicked in the interface, pick_up(self)
will be called in your Game class. The rest of the implementation is largely up to you, but you should follow these rules:
The inventory is a list of parts the rover is carrying. The inventory shows as a string in the inventory field of the GUI. Think carefully how you want to design your Inventory so that you can keep track of the number of each item.
name
fieldThe get_inventory(self)
function in Game.py
will expect you to return a string representing your current inventory. For Example:
3 Cabbage
1 Screw
2 Gear
.ppm
part of an image name is not displayed.Way Back
button must now be fully functional.As your rover travels deep into this barren world filled with both vast desert landscapes and delicious cake, it's likely that you will get lost. How do you find your way back to your ship? To help the rover, you'll implement the Way Back
button. Whenever this button is hit, the room's portal that contains a path to your ship will change color. This will allow you to always get back to your ship.
Show the way back
button, the GUI will call show_way_back()
.Whenever you have to develop a feature that allows users retrace their steps (either in a browser with the back button or ann app with an undo button), your mind should jump to using a Stack
. Think carefully about how you should use a Stack in your program to recover the rover's way back home.
We are intentionally leaving these details open for interpretation. It's up to you to decide the way to make your program functional. Don't forget to do lots of testing!
This is the final section of the project: Your Rover is in a race against time to fix the ship. You must collect items across the Martian landscape to repair your ship. However, as time passes in the brutal climate, more things go wrong, leaving you with more things to fix before you can get off the planet. If you aren't quick enough at repairing your ship, you may find yourself permanently stuck on Mars.
Your objectives:
Think about what new classes (if any) that you should create to fulfill these goals. Design matters! Don't have a class do too much!
Tasks are shown as a string in the task field of the GUI (much like the inventory):
Broken Engine! To fix the engine, you will need:
- 3 Screws
- 2 Cakes
- 1 Cabbage
Perform Task
button, the items get used up (assuming they have enough of the part).For the last 10% of your grade, you are encouraged to augment your project in any way that you'd like. No matter what you do you must include a README.txt
file describing your functionality.
We will roughly use the following guide to grade creativity: