Turrets

Published on 2022-11-20

demo rust macroquad

Follow the dev on Twitch

Controls

  • Left mouse click: Place regular turret
  • Right mouse click: Place laser turret
  • Escape: Take manual control of standing by turrets
  • Escape again: Take the turret back to automatic mode

How to play

There's neither winning nor losing mechanic at the moment, so you can take your time :D

  • Targets will spawn from the top of the screen
  • You can place turrets to destroy them; each turret has its own sensor and will shoot automatically
  • Place turrets using your muse: left click deploys a regular turret, right click deploys a laser beam turret
  • Regular turrets shoot projectiles at a medium pace (for 20 damage)
  • Laser Beam turrets concentrate a beam on their target, inflicting low damage constantly
  • Targets have 100 health points

Context

It's been a while since I wanted to prototype a small turret, similar to what can be found in Team Fortress 2:

The idea was basically to have a Turret featuring those characteristics:

  • Separate Sensor and Cannon, with the Sensor moving left to right (60 degrees on each side)
  • A basic AI able to operate the turret, switching its internal state and rotating the cannon to the next target

And that's pretty much it. I didn't intend to make anything playable out of it, but I may end up refactoring on a regular basis and adding new features, as it's much funnier than I initially expected.

Using Rust and Macroquad was truly a bless, although I'm still unsure on how to solve some issues I encountered. I approached Rust in 2015 initially, but got back to it only very recently, and both the language and its tooling are amazing. Macroquad is a fantastic library to prototype games, as well.

I will probably continue streaming game dev, either this prototype, or new ones, so please head over to Twitch if you're interested in that!

Goals

Those items are on my To-Do list:

  • Add more sounds and replace my awful placeholders (once I figured out how to make samples); got any SimCity 2000 vibe with that laser beam sound :D?
  • As suggested on my Twitch channel, implement a network of sensors with a simple PubSub design, allowing one turret to alert the other ones; possibly adding the possibility to deploy Sensors directly as well
  • Fix the laser beam collision detection (currently, if a target appears between a laser beam turret and its target, nothing happens)
  • Fix the annoying right click behavior on that page (yeah, I know)
  • Possibly refactor and make a game out of it, like a tower defense

History

  • 2022-11-28: More neutral colors

    • Guns stop moving on idle mode
    • Sensors now follow their current target
  • 2022-11-26: Burst Mode for regular turrets!

  • 2022-11-20: Laser beam turrets!

  • 2022-11-15: More bug fixes

    • Introduction of an Assets store
    • Fixed target spawns
  • 2022-11-08: Various bug fixes

    • Turrets can now follow their target
    • Some sounds were added
  • 2022-11-07: Initial implementation

    • One turret in the center of the screen, with a sensor moving left to right
    • A functional cannon (manual)
    • A functional AI, using the sensor to detect targets and rotating the cannon to shoot at them
    • Target spawns from the top of the screen

Repo

Source code is available on Github