54 releases

0.6.5 May 26, 2021
0.6.3 Apr 9, 2021
0.6.2 Mar 15, 2021
0.5.6 Dec 20, 2020
0.2.2 Dec 24, 2018

#20 in Game dev

Download history 144/week @ 2021-06-02 181/week @ 2021-06-09 163/week @ 2021-06-16 113/week @ 2021-06-23 120/week @ 2021-06-30 162/week @ 2021-07-07 201/week @ 2021-07-14 126/week @ 2021-07-21 292/week @ 2021-07-28 282/week @ 2021-08-04 211/week @ 2021-08-11 83/week @ 2021-08-18 107/week @ 2021-08-25 25/week @ 2021-09-01 152/week @ 2021-09-08 42/week @ 2021-09-15

939 downloads per month
Used in 5 crates

MIT license

1.5MB
7.5K SLoC

Tetra

Build Status Crates.io 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
  • Easy input handling, via polling or events, with support for gamepads
  • Deterministic game loop by default, à la Fix Your Timestep
  • Common building blocks built-in, such as:
    • Font rendering
    • Cameras
    • Screen scaling

Installation

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

tetra = "0.6"

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) -> 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(|_| Ok(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 the Rust Game Development Discord.

Dependencies

~8–12MB
~237K SLoC