Now that we have amassed all the tools we need, we are going to make a video game! Now, it won't be a next-gen console game with lifelike graphics, we will be making a text based adventure game. First, we need one more tool. We want to take input from our player if we want them to stay interested in the game. We do this with the input() command. If we put something inside the parentheses, that will be our prompt.
In [4]:
x = input("Input something please ")
In [5]:
print(x)
Let's get started on our game! The first thing any good hero needs is an inventory. Let's give them one.
In [ ]:
Good! It's empty for now, but I am sure our hero will come across some items soon. Let's give our hero some base information like name, age, health, damage, gold, etc. Choose whatever you think will be important in your game. Remember, we can ask the user for input on some of these.
In [ ]:
Okay, so our hero exists and is ready for action. We ought to keep track of where he is, let's define a location for them to start at, perhaps a town. We can update this as the hero moves from place to place.
In [ ]:
Looks like we are ready to start the adventure. Let's give some options for our hero to choose from and ask for some input. Then let's check if our hero chose one of the acceptable optons. We can check where our hero is and update the options accordingly. Let's loop over and over while we are still in town.
In [ ]:
Maybe now that we have explored the town, we can move on to our quest! As our hero moves from place to place, we can inspire some conflict and use while loops to fight some monster until either of us dies.
In [ ]:
So now we can loop over and over until we decide the hero has "won". Have fun with this and explore different ways to use what we have learned to keep track of our hero.
In [ ]: