Skip to content

traffloat/traffloat

Repository files navigation

Traffloat

GitHub GitHub

Simple issues Medium issues Complex issues

API issues Bug issues Documentation issues Feature issues Optimization issues Tooling issues

A 3D traffic, factory, city building, tower defense web game.

Play the game | Rust API docs | Discuss | Report bug

What is this game about?

This game happens in a self-sustaining space colony. The player constructs buildings and corridors in the colony to produce and transfer different resources.

This game is about logistics. Most resources are created from other types with factories. Insufifciency or excess of resources will bottleneck the game.

This game is about traffic. Resources are transferred in different forms (cargo, liquid, gas, electricity, human). Optimize transportation routes to maximize production rate.

This game is about city building. Inhabitants are produced in the colony to boost productivity. Build schools to improve inhabitant skills and unlock new technologies.

This game is 3D. Explore new transportation mechanisms in a genuinely 3D network of buildings. Become a leading architect for 3D cities.

This game is cooperative. Players can join the colonies of other players, or create new colonies and establish trades with existing colonies.

This game involves tower defense. Colonies are attacked by waves of asteroids in the space, which can be propelled or dissolved into raw resources.

Compilation

This project uses Rust nightly-2021-11-17. The toolchain version is automatically installed if you installed Rust with rustup.

This project requites the wasm target for the Rust toolchain. Install it by running the following command inside a traffloat clone:

rustup target add wasm32-unknown-unknown

This project uses just to manage script commands, and trunk to manage WebAssembly and site building. To install these tools:

cargo install trunk just

See the justfile for common commands, in particular:

# Compile the scenario files
just client-scenarios-dev
# Compile the client for production
just client-build

To compile for development mode, use just client-build-dev instead. There is also just client-watch, which compiles the client and start a dev server, and recompiles if files have been modified.

While development build claims to produce "optimized" output, LTO (link time optimization) in release build can further improve performance and reduce file size at the cost of longer compile time. The release build also triggers wasm-opt with optimization level 4, which takes a long time to execute (more than 15 minutes of CPU time).

Contribution

The game is composed of multiple crates:

  • codegen/codegen-raw: Defines procedural macros used in the game.
  • types: Defines standard data types of vectors, units and gamerule definition.
  • types: Defines scenario schema.
  • common: Implements game world simulation.
  • client: Implements a web game client.
  • tfsave-builder: CLI tool to compile scenarios from human-readable TOML files.

Create a thread in Discussions if you would like to contribute and don't know where to start.