A complete template for building a 2D grid based game with a Rust backend and Typescript frontend.
https://icy-shape-6464.fly.dev/
- Serialization (serde)
- Shared types (typeshare)
- Data persistence (sqlx)
- Web server (warp)
- Tooling & bundling (Vite)
- UI (React)
- Game rendering (Pixi.js)
A couple of Rust CLI tools are required to build the project:
For sharing Rust types with client:
cargo install typeshare-cli
For initializing the SQLite database:
cargo install sqlx-cli
Before running for the first time you must run these commands to build the initial types file and initialize the database:
sqlx database create
sqlx migrate run
typeshare ./ --lang=typescript --output-file=client/src/utility/types.ts
Then run the server with:
cargo run
Then run the client dev server (including hot reloading) with:
cd client
npm install
npm run dev
The easiest way to build for release is with the included Dockerfile.
You will need Docker installed for this.
docker build -t gamejam .
docker run -p 8080:8080 gamejam
Then access the game at:
Or deploy wherever you want.
This project can be deployed via Docker on https://fly.io/
Install the fly CLI and then:
fly auth login
fly launch
Fly will launch the app and create a fly.toml
in the root directory with project config options.
Subsequent re-launches using that configuration to overwrite can be made with:
fly deploy
Distributed under the terms of both the MIT license and the Apache License (Version 2.0).