Write a program using an object
Start to create your object-oriented text-based adventure game
Extend other people’s classes
Create an enemy in the room
Recap Week 3
Extending your knowledge of OOP
Finish your game
End of the course
In this step, you will play a text-based adventure game and explore how you could use methods and attributes to interact with a room in the game.
A text-based adventure game is an interactive invented world described in text. It can be filled with different rooms, items, obstacles, or anything your imagination allows. The player interacts with the world by typing commands, and the game describes the result of the player’s commands.
Test the game you will make this week by running the program in Trinket.
You can move around the game by using the commands north, south, east, and west.
Each time you move, you enter a new room and a description is shown.
An example of a room in your game might be a dining hall, described like this:
The dining hall
-------------------
A large room with ornate golden decorations on every wall
The kitchen is north
The ballroom is west
>
In the previous week, you looked at attributes and methods.
Attributes are the pieces of information stored within an object, just like a collection of variables. Methods are the ways in which you interact with an object; you used an on() method to light up an LED in our example in week one.
In your adventure game, what methods do you think might be useful for interacting with a room? As an example, you need to be able to display the name of a room when the player enters it, so you might write a get_room() method.
What attributes do you think a room might have? For example, every room should have a name (for example ‘kitchen’ or ‘dining hall’), so you will add an attribute called name.
Think about the attributes and methods that rooms might have, and share your ideas by leaving a comment. Remember — there is no one correct answer!