Minimalist game framework
Rust
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
src Don't require owned string in get_render_item_by_name, closes #24 May 31, 2018
tests Apply rustfmt Aug 19, 2017
.gitignore
.travis.yml
Cargo.toml
LICENSE.md
README.md

README.md

Caper

crates.io version Build status Documentation

Minimalist game framework using rust. Currently has systems for:

Documentation

Setup

Linux

Due to the crate alsa-sys being use for linux the following packages are required:

Debian/Ubuntu etc

apt install libasound2-dev pkg-config

Fedora/RHEL/CentOS

dnf install alsa-lib-devel

Usage

Example of a basis for a game:

extern crate caper;

use caper::types::{DefaultTag, RenderItemBuilder, TransformBuilder};
use caper::game::*;
use caper::mesh::gen_cube;
use caper::imgui::Ui;
use caper::input::Key;
use caper::utils::handle_fp_inputs;

fn main() {
    // crate an instance of the game struct
    let mut game = Game::<DefaultTag>::new();

    // define some items to be rendered
    game.add_render_item(
        RenderItemBuilder::default()
            .vertices(gen_cube())
            .instance_transforms(vec![
                TransformBuilder::default()
                    .pos((-0.5, 0.0, -5.0))
                    .build()
                    .unwrap(),
            ])
            .build()
            .unwrap(),
    );

    loop {
        // run the engine update
        let status = game.update(|_: &Ui| {}, |g: &mut Game<DefaultTag>| -> UpdateStatus {
            // update the first person inputs
            handle_fp_inputs(&mut g.input, &mut g.cams[0]);

            // quit
            if g.input.keys_down.contains(&Key::Escape) {
                return UpdateStatus::Finish;
            }

            UpdateStatus::Continue
        });

        if let UpdateStatus::Finish = status {
            break;
        }
    }
}

Check out the examples and run with:

cargo run --example transforms

License