#olc #olc-pixel-game-engine


Rust bindings for olcPixelGameEngine

5 releases (breaking)

0.5.0 Jun 5, 2020
0.4.0 May 23, 2020
0.3.0 May 21, 2020
0.2.0 May 20, 2020
0.1.0 May 19, 2020

#243 in Game dev

47 downloads per month

MIT license


Rust 850 SLoC // 0.1% comments C++ 165 SLoC // 0.0% comments


Build Status Crates.io

Library offers Rust API for olcPixelGameEngine. I try keeping the methods and constants similar to the original C++ code so the API feels familiar and it is easy to follow along the tutorial videos.

The code builds on Linux and macOS/OSX (any 10.x, including older versions, only X11 is required) and uses my mac port of pixel game engine https://github.com/sadikovi/olcPixelGameEngine-macos.

You can link the crate as a dependency and extend Application trait to run the pixel game engine:

extern crate olc_pixel_game_engine;

use crate::olc_pixel_game_engine as olc;

// Very simple example application that prints "Hello, World!" on screen.

struct ExampleProgram {}

impl olc::Application for ExampleProgram {
  fn on_user_create(&mut self) -> Result<(), olc::Error> {
    // Mirrors `olcPixelGameEngine::onUserCreate`. Your code goes here.

  fn on_user_update(&mut self, _elapsed_time: f32) -> Result<(), olc::Error> {
    // Mirrors `olcPixelGameEngine::onUserUpdate`. Your code goes here.

    // Clears screen and sets black colour.
    // Prints the string starting at the position (40, 40) and using white colour.
    olc::draw_string(40, 40, "Hello, World!", olc::WHITE)?;

  fn on_user_destroy(&mut self) -> Result<(), olc::Error> {
    // Mirrors `olcPixelGameEngine::onUserDestroy`. Your code goes here.

fn main() {
  let mut example = ExampleProgram {};
  // Launches the program in 200x100 "pixels" screen, where each "pixel" is 4x4 pixel square,
  // and starts the main game loop.
  olc::start("Hello, World!", &mut example, 200, 100, 4, 4).unwrap();

I recommend checking out the documentation to see what APIs are available.


You can look at the examples in examples/ directory to get a sense of available APIs, make sure to also check out the docs.

I will be adding more examples in that directory. Some of them are direct ports of olcPixelGameEngine examples and videos. Feel free to add more as you explore the pixel game engine!

Run examples

For example, run the Isometric Tiles demo with cargo run --example isometric_tiles.


Run cargo build to build the project.


Run cargo test for the project tests.


Run cargo doc --open to build and view the documentation locally.

No runtime deps