Build a Text-Based RPG (Exercise)
00:00 All right, at this point, I can see you’re all trained up and ready for a big challenge. So here it is, your final challenge for this course: Build a Text-Based Role-Playing Game. It has the following features.
The player has the option to attack, heal, or run away. If the player attacks, they deal between
15 damage to the monster. If the player heals, they regain
30 health, but that can’t go over their maximum of
This is going to be a lot of conditional expressions, as you can already see with some of these bullet points start with
if, right? And you have to put some game logic into it to actually make this game work.
01:05 You’ll have to use loops, you’ll have to use loop keywords to maybe break out somewhere or continue in another place, et cetera, et cetera. This challenge is going to bring together all the things that you’ve trained in the course up to now. So if you get stuck somewhere, maybe just look back at the previous lesson and then refresh one of those concepts that you’ve trained there. Okay?
01:26 And then there’s going to be some stretch goals, right? Prevent the player from exiting the game when they press Ctrl + C. So there’s a specific error that Python raises if you press this keyboard combination, and you can do something with that error instead of making the program end.
Then you can introduce double-damage critical hits when an attack value either of the player or the monster is a multiple of
3. And you can also, of course, make the game pretty by using emojis or some string formatting syntax to make the flow of the text that gets printed to the console a little bit nicer.
01:58 Those are your stretch goals. And before, you saw the main characteristics that the game should fulfill. This is a big challenge, and just as before, I’m going ask you now to wait before watching the next lessons because the best way to practice all the concepts that you’ve learned is to try it out yourself.
02:15 So, give it a go. Try to tackle this challenge and write this game. I hope you have fun while doing it. And then when you’re ready, you can move on to the next lessons, where I’ll show you an example of how you could solve this challenge and build this game.
Become a Member to join the conversation.