Giter Site home page Giter Site logo

linecode / tetra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 17cupsofcoffee/tetra

0.0 1.0 0.0 8.42 MB

๐ŸŽฎ A simple 2D game framework written in Rust

Home Page: https://tetra.seventeencups.net

License: MIT License

Rust 99.82% GLSL 0.18%

tetra's Introduction

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

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, the Rust Game Development Discord, or the #games-and-graphics channel on the Rust Community Discord.

tetra's People

Contributors

17cupsofcoffee avatar aaneto avatar dependabot-preview[bot] avatar johanlindfors avatar puppetmaster- avatar selimeren avatar tatref avatar teknico avatar victorkoenders avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.