Crates.io | caper |
lib.rs | caper |
version | 0.13.0 |
source | src |
created_at | 2016-05-17 09:34:09.188284 |
updated_at | 2020-11-14 19:11:58.98609 |
description | Minimalist game framework |
homepage | https://github.com/shockham/caper |
repository | https://github.com/shockham/caper |
max_upload_size | |
id | 5092 |
size | 1,942,412 |
Minimalist game framework using rust. Currently has systems for:
Due to the crate alsa-sys being use for linux the following packages are required:
apt install libasound2-dev pkg-config
dnf install alsa-lib-devel
Example of a basis for a game:
extern crate caper;
use caper::game::*;
use caper::imgui::Ui;
use caper::input::Key;
use caper::mesh::gen_cube;
use caper::types::{DefaultTag, RenderItemBuilder, TransformBuilder};
use caper::utils::handle_fp_inputs;
fn main() {
// crate an instance of the game struct
let (mut game, event_loop) = 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(),
);
// run the engine update
start_loop(event_loop, move |events| {
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
},
events,
)
});
}
Check out the examples and run with:
cargo run --example transforms