This course will be retired on January 6, 2020.
Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
Here's your game-based quest!
Check out the random
library. Can you pick out the method I'm suggesting you use?
The challenge
Create a game with a 2-dimensional map. Place the player, a door, and a monster into random spots in your map. Let the player move around in the map and, after each move, tell them if they've found the door or the monster. If they find either the game is over. The door is the win condition, the monster is the lose condition.
-
0:01
I'd like you to take a second and
-
0:05
realize that you're almost done with another Python course.
-
0:08
That's a big achievement and you've learned a lot in the past five stages.
-
0:11
Not only have you picked up some new tips, tricks and methods with lists, but
-
0:15
you've learned about several other data types.
-
0:16
You learned how to slice lists, strings and
-
0:18
tuples, you learned what a tuple is even.
-
0:20
Then you learned about two handy unsorted data types, sets and dictionaries.
-
0:24
Set math is going to come in very handy for you when you need to compare and
-
0:27
contrast groups of customers some day, and maybe most important of all,
-
0:31
you learned how to pack and unpack tuples and
-
0:33
dictionaries to make your functions much more flexible, useful and pythonic.
-
0:37
That's all so amazing.
-
0:39
But I can't let you go just yet.
-
0:41
We made a couple of games in Python basics, and I think games are a really
-
0:44
good way to practice different bits of code and different ways of thinking.
-
0:47
So let's make another game together.
-
0:49
This one though is going to take advantage of as much of the new stuff in this
-
0:52
course as possible.
-
0:53
It will take us a few videos to get through it together.
-
0:55
So let's get started.
-
0:56
First things first, here's what I planned for us.
-
0:59
This time instead of making a game that just prints words or
-
1:01
hints on the screen, I think we can make a 2D game with some ASCII graphics.
-
1:05
We'll make a grid with a randomly placed invisible exit, then open the player into
-
1:09
a random room in our grid, and we'll hide a monster in another random room.
-
1:13
We'll let the player move around to find the door to leave so
-
1:15
long as they don't find the monster first.
-
1:17
So, we need to have a grid of rooms.
-
1:19
What data type or types would you think would be best for storing this.
-
1:22
And before the game can start, we need to figure out where the player, the door and
-
1:26
the monster are.
-
1:27
The Random Library has a really useful method we can use for
-
1:30
this randomization part.
-
1:32
Finally, we need to let the player move around, but
-
1:34
want to make sure they don't go past the edges of the grid, and we'll have the end
-
1:37
of the game if they run to the monster or get through the secret door.
-
1:40
This is gonna be a challenging project to build, but I know you can do it.
-
1:43
I'll be right there with you the whole way,
-
1:44
no matter how many twisty corridors we come across.
-
1:47
All right, ready?
-
1:48
We'll start building the game in the next video.
-
1:50
Keep an eye out for any groups okay?
You need to sign up for Treehouse in order to download course files.
Sign up