Skip to content
šŸŽ® A simple 2D game framework written in Rust
Rust GLSL
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Amend examples page to point at latest release Aug 4, 2019
examples First tweaks to the initialization API to get it working better on WASM Aug 14, 2019
src Remove lifetime from ContextBuilder Aug 14, 2019
.gitignore First draft of a tutorial Dec 23, 2018
CHANGELOG.md First tweaks to the initialization API to get it working better on WASM Aug 14, 2019
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Dec 6, 2018
Cargo.toml
LICENSE Initial commit Sep 30, 2018
README.md Point example link in README at release branch Aug 14, 2019
azure-pipelines.yml Set up CI with Azure Pipelines (#126) Jul 4, 2019
book.toml Simplify mdbook config Dec 23, 2018
netlify.toml Migrate website deploments to Netlify Mar 18, 2019

README.md

Tetra

Build Status Crates.io Minimum Rust Version Documentation License

Tetra is a simple 2D game framework written in Rust. It uses SDL2 for event handling and OpenGL 3.2+ for rendering.

Features

  • XNA/MonoGame-inspired API
  • Efficient 2D rendering, with draw call batching by default
  • Simple input handling
  • Animations/spritesheets
  • TTF font rendering
  • Multiple screen scaling algorithms, including pixel-perfect variants (for those chunky retro pixels)
  • Deterministic game loop, Ć  la Fix Your Timestep

Installation

To add Tetra to your project, add the following line to your Cargo.toml file:

tetra = "0.2"

Tetra currently requires Rust 1.32 or higher.

You will also need to install the SDL2 native libraries - full details are provided in the documentation.

Examples

To get a simple window displayed on screen, the following code can be used:

use tetra::graphics::{self, Color};
use tetra::{Context, ContextBuilder, State};

struct GameState;

impl State for GameState {
    fn draw(&mut self, ctx: &mut Context, _dt: f64) -> tetra::Result {
        // Cornflower blue, as is tradition
        graphics::clear(ctx, Color::rgb(0.392, 0.584, 0.929));
        Ok(())
    }
}

fn main() -> tetra::Result {
    ContextBuilder::new("Hello, world!", 1280, 720)
        .build()?
        .run(&mut GameState)
}

You can see this example in action by running cargo run --example hello_world.

The full list of examples is available here.

Support/Feedback

Tetra is fairly early in development, so you might run into bugs/flaky docs/general weirdness. Please feel free to open an issue/PR if you find something! You can also contact me via Twitter, or find me lurking in the #games-and-graphics channel on the Rust Community Discord.

You can’t perform that action at this time.