Skip to content

NikitHamal/OpenRTS

Repository files navigation

OpenRTS

A compact, mobile-friendly 2D RTS playable in the browser. Inspired by classic C&C/Red Alert/Dune 2000 and modern browser RTS. Built with HTML, CSS, and vanilla JS (no deps).

Features

  • Grid map, camera with zoom, mouse/touch input, mobile-friendly UI.
  • Units: Worker (harvest), Soldier (ranged). Buildings: HQ, Refinery, Barracks, Turret, Power.
  • Economy with ore patches, harvesting, dropoff at HQ/Refinery, population cap from buildings.
  • Selection (click/tap, drag-box), commands: Move, Attack, Harvest, Stop.
  • Build placement with proximity rule (near HQ), production queues, pop limits.
  • A* pathfinding and simple collision handling.
  • Combat with hitscan, HP bars, and turret auto-defense.
  • Simple enemy AI that spawns waves and targets your HQ. Destroy enemy HQ to win.

Run

  • Open index.html in any modern browser (Chrome/Edge/Firefox/Safari). No server required.

Controls

  • Selection: Click/Tap a unit/building. Drag to box-select units. Selected entities show a cyan ring/outline.
  • Pan/Scroll: Toggle the "Pan" button to drag the map. Use range slider to zoom.
  • Commands:
    • Move: Click ground.
    • Attack: Click enemy.
    • Harvest: Click ore (workers only).
    • Stop: Stops selected units.
  • Build: Select HQ (or relevant building), then click a build button (Refinery/Barracks/Turret/Power). Tap on the map near HQ to place.
  • Produce: Select HQ/Barracks to produce Worker/Soldier.
  • Keyboard shortcuts: M (Move), A (Attack), H (Harvest), S (Stop), Esc (Cancel).

Tips

  • Start harvesting early with your Worker to fund builds.
  • Build a Refinery for faster drop-off and a Power to extend population cap.
  • Place a Turret near your HQ or chokepoints for early defense.
  • Enemy waves escalate slowly; prepare before engaging the enemy HQ.

Tech Notes

  • Canvas renders a tile map at 32px/tile internally. Camera manages zoom and translation.
  • A* uses 4-way movement and avoids building-occupied tiles.
  • Turrets auto-target enemies within 6 tiles, ~0.7 shots/sec.
  • Hitscan damage for performance; projectiles omitted to keep code compact.

Known Limitations / Future Ideas

  • No building power grid or advanced tech tree.
  • Basic AI; could add scouting, expansion, path grouping, or micro.
  • Add rally points, guard/hold position, and formation movement.
  • Sound effects, sprite art, and minimap would improve immersion.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published