Spaces:
Sleeping
Sleeping
RTS Game Web Application
Quick Start for HuggingFace Spaces
This is a Dockerized web application ready for deployment on HuggingFace Spaces.
Local Development
- Install dependencies:
pip install -r requirements.txt
- Run the server:
uvicorn app:app --host 0.0.0.0 --port 7860 --reload
- Open browser: Navigate to
http://localhost:7860
Docker Build & Run
# Build the image
docker build -t rts-game .
# Run the container
docker run -p 7860:7860 rts-game
Deployment to HuggingFace Spaces
- Create a new Space on HuggingFace with Docker SDK
- Upload all files from this directory
- HuggingFace will automatically build and deploy using the Dockerfile
Project Structure
web/
โโโ app.py # FastAPI server with WebSocket
โโโ Dockerfile # Container configuration
โโโ requirements.txt # Python dependencies
โโโ README.md # HuggingFace Space README
โโโ static/
โ โโโ index.html # Main game interface
โ โโโ styles.css # Modern UI styling
โ โโโ game.js # Game client logic
Features
- Real-time gameplay via WebSocket
- Modern UI/UX with responsive design
- Minimap with viewport indicator
- Resource management system
- AI opponent with intelligent behavior
- Multiple unit types and buildings
- Drag-to-select and command interface
API Endpoints
GET /- Main game interfaceGET /health- Health check endpointWS /ws- WebSocket connection for game communication
Game Commands (WebSocket)
// Move units
{
type: "move_unit",
unit_ids: ["unit-id-1", "unit-id-2"],
target: { x: 100, y: 200 }
}
// Build unit
{
type: "build_unit",
building_id: "building-id",
unit_type: "tank"
}
// Place building
{
type: "build_building",
building_type: "barracks",
position: { x: 240, y: 240 },
player_id: 0
}
Credits
Reimplemented from Python/Pygame to FastAPI/WebSocket for better web accessibility.