bottomless_pit/
lib.rs

1//! # Bottomless-pit
2//! Bottomless-pit is a simple 2D game engine that is still a work in progress.
3//! This library is inspired slightly by Raylib and other rust based game engines like GGEZ.
4//! All Bottomless-pit does currently is handle keyboard and mouse input while also providing
5//! a simple way to draw objects to the screen. The shape and texutre renderer is written
6//! in house, but the text rendering is powered by [glyphon](https://github.com/grovesNL/glyphon).
7//!
8//! To get started start by implmenting the Game trait on any struct you like
9//! ```rust,no_run
10//! use bottomless_pit::Game;
11//! use bottomless_pit::engine_handle::{Engine, EngineBuilder};
12//! use bottomless_pit::render::RenderInformation;
13//!
14//! fn main() {
15//!     let engine = EngineBuilder::new()
16//!         .build()
17//!         .expect("Failed to create the engine!");
18//!     let game = CoolGame::new(&mut engine);
19//!
20//!     engine.run(game);
21//! }
22//!
23//! struct CoolGame {
24//!     // put whatever you want here
25//! }
26//!
27//! impl CoolGame {
28//!     pub fn new(engine_handle: &mut Engine) {
29//!         // you can even load assets before the game opens
30//!     }
31//! }
32//!
33//! impl Game for CoolGame {
34//!     fn render<'o>(&'o mut self, mut render_handle: RenderHandle<'o>) {
35//!         // render what ever you want
36//!     }
37//!     fn update(&mut self, engine_handle: &mut Engine) {
38//!         // this is where all your logic should go
39//!     }
40//! }
41#![allow(clippy::needless_doctest_main)]
42
43pub mod buffer;
44pub mod camera;
45pub mod colour;
46mod context;
47pub mod engine_handle;
48pub mod input;
49mod layouts;
50pub mod material;
51pub mod matrix_math;
52pub mod render;
53pub mod resource;
54pub mod shader;
55pub mod text;
56pub mod texture;
57pub mod vectors;
58mod vertex;
59
60use engine_handle::Engine;
61use render::RenderHandle;
62use vectors::Vec2;
63/// The Trait needed for structs to be used in with the Engine
64pub trait Game {
65    /// Rendering code goes here
66    fn render<'o>(&'o mut self, render_handle: RenderHandle<'o>);
67    /// Updating code goes here
68    fn update(&mut self, engine_handle: &mut Engine);
69    /// Things to do when the window closes
70    fn on_close(&self) {}
71    fn on_resize(&mut self, _new_window_size: Vec2<u32>, _engine_handle: &mut Engine) {}
72}
73
74#[rustfmt::skip]
75// just the data for png of a white pixel didnt want it in a seperate file so here is a hard coded const!
76const WHITE_PIXEL: &[u8] = &[137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0, 0, 0, 31, 21, 196, 137, 0, 0, 0, 11, 73, 68, 65, 84, 8, 91, 99, 248, 15, 4, 0, 9, 251, 3, 253, 159, 31, 44, 0, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130];
77const ERROR_TEXTURE_DATA: &[u8] = include_bytes!("error.png");