File size: 1,501 Bytes
29b445b |
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 |
#!/usr/bin/env python3
import os
import sys
import subprocess
def run_game():
# Check if game app.py exists
game_path = "game.py"
if not os.path.exists(game_path):
print(f"Error: {game_path} not found")
return False
# Get parent directory path (where venv is located)
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Get the path to streamlit in the virtual environment (in parent directory)
if sys.platform == "win32":
streamlit_path = os.path.join(parent_dir, "venv", "Scripts", "streamlit.exe")
else:
streamlit_path = os.path.join(parent_dir, "venv", "bin", "streamlit")
if not os.path.exists(streamlit_path):
print(f"Error: Streamlit not found at {streamlit_path}")
print("Make sure you've run setup.py first to create the virtual environment")
return False
print("=" * 60)
print(" Starting Tag Collector Game")
print("=" * 60)
# Run Streamlit app
try:
command = [streamlit_path, "run", game_path, "--server.port", "8502"]
subprocess.run(command, check=True)
return True
except subprocess.CalledProcessError as e:
print(f"Error running the game: {e}")
return False
except KeyboardInterrupt:
print("\nGame stopped by user")
return True
if __name__ == "__main__":
success = run_game()
sys.exit(0 if success else 1)
|