[][src]Crate caper

Minimalist game framework. Currently has systems for:

Example of a basis for a game:

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

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;
        }
    }
}

Re-exports

pub extern crate glium;
pub extern crate image;
pub extern crate imgui;
pub extern crate impose as audio;
pub extern crate nalgebra;
pub extern crate ncollide3d as ncollide;
pub extern crate nphysics3d;
pub extern crate volition as input;
pub use renderer::lighting;
pub use renderer::posteffect;
pub use renderer::shader;
pub use renderer::texture;

Modules

collision

Simple collision detection

game

Module represent another way of creating a game

mesh

Module for procedurally generated meshes

persist

Module for saving and loading data

renderer

A module for rendering items

types

All of the caper types

utils

Utility functions and macros

Macros

load_texture

Macro for including and loading a texture