Spaces:
Runtime error

Game-1 / app.py
MalMish's picture
render background image via html
0573dfe verified
Raw History Blame Contribute Delete
1.52 kB
import gradio as gr
BACKGROUND_IMAGE = "https://images.unsplash.com/photo-qsUudp6RKzQ?auto=format&fit=crop&w=1200&q=80"
def play(choice):
if choice == "Enter":
return (
"🌧️ You step into the Valley of Eternal Monsoons.\n\n"
"Rain softens the world. Memories rise.\n\n"
"Do you follow your heart or protect yourself?"
)
elif choice == "Heart":
return (
"❤️ You choose love over fear.\n\n"
"The Cinematic Thread glows.\n\n"
"Her story has begun."
)
elif choice == "Away":
return (
"🌫️ You choose yourself.\n\n"
"Strength gathers quietly.\n\n"
"Another path will open."
)
return "Make a choice."
with gr.Blocks() as app:
gr.Markdown("# 🎮 HER-VERSE")
gr.Markdown("A cinematic, choice-driven story experience.")
# HTML image (most reliable)
gr.Markdown(
f"""
<div style="text-align:center;">
<img src="{BACKGROUND_IMAGE}"
style="width:100%; max-height:400px; object-fit:cover; border-radius:12px;">
</div>
"""
)
output = gr.Textbox(lines=8, label="Story")
gr.Button("Enter the Monsoon Valley").click(
lambda: play("Enter"), None, output
)
gr.Button("Follow My Heart").click(
lambda: play("Heart"), None, output
)
gr.Button("Walk Away").click(
lambda: play("Away"), None, output
)
app.launch()