Python Coding Haunted House by Widyan
Python Coding Haunted House by Widyan
def approach_woman():
story_label.config(
text="You cautiously approach the old woman. 'Take this candle,' she whispers, 'and
head to the basement. There's a secret "
"down there.' She hands you a worn candle, its flame flickering ominously. Will you
go to the basement or stay with her?"
)
choice_button_1.config(text="Go to the basement", command=basement_path)
choice_button_2.config(text="Stay with the woman", command=stay_with_woman)
def basement_path():
story_label.config(
text="The basement door creaks open, revealing a staircase leading into darkness. You
descend slowly, candlelight barely illuminating "
"the stone walls. At the bottom, you find an ancient chest bound with iron. Do you
open it or go back upstairs?"
)
choice_button_1.config(text="Open the chest", command=open_chest)
choice_button_2.config(text="Go back upstairs", command=start_story)
def open_chest():
story_label.config(
text="Inside the chest, you find a book with strange symbols. As you touch it, whispers
fill the room. The walls shake, and the door "
"slams shut. You feel trapped. Do you open the book or try to escape?"
)
choice_button_1.config(text="Open the book", command=curse_ending)
choice_button_2.config(text="Try to escape", command=trapped_ending)
def trapped_ending():
story_label.config(
text="You rush to the door, but it won’t budge. The candle goes out, and darkness
envelops you. Panicked, you realize there’s no escape. "
"This is the end. Do you want to start over?"
)
choice_button_1.config(text="Yes", command=start_story)
choice_button_2.config(text="No", command=end_game)
def stay_with_woman():
story_label.config(
text="You decide to stay with the woman. She hands you a cup of tea, and as you drink,
your surroundings blur. You feel yourself "
"slowly slipping away, fading into the shadows. You’ve joined the spirits in the house.
This is the end. Do you want to start over?"
)
choice_button_1.config(text="Yes", command=start_story)
choice_button_2.config(text="No", command=end_game)
def path_two():
story_label.config(
text="You dash into the forest, branches scratching at your face. The dense trees block
out the moonlight, and soon you find yourself "
"lost. A strange figure appears in the mist. Do you call out to them or hide?"
)
choice_button_1.config(text="Call out", command=call_out)
choice_button_2.config(text="Hide", command=hide)
def call_out():
story_label.config(
text="The figure turns, revealing glowing eyes that pierce through the mist. 'You
shouldn’t be here,' it whispers as it reaches out, "
"pulling you into the darkness. This is the end. Do you want to start over?"
)
choice_button_1.config(text="Yes", command=start_story)
choice_button_2.config(text="No", command=end_game)
def hide():
story_label.config(
text="You hide behind a tree, holding your breath. The figure moves closer, but
suddenly you notice a faint glow in the distance. "
"Do you investigate the glow or stay hidden?"
)
choice_button_1.config(text="Investigate the glow", command=glow_path)
choice_button_2.config(text="Stay hidden", command=hidden_ending)
def glow_path():
story_label.config(
text="Following the glow, you reach a clearing where an ancient stone circle stands. A
spectral figure floats above the stones. "
"'You seek answers,' it says. 'Will you pay the price?' Do you accept its offer or run
away?"
)
choice_button_1.config(text="Accept the offer", command=spectral_ending)
choice_button_2.config(text="Run away", command=run_away)
def spectral_ending():
story_label.config(
text="The figure touches your forehead, filling you with visions of ancient secrets. You
feel yourself becoming one with the forest, "
"bound to its mysteries forever. This is the end. Do you want to start over?"
)
choice_button_1.config(text="Yes", command=start_story)
choice_button_2.config(text="No", command=end_game)
def run_away():
story_label.config(
text="You turn and flee, but the trees seem to close in around you. Lost and exhausted,
you collapse, realizing you’ve been running in circles. "
"This is the end. Do you want to start over?"
)
choice_button_1.config(text="Yes", command=start_story)
choice_button_2.config(text="No", command=end_game)
def hidden_ending():
story_label.config(
text="You remain hidden, but the forest grows eerily silent. The figure disappears, but
you realize you are utterly alone. "
"Forever lost, you wander endlessly. This is the end. Do you want to start over?"
)
choice_button_1.config(text="Yes", command=start_story)
choice_button_2.config(text="No", command=end_game)
def end_game():
root.quit()