Spaces:
Runtime error
Runtime error
File size: 3,123 Bytes
ea0e911 747ada8 ea0e911 747ada8 ea0e911 747ada8 ea0e911 747ada8 ea0e911 747ada8 ea0e911 747ada8 ea0e911 747ada8 ea0e911 747ada8 ea0e911 a9488b8 ea0e911 a9488b8 ea0e911 a9488b8 ea0e911 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import streamlit as st
from PIL import Image
# Define pages
pages = {
'page1': {
'text': "You are a brave hero on a quest to save the princess. You must travel through a dangerous forest to reach the castle where she is being held captive. Do you want to go left or right?",
'left': 'page2',
'right': 'page3',
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
},
'page2': {
'text': "You chose to go left. You come across a river. Do you want to swim across or build a raft?",
'left': 'page4',
'right': 'page5',
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
},
'page3': {
'text': "You chose to go right. You come across a pack of wolves. Do you want to fight them or run away?",
'left': 'page6',
'right': 'page7',
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
},
'page4': {
'text': "You chose to swim across. You make it to the other side safely.",
'left': 'page8',
'right': 'page8',
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
},
'page5': {
'text': "You chose to build a raft. It takes a while, but you eventually make it across the river safely.",
'left': 'page8',
'right': 'page8',
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
},
'page6': {
'text': "You chose to fight the wolves. You defeat them, but you sustain some injuries in the process.",
'left': 'page8',
'right': 'page8',
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
},
'page7': {
'text': "You chose to run away. You escape the wolves, but you get lost in the forest.",
'left': 'page8',
'right': 'page8',
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
},
'page8': {
'text': "You continue on your journey and eventually reach the castle where the princess is being held. You rescue her and she rewards you with a chest full of gold.",
'left': None,
'right': None,
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
}
}
# Define show_page function
def show_page(page_name):
page = pages[page_name]
image = Image.open(page['image'])
st.image(image, caption='', use_column_width=True)
st.write(page['text'])
if page['left'] is not None:
if st.button('Go left', key=hash(page['left'])):
show_page(page['left'])
if page['right'] is not None:
if st.button('Go right', key=hash(page['right'])):
show_page(page['right'])
# Render initial page
show_page('page1') |