DOMville is a lightweight, browser-based city-building simulation game developed using vanilla JavaScript and the HTML5 Canvas API. The project focuses on modular architecture and deep simulation mechanics, featuring procedural terrain generation, dynamic traffic AI, and a fully integrated mass transit system.
- Smart Pathing: Roads and train tracks utilize an auto-merge algorithm to seamlessly stitch arrays together during construction, ensuring continuous visual rendering and perfect AI navigation.
- Coastal and Alpine Engineering: Bypasses standard grid restrictions to allow train tracks to hug ocean coastlines and stations to be constructed directly into mountain terrain.
- Precision Tools: Demolition and rebuild tools allow for single-tile surgical alterations without disrupting entire transit lines.
- Park and Ride Commuting: Citizens actively calculate commute options during rush hours. A significant percentage of the population will drive to local train stations, park, and commute via train, physically reducing vehicular traffic on the road network.
- Supply Chain Logistics: Factories autonomously dispatch delivery trucks to restock supermarkets based on dynamic inventory levels.
- Emergency Dispatch: The city monitors for emergencies (fires, crime, medical events) and automatically paths firetrucks, police, and ambulances from their respective stations to the affected zones.
- Disaster Mechanics: Trains track individual passenger capacities dynamically. Unsafe transit loops with multiple trains feature collision detection, resulting in service disruptions, casualties, and visual explosion effects.
- Procedural Terrain: Generates a randomized island layout upon initialization, complete with organic coastlines, rivers, lakes, and mountain elevations using smoothed boundary mathematics.
- Responsive Rendering: Features a linear-interpolated (lerped) visual grid cursor for smooth tool tracking.
- Adaptive Viewport: Minimap and UI elements automatically scale or hide based on the user's screen resolution to support both desktop and mobile environments.
Because DOMville is built entirely with vanilla JavaScript, HTML, and CSS, it requires no build steps, bundlers, or dependencies.
- Clone the repository to your local machine:
git clone https://github.com/yourusername/DOMville.git
- Navigate into the project directory:
cd DOMville
- Open the project using a local development server to ensure module loading and canvas cross-origin policies function correctly.
- If using VS Code, you can use the Live Server extension.
- If using Python, you can run:
python -m http.server 8000
- Open your browser and navigate to
http://localhost:8000.
- Left Click: Build, zone, or interact with UI panels.
- Right Click: Deselect current tool / Close contextual panels.
- Click and Drag (Middle Mouse / Right Click): Pan the camera across the map.
- Scroll Wheel: Zoom in and out.
- Pinch-to-Zoom: Supported on touch devices.
- D Key: Toggle the Demolish tool.
- R Key: Toggle the Rebuild tool.
Contributions, issues, and feature requests are welcome. Feel free to check the issues page if you want to contribute.
This project is open source and available under the MIT License.