make good games easily

View My GitHub Profile


A Rust library to create Good Games Easily.

More specifically, ggez is a lightweight game framework for making 2D games. It aims to implement an API quite similar to (a Rustified version of) the Love2D game engine. This means it will contain portable basic functionality, without including things that force your game to function a particular way.

It's not meant to be everything to everyone, but rather a good base upon which to build higher-level systems and a useful tool that lets you immediately get started on projects such as game jams. As such, it provides:

Getting it

ggez is built on the latest stable Rust compiler and distributed on To include it in your project, just add the dependency line to your Cargo.toml file:

ggez = "0.2.1"

Or, check out the github page!


See the auto-generated docs at


The best place to find example code is in the project examples directory. There is a simple hello-world example, and a more complete asteroids-like game.

Here's what hello world looks like. It's a bit verbose, sorry. :-P

extern crate ggez;
use std::path;
use ggez::conf;
use ggez::game::{Game, GameState};
use ggez::{GameResult, Context};
use ggez::graphics;
use ggez::timer;
use std::time::Duration;

// First we make a structure to contain the game's state
struct MainState {
    text: graphics::Text,

// Then we implement the `ggez::game::GameState` trait on it, which
// requires callbacks for creating the game state, updating it each
// frame, and drawing it.
// The `GameState` trait also contains callbacks for event handling
// that you can override if you wish, but the defaults are fine.
impl GameState for MainState {
    fn load(ctx: &mut Context, _conf: &conf::Conf) -> GameResult<MainState> {
        let fontpath = path::Path::new("DejaVuSerif.ttf");
        let font = graphics::Font::new(ctx, fontpath, 48).unwrap();
        let text = graphics::Text::new(ctx, "Hello world!", &font).unwrap();

        let s = MainState { text: text };

    fn update(&mut self, _ctx: &mut Context, _dt: Duration) -> GameResult<()> {

    fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
        try!(graphics::draw(ctx, &mut self.text, None, None));
        timer::sleep_until_next_frame(ctx, 60);

// Now our main function, which does three things:
// * First, create a new `ggez::conf::Conf`
// object which contains configuration info on things such
// as screen resolution and window title,
// * Second, create a `ggez::game::Game` object which will
// do the work of creating our MainState and running our game,
// * then just call `` which runs the `Game` mainloop.
pub fn main() {
    let c = conf::Conf::new();
    let mut game: Game<MainState> = Game::new("helloworld", c).unwrap();
    if let Err(e) = {
        println!("Error encountered: {:?}", e);
    } else {
        println!("Game exited cleanly.");


ggez is released under an MIT license.


Open an issue in the Github project, or join us in #rust-gamedev on