MCPcopy Index your code
hub / github.com/17cupsofcoffee/tetra

github.com/17cupsofcoffee/tetra @0.9.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.9.1 ↗ · + Follow
931 symbols 1,863 edges 61 files 395 documented · 42%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Tetra

Build Status Crates.io Documentation License

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

Status

Tetra is being passively maintained, as of January 2022.

No new features are planned, but occasional bugfix updates may still be released from time to time. PRs may be accepted if they don't have a large maintainence burden.

If you're looking for a similar framework that's more actively developed, try macroquad or GGEZ. Alternatively, you can try nova, my spiritual successor to this library (much smaller scope, still very experimental).

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.9"

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

Examples

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

```rust ,noplaypen 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.

Extension points exported contracts — how you extend this code

State (Interface)
(no doc) [28 implementers]
src/lifecycle.rs
UniformValue (Interface)
Implemented for types that can be passed as a uniform value to a shader. As the implementation of this trait currently [2 …
src/graphics/shader.rs
Scene (Interface)
(no doc) [2 implementers]
examples/tetras.rs
Rasterizer (Interface)
Implemented for types that can rasterize characters, and provide information about their metrics. [2 implementers]
src/graphics/text/cache.rs

Core symbols most depended-on inside this repo

get
called by 36
src/graphics/text/bmfont.rs
clear
called by 33
src/input.rs
run
called by 28
src/context.rs
build
called by 28
src/context.rs
insert
called by 23
src/graphics/text/packer.rs
event
called by 22
src/lifecycle.rs
is_key_down
called by 21
src/input/keyboard.rs
quit_on_escape
called by 20
src/context.rs

Shape

Method 551
Function 237
Class 107
Enum 32
Interface 4

Languages

Rust100%

Modules by API surface

src/platform/device_gl.rs78 symbols
src/platform/window_sdl.rs58 symbols
src/window.rs54 symbols
src/graphics/mesh.rs49 symbols
src/graphics.rs45 symbols
src/graphics/image_data.rs43 symbols
src/audio.rs35 symbols
src/input/gamepad.rs30 symbols
src/graphics/color.rs29 symbols
src/graphics/texture.rs27 symbols
src/context.rs27 symbols
src/graphics/text/bmfont.rs26 symbols

For agents

$ claude mcp add tetra \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page