orbgame icon indicating copy to clipboard operation
orbgame copied to clipboard

Mirror of https://gitlab.redox-os.org/redox-os/orbgame

trafficstars

OrbGame

OrbTk extensions for 2D game development. Compatible with Redox and SDL2.

Build status MIT licensed

Usage

To include orbgame in your project, just add the dependency line to your Cargo.toml file:

orbgame = { git = "https://gitlab.redox-os.org/redox-os/orbgame.git" }

However you also need to have the SDL2 libraries installed on your system. The best way to do this is documented by the SDL2 crate.

Minimal Example

use orbgame::prelude::*;

fn main() {
    Game::new()
        .window(|ctx| {
            Window::create()
                .title("OrbGame - minimal example")
                .position((100.0, 100.0))
                .size(420.0, 730.0)
                .child(TextBlock::create().text("OrbGame").build(ctx))
                .build(ctx)
        })
        .run();
}

Additional Examples

You find the examples in the examples/ directory.

You can start the widgets example by executing the following command:

cargo run --example dungeon --release

Additional Examples on Web

To run the examples on a browser you have to install

cargo install -f cargo-web

Run

You can start the dungeon example by executing the following command:

  • Compile to WebAssembly using Rust's native WebAssembly backend:
cargo web start --target=wasm32-unknown-unknown --auto-reload --example dungeon
  • Compile to asm.js using Emscripten:
$ cargo web start --target=asmjs-unknown-emscripten --auto-reload --example dungeon
  • Compile to WebAssembly using Emscripten:
$ cargo web start --target=wasm32-unknown-emscripten --auto-reload --example dungeon

Build and run documentation

You can build and run the latest documentation y executing the following command:

cargo doc --no-deps --open

Sub Crates

  • api: additional game elements
  • utils: Game helper structs and traits
  • widgets: Game widget library

Credits

  • https://pixel-poem.itch.io/dungeon-assetpuck