import streamlit as st from datetime import datetime # Initialize session state if 'scores' not in st.session_state: st.session_state.scores = [] # HTML/JS game code GAME_HTML = '''
Fuel: 100%
Velocity: 0 m/s
↑ - Thrust
← → - Move
Land between flags
''' def main(): st.title("Lunar Lander") # Display game st.components.v1.html(GAME_HTML, height=450) # Handle score updates st.markdown(""" """, unsafe_allow_html=True) # Display leaderboard if st.session_state.scores: st.subheader("Top Scores") for score in sorted(st.session_state.scores, key=lambda x: x['score'], reverse=True)[:10]: st.write(f"Score: {score['score']} - {score['timestamp'].strftime('%H:%M:%S')}") # Reset scores button if st.button("Reset Scores"): st.session_state.scores = [] st.experimental_rerun() if __name__ == "__main__": main()