My Channel

Death game project in python | How to make a game in python | Text-based adventure game in python | For beginners | Easy python projects |

 

Death game project in python | How to make a game in python | Text-based adventure game in python | For beginners | Easy python projects | Python Bro’s

 

Hi guys, welcome to python bros. Today we are going to make mini-games. This comprises of 3 games. These games are very interesting. These games are really interesting. You can do it in any IDE. This will make you learn python easily. It will also enable to you know more about the input, print and other statements.


 

 

HOW ARE WE GOING TO MAKE IT?

This game uses only very little packages. Most of the code is very easy to understand. Yet, we have explained it. Do us a favour by sharing this post to more than 10 people!


 

 

If you like python, stay tuned to python bros!

WHAT IS THE USE OF THIS GAME?

This game is very interesting to play. We could’ve made the games as separate files. But as we are making this for beginners,  we wanted to make it as a single file.

         This game is very easy to understand. And beginners can make their python programming basics strong.


 

 

As I told, the code is very easy to understand and simple. We have used very simple methods to make this game. Please do try this game and let us know if you enjoyed it in the comment section below.

 

Now let’s go straight into the code:

CODE:

 

#made by raghav, michel and gowri
#importing packages
import webbrowser
import time
#starting the game
welcome = input("Hi, This is death game. You can play some interesting games. Would you like to play? (y/n)  = ")
if welcome=='y':
    print("You have chosen to play the game. Please make your way to the game hall.")
    time.sleep(5)
    #starting cointoss game
    import time

    print("Instructions: The first game is coin toss. 'h' - Heads or 't'[Tails]. A coin will be tossed. If your choice is the outcome of the coin, you will win. If your choice is different than the outcome, you lose.")
    time.sleep(7)
    headsortails = input("What is your choice? (h/t) = ")
    if headsortails=='t':
        print("You lost!")

    else:
        print("You win")
        print("The next game will begin in a few minutes.")
        print("Please move to the hallway")
        #starting good choice game
        print("Hi. Welcome to the choice game. You have to make a choice in order to win this round.")
        whatsyourchoice=input('Would you choose to get 1 million dollars or work hard to get 10000 dollars? (one million / 10000)= ')
        if whatsyourchoice=='10000':
            print("You have picked the right choice. You have won this game.")
            #starting wild game
            print("The next game is in the wild. You will be dropped in a forest. Where you must survive one day to win this round")
            print("Dropping you in the forest...")
            time.sleep(3)
            print("VirtualBot - Hi player. I am a VirtualBot. I will help you in this round. You must survive this one day and you must have walked at least 10 km to win this round.")
            time.sleep(2)
            print("Start walking..")
            walkorno=input('would you walk or quit? = (walk/quit) = ')
            if walkorno=='walk':
                print("Good")
                print("After 5 hrs...")
                time.sleep(3)
                print("Hi there user. You have just walked 5 km. That's good. Now find something to eat.")
                fruitchoosing=input("Would you choose an apple or a worm. The worm is a special kind and very more nutritious. (worm/apple) = ")
                if fruitchoosing=='worm':
                    print("You have done the correct choice. Worms give you good nutrition that is required by you.")
                    leftorright2=input("do you want to turn right or left (left/right) = ")
                    if leftorright2=='right':
                        print("Walking..")
                        time.sleep(3)
                    elif leftorright2=='left':
                        print("Walking..")
                        time.sleep(3)
                        shootorrun=input("There is a lion.Would you shoot or escape? (shoot/escape) = ")
                        if shootorrun=='shoot':
                            print("Bam! The lion is down!")
                            print("You made the right choice!")
                            print("You have survived the forest!")
                            print("You won the death game!")
                            webbrowser.open('https://theraghavblog.blogspot.com')
                        else:
                            print("running away!")
                            time.sleep(2)
                            print("The lion has caught you. You have been eliminated.")


                else:
                    print("apple is ok but the worm is more nutritous.")
                    leftorright2=input("do you want to turn right or left (left/right) = ")
                    if leftorright2=='right':
                        print("Walking..")
                        time.sleep(3)
                    elif leftorright2=='left':
                        print("Walking..")
                        time.sleep(3)
                        shootorrun=input("There is a lion.Would you shoot or escape? (shoot/escape) = ")
                        if shootorrun=='shoot':
                            print("Bam! The lion is down!")
                            print("You made the right choice!")
                            print("nutrition level - 0")
                            print("You have been eliminated!")
                        else:
                            print("running away!")
                            time.sleep(2)
                            print("The lion has caught you. You have been eliminated.")
            else:
                print("You have been let free from the game.")
        else:
            print("You are greedy. You have been elimininated.")


else:
    print("Why are you missing on an enormous cash prize? It's ok..You have just lost the chance to earn millions.")

 

That is the code. Now paste this code in your IDE. You don't need to install any package. Just run it.

Explanation of the code:

First we imported webbrowser and time. Then we started the main game. The game is easy to understand if you know input function and if-elif statements.
To know more about if-elif statement, click here.
To know more about the input function, click here.
 
The code is very easy to understand. Hope you liked this post. For more python content, stay tuned to python bros. Also, visit:

Meet you on the Next Post
Until then Bye!
BY THE BLOG AUTHOR. 

Post a Comment

2 Comments