Text-Based Adventure Game is a very basic adventure game that any Python beginner can work on. In this article, I am going to walk you through how to make a very basic text-based adventure game with Python.
What is a Text-Based Adventure Game?
A text-based adventure game is a completely text-based and very simple game. In this game, users have options to tackle a situation and with each input provided by the user, the game will continue to increase by putting more situations and more options. This is what a good task for a beginner to get their hands on.
In the section below, you will learn how to create a very basic text-based game with Python. Here I will show you the basic idea of how you can create this game and then you can modify or increase the size of this game with more situations and user inputs to suit you.
Text-Based Adventure Game with Python
Now let’s see how to create a text-based adventure game with Python programming language:
Enter Your Name: Aman
Aman you are stuck at work
You are still working and suddenly you you saw a ghost, Now you have two options
1.Run. 2.Jump from the window
Choose 1 or 2: 1
You did it
Understanding The Code:
In the above code, I am starting by asking for a user to enter his name. Then I am printing that the user is stuck at work. Then I again used a print statement to tell the situation to the user and the next print statement tells the user about the two different options he is having.
At last, I am just using the if and elif statements to show the results based on the input of the user.
I hope you liked this article on how to create a text-based game with Python programming language. Feel free to ask your valuable questions in the comments section below.