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
#![warn(missing_docs)] //! Simple 2d framework/engine //! //! Provides some utilities to draw basic shapes, //! might turn into an actual game engine at some point //! //! ### Math //! [nalgebra-glm](https://nalgebra.org/) is used as the math library and reexported under the //! `rain2d::math` namespace //! //! For documentation see [the official nalgebra-glm documentation](https://nalgebra.org/rustdoc_glm/nalgebra_glm/index.html) //! //! ### Example //! //! ```no_run //! use std::time::Duration; //! //! use rain2d::{ //! core::*, //! math::vec2, //! }; //! //! const WIDTH: usize = 640; //! const HEIGHT: usize = 360; //! //! // can be used to store application state //! struct ExampleApp; //! //! impl RainApp for ExampleApp { //! fn on_update(&mut self, rain: &mut RainCore, dt: Duration) { //! // drawing //! rain.fill_triangle(vec2(120, 300), vec2(520, 300), vec2(320, 100), WHITE); //! //! // keyboard input //! // gets all keys that are currently down //! if let Some(keys) = rain.get_keys() { //! for key in keys { //! match key { //! Key::Space => println!("Spacebar down"), //! Key::A => println!("A down"), //! _ => (), //! } //! } //! } //! //! // only true on keypress, doesn't repeat //! if rain.key_pressed(Key::Key1) { //! println!("1 pressed"); //! } //! //! // mouse input //! if rain.mouse_button_down(MouseButton::Left) { //! if let Some(pos) = rain.get_mouse_pos() { //! println!("Mouse x: {}, Mouse y: {}", pos.x, pos.y); //! } //! } //! } //! } //! //! let mut core = RainCore::init("example app", //! WIDTH, //! HEIGHT, //! true); //! //! core.run(&mut ExampleApp {}); //! ``` pub use nalgebra_glm as math; pub mod core;