import streamlit as st import base64 st.set_page_config(layout="wide", page_title="Game Dev and 3D Showcase") st.title("Game Development and 3D Content Showcase") # Kaboom.js Breakout Game st.header("Kaboom.js Breakout Game") kaboom_breakout_game = """ """ st.components.v1.html(kaboom_breakout_game, height=650) # Mad Lib Generator st.header("Mad Lib Generator") templates = [ "The {adjective} {noun} {verb} over the {adjective} {noun}.", "In a {adjective} land, a {noun} and a {noun} went on a {adjective} adventure.", "The {noun} {verb} {adverb} while the {adjective} {noun} watched in amazement." ] parts_of_speech = { "adjective": ["brave", "mysterious", "colorful", "gigantic", "tiny"], "noun": ["wizard", "dragon", "knight", "castle", "forest"], "verb": ["flew", "danced", "sang", "fought", "explored"], "adverb": ["quickly", "silently", "gracefully", "fiercely", "carefully"] } def generate_mad_lib(): import random template = random.choice(templates) for part in parts_of_speech: while "{" + part + "}" in template: template = template.replace("{" + part + "}", random.choice(parts_of_speech[part]), 1) return template if st.button("Generate Mad Lib"): st.write(generate_mad_lib()) # A-Frame 3D Scene with Model Upload st.header("A-Frame 3D Scene") aframe_scene = """ """ st.components.v1.html(aframe_scene, height=450) # File uploader for 3D models uploaded_file = st.file_uploader("Upload a 3D model (OBJ or GLB)", type=['obj', 'glb']) if uploaded_file is not None: # Get the file extension file_extension = uploaded_file.name.split('.')[-1].lower() # Encode the file encoded_file = base64.b64encode(uploaded_file.read()).decode() # Create a data URL data_url = f"data:application/octet-stream;base64,{encoded_file}" # JavaScript to load the model load_model_js = f""" """ st.components.v1.html(load_model_js, height=0) st.success(f"Loaded {uploaded_file.name}") st.sidebar.title("Navigation") st.sidebar.info("Use the sections above to interact with different components of the app.")