0% found this document useful (0 votes)
3 views

Text Based

This document outlines a text-based adventure game where the player navigates through a dungeon with two paths: one leading to a dark hallway and the other to a treasure room. Players make choices that affect the outcome, including battling enemies or facing game over scenarios. The game includes a restart option to play again after completing the adventure.

Uploaded by

yuvasrisri040
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Text Based

This document outlines a text-based adventure game where the player navigates through a dungeon with two paths: one leading to a dark hallway and the other to a treasure room. Players make choices that affect the outcome, including battling enemies or facing game over scenarios. The game includes a restart option to play again after completing the adventure.

Uploaded by

yuvasrisri040
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Import time

Import random

Def print_slow(text):

“””Prints text slowly for dramatic effect.”””

For char in text:

Print(char, end=’’, flush=True)

Time.sleep(0.02)

Print()

Def intro():

Print_slow(“You wake up in a dark dungeon with two paths ahead of you.”)

Print_slow(“One leads to the left, the other to the right.”)

Choice = input(“Which way do you go? (left/right) “).lower()

If choice == “left”:

Dark_hallway()

Elif choice == “right”:

Treasure_room()

Else:

Print_slow(“Confused, you stand still… until something grabs you. Game


over.”)

Restart()

Def dark_hallway():

Print_slow(“You enter a dark hallway. You hear strange noises.”)

Action = input(“Do you keep moving forward or turn back? (forward/back)


“).lower()
If action == “forward”:

Print_slow(“A shadow moves! You find a rusty sword on the ground.”)

Battle(“Shadow Creature”)

Else:

Print_slow(“You turn back but fall into a pit. Game over.”)

Restart()

Def treasure_room():

Print_slow(“You find a room filled with treasure!”)

Print_slow(“But wait… a giant spider guards it.”)

Action = input(“Do you fight or run? (fight/run) “).lower()

If action == “fight”:

Battle(“Giant Spider”)

Else:

Print_slow(“You run back but slip on gold coins. The spider catches you.
Game over.”)

Restart()

Def battle(enemy):

Print_slow(f”A {enemy} attacks!”)

Time.sleep(1)

If random.choice([True, False]):

Print_slow(f”You defeat the {enemy}! You win!”)

Else:

Print_slow(f”The {enemy} was too strong. You lose.”)

Restart()
Def restart():

Choice = input(“Do you want to play again? (yes/no) “).lower()

If choice == “yes”:

Intro()

Else:

Print_slow(“Thanks for playing!”)

# Start the game

Intro()

You might also like