Crate caper [−] [src]
Small game framework.
Example of a basis for a game:
#[macro_use] extern crate caper; use caper::types::{ RenderItem, Transform, PhysicsType }; use caper::mesh::gen_cube; fn main() { // define some items to be rendered let mut render_items = vec![ RenderItem { vertices: gen_cube(), shader_name: String::from("dist"), instance_transforms: vec![ Transform { active: true, pos: (-0.5, 0.0, -5.0), rot: (0f32, 0f32, 0f32, 1f32), scale: (1f32, 1f32, 1f32), } ], active: true, physics_type: PhysicsType::None, }, ]; // define a vector for potential text items let text_items = Vec::new(); game_loop! { // following are identities for access to the frameworks systems Input => input, Renderer => renderer, CamState => cam_state, RenderItems => render_items, TextItems => text_items, // define a block for start start => { println!("{:?}", cam_state.cam_pos); }, // define block for update update => { input.handle_fp_inputs(&mut cam_state); }, // block for ui rendering ui => { } } }
Reexports
pub extern crate glium; |
pub extern crate imgui; |
pub extern crate ncollide; |
pub extern crate nphysics3d; |
pub extern crate nalgebra; |
Modules
collision |
Simple collision detection |
input |
Module for input handing |
mesh |
Module for procedurally generated meshes |
persist |
Module for saving and loading data |
posteffect |
Rendering post processing effects |
renderer |
A module for rendering items |
shader |
Module for dealing with shaders |
types |
All of the caper types |
utils |
Utility functions and macros |
Macros
game_loop |
quick macro to use in the examples for easily defining all the modules and game loop |