1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
/*! Minimalist game framework. Currently has systems for: - Rendering ([glium](https://github.com/tomaka/glium)) - Input ([winit](https://github.com/tomaka/winit) via [volition](https://github.com/shockham/volition)) - Physics ([nphysics](https://github.com/sebcrozet/nphysics)) - Audio ([rodio](https://github.com/tomaka/rodio)) [Example](https://github.com/shockham/caper/blob/master/examples/simple.rs) 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 ```no_run 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, ) }); } ``` */ #![deny(missing_docs)] #[macro_use] extern crate derive_builder; #[macro_use] pub extern crate glium; #[macro_use] extern crate lazy_static; #[macro_use] extern crate serde_derive; pub extern crate image; pub extern crate imgui; #[cfg(feature = "default")] #[cfg(not(feature = "3d-audio"))] pub extern crate impose as audio; #[cfg(feature = "3d-audio")] pub extern crate ambisonic as audio; #[cfg(feature = "nphysics")] pub extern crate nalgebra; #[cfg(feature = "nphysics")] pub extern crate ncollide3d as ncollide; #[cfg(feature = "nphysics")] pub extern crate nphysics3d; pub extern crate volition as input; extern crate bincode; extern crate fps_counter; extern crate gif; extern crate glium_text_rusttype as glium_text; extern crate imgui_glium_renderer; extern crate noise; extern crate rayon; extern crate serde; extern crate time; /// Simple collision detection pub mod collision; /// Module represent another way of creating a game pub mod game; /// Module for procedurally generated meshes pub mod mesh; /// Module for saving and loading data pub mod persist; /// A module for rendering items pub mod renderer; /// All of the caper types pub mod types; /// Utility functions and macros pub mod utils; pub use renderer::lighting; pub use renderer::posteffect; pub use renderer::shader; pub use renderer::texture;