Ryan Andersen / Projects /

SpaceRTS
5/22/2024 // View project source

Table of Contents

SpaceRTS is a data-driven RTS game prototype I worked on over the course of 2024 and 2025.

Gameplay

gameplay While most of the my time went into the game systems, I did add some basic gameplay systems:

  • ships the player can move around
  • certain ships can build structures
  • ships that have weapons will automatically attack enemy ships

main menu

The game's main menu

Large Worlds

I use double precision floats for all units, so the game supports an absolutely massive map. The current play area is 2^17 (131,072) units of all sides (for reference, the small ship is ~.5 units).

map

Each cluster here is a star system, each 1000+ units wide and with dozens of planets

Multiplayer

The game supports multiplayer among a reasonable number of players. It uses deterministic lockstep, with each turn being 10 ticks and input having a 2-turn delay. This it meant once the core lockstep logic was implemented, most

Serialization

Shaders

I wrote some shaders for game using SimulationFramework's canvas shaders. I'm happy with how they came out and I think they add a lot to the look and feel of the game.

Black Hole

The black hole shader uses raymarching to produce gravitational lensing effects.

black hole

You might think this black hole is sideways. Well, I think the camera is.

After each ray step, its direction is distorted towards the black hole (by "gravity"). Even though the SDF consists only of the eccretion disk (a perfect cylinder), the rays travel along a curve, yielding a wicked looking black hole.

Also, the disk color is determined by sampling by random noise (with brightness effected by distance).

black hole 2

Kind of looks like M87... no? just me?

Check out the black hole shader source here.

Star

The star shader is actually two shaders in a trech coat: One for the star itself and another for the corona.

sun

The star shader

The main star uses 12 layers of random noise, each having 3/4 the scale and 2/3 the brightness of the last. The noise is slightly compressed toward the edges to give it the appearance of a ball.

The corona also uses random noise layers (5 this time), but it samples based on angle to the star center instead of position.

Check out the star shader source here.

Galaxy

The galaxy shader is again built on random noise (aren't all good shaders?).

galaxy

A long time ago in a galaxy far, far away...

For each NxN world cell (size is determined by integer zoom level) the star density is calculated and used to sample a few stars.

The "stars" are generated by hashing the cell coordinates and zoom level to sample random noise. For each star a random temperature is generated using real star density & brightness data, then that temperature is converted to a color. The actual star sample is just that color scaled multiplied a distance falloff.

This is done for the integer above and below the actual zoom level, then interpolated (for a smooth transition between low and high densities).

galaxy2

The galaxy's arm count, curve, shape and more can be modified. In game they are randomly generated.

Check out the galaxy shader source here.