Skip to main content

firecore_tetra/
lib.rs

1//! Tetra is a simple 2D game framework written in Rust. It uses SDL2 for event handling and OpenGL 3.2+ for rendering.
2//!
3//! * [Website](https://tetra.seventeencups.net)
4//! * [Tutorial](https://tetra.seventeencups.net/tutorial)
5//! * [API Docs](https://docs.rs/tetra)
6//! * [FAQ](https://tetra.seventeencups.net/FAQ)
7//!
8//! ## Features
9//!
10//! * XNA/MonoGame-inspired API
11//! * Efficient 2D rendering, with draw call batching by default
12//! * Easy input handling, via polling or events, with support for gamepads
13//! * Deterministic game loop by default, à la [Fix Your Timestep](https://gafferongames.com/post/fix_your_timestep/)
14//! * Common building blocks built-in, such as:
15//!     * Font rendering
16//!     * Cameras
17//!     * Screen scaling
18//!
19//! ## Installation
20//!
21//! To add Tetra to your project, add the following line to your `Cargo.toml` file:
22//!
23//! ```toml
24//! tetra = "0.6"
25//! ```
26//!
27//! You will also need to install the SDL2 native libraries - full details are provided in the [documentation](https://tetra.seventeencups.net/installation).
28//!
29//! ## Examples
30//!
31//! To get a simple window displayed on screen, the following code can be used:
32//!
33//! ```no_run
34//! use firecore_tetra::graphics::{self, Color};
35//! use firecore_tetra::{Context, ContextBuilder, DefaultContext, State};
36//!
37//! struct GameState;
38//!
39//! impl State for GameState {
40//!     fn draw(&mut self, ctx: &mut DefaultContext) -> firecore_tetra::Result {
41//!         // Cornflower blue, as is tradition
42//!         graphics::clear(ctx, Color::rgb(0.392, 0.584, 0.929));
43//!         Ok(())
44//!     }
45//! }
46//!
47//! fn main() -> firecore_tetra::Result {
48//!     ContextBuilder::new("Hello, world!", 1280, 720)
49//!         .build()?
50//!         .run(|_| Ok(GameState))
51//! }
52//! ```
53//!
54//! You can see this example in action by running `cargo run --example hello_world`.
55//!
56//! The full list of examples is available [here](https://tetra.seventeencups.net/examples).
57//!
58//! ## Support/Feedback
59//!
60//! 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](https://twitter.com/17cupsofcoffee) or the [Rust Game Development Discord](https://discord.gg/yNtPTb2).
61
62#![warn(missing_docs)]
63
64#[cfg(feature = "audio")]
65pub mod audio;
66mod context;
67pub mod error;
68mod fs;
69pub mod graphics;
70pub mod input;
71mod lifecycle;
72pub mod math;
73mod platform;
74pub mod time;
75pub mod window;
76
77pub use crate::context::{run, Context, ContextBuilder, DefaultContext};
78pub use crate::error::{Result, TetraError};
79pub use crate::lifecycle::{Event, State};