Struct Engine

Source
pub struct Engine {
    pub title: String,
    pub elapsed: f64,
    /* private fields */
}
Expand description

Bone of the Engine, join everything;

Fields§

§title: String

Main title of the window, Window’s full title will be Title - fps You can modify it to change the title

§elapsed: f64

Time between current frame and last frame, useful for movement’s calculations

Implementations§

Source§

impl Engine

Source

pub fn size(&self) -> Vu2d

Return the current Target size in pixel

Source

pub fn scale(&self) -> u32

Return the pixel scale factor

Source

pub fn get_key(&self, keycode: Keycodes) -> Input

Get The status of a key

Source

pub fn get_mouse_btn(&self, btn: MouseBtn) -> Input

Get the status of a Mouse Button

Source

pub fn get_mouse_location(&self) -> Vu2d

Get the mouse location (in pixel) on the screen Will be defaulted to (0,0) at the start of the program

Source

pub fn get_mouse_wheel(&self) -> MouseWheel

Get the scroll wheel direction (If Any) during the frame

Source

pub fn get_pressed(&self) -> HashSet<Keycodes>

Get all Keys pressed during the last frame

Source

pub fn get_held(&self) -> HashSet<Keycodes>

Get all the keys that were held during the last frame

Source

pub fn get_released(&self) -> HashSet<Keycodes>

Get all the keys that were released during the last frame

Source

pub fn create_decal(&mut self, sprite: &Sprite) -> Decal

Create a GPU version of Sprite

Source

pub fn clear_input_buffer(&mut self)

Will clear the input buffer and set the cursor to 0

Source

pub fn set_input_buffer(&mut self, value: impl AsRef<str>)

Set the input buffer to the desired value and put the input cursor at the end of the text

§Warning

The value must be an ascii string

Source

pub fn insert_input_buffer(&mut self, value: impl AsRef<str>)

Insert the given string into the input buffer at the input cursor

§Warning

if the string is not only ASCII characters it will silently do nothing

Source

pub fn append_input_buffer(&mut self, value: impl AsRef<str>)

Append the given string onto the input buffer

§Warning

if the string is not only ASCII characters it will silently do nothing

Source

pub fn add_input_passthrough( &mut self, iterator: impl Iterator<Item = Keycodes>, )

Add keys onto the input pass through list

Source

pub fn remove_input_passthrough( &mut self, iterator: impl Iterator<Item = Keycodes>, )

Remove keys onto the input pass through list

Source

pub fn set_input_passthrough( &mut self, iterator: impl Iterator<Item = Keycodes>, )

Set the input to the iterator

Source

pub fn set_ignore_passthrough_chars(&mut self, val: bool)

If set to true, any key that is passed through when in input mode won’t have the char appended to the input buffer

Source

pub fn get_input_buffer(&self) -> &str

Return a view into the input buffer

Source

pub fn get_input_cursor(&self) -> usize

Return the input cursor

Source

pub fn start_input(&mut self)

Switch to text input mode, return true if it wasn’t in this mode before

Source

pub fn force_stop_input_mode(&mut self)

This will clear the input buffer, reset the input cursor and stop the input mode

Source

pub fn is_in_input_mode(&self) -> bool

Is the engine in input mode

Source

pub fn end_input_mode(&mut self) -> &str

Stop the input mode right there, and return a &str to the current buffer. This is if you need to leave the mode but retain the input buffer for a later re-entry

Trait Implementations§

Source§

impl Debug for Engine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DecalDraw for Engine

Source§

fn draw_explicit_decal<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], uv: [P; 4], decal: &Decal, tint: Color, )

Draw A decal with given position and uv (You probably don’t want to use this)
Source§

fn draw_decal<P: Into<Vf2d> + Copy>(&mut self, pos: P, decal: &Decal)

Draw a decal from the given position
Source§

fn draw_decal_scaled<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, scale: P, )

Draw a decal with a given scale
Source§

fn draw_partial_decal<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, source_pos: P, source_size: P, )

Draw a partial decal from the given position
Source§

fn draw_partial_decal_scaled<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, source_pos: P, source_size: P, scale: P, )

Draw a partial decal with a given scale
Source§

fn draw_warped_decal<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], decal: &Decal, )

Draw a decal where all Corner are given, this will set the uv correctly to allow texture warping The points are in order: Read more
Source§

fn draw_warped_partial_decal<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], source_pos: P, source_size: P, decal: &Decal, )

Draw a decal where all Corner are given, this will set the uv correctly to allow texture warping The points are in order: Read more
Source§

fn draw_rotated_decal<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, angle: f32, center: P, )

Draw a decal rotated angle radians around center center is an offset in pixel from the top left corner of the decal
Source§

fn draw_rotated_decal_scaled<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, angle: f32, center: P, scale: P, )

Same as draw_rotated_decal but with scaling
Source§

fn draw_partial_rotated_decal<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, angle: f32, center: P, source_pos: P, source_size: P, )

Draw a zone of a decal and rotate it
Source§

fn draw_partial_rotated_decal_scaled<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, angle: f32, center: P, source_pos: P, source_size: P, scaled: P, )

Draw a zone of a decal, rotate it and scaled it
Source§

fn draw_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_decal_scaled_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, scale: P, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_partial_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, source_pos: P, source_size: P, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_partial_decal_scaled_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, source_pos: P, source_size: P, scale: P, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_warped_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], decal: &Decal, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_warped_partial_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], source_pos: P, source_size: P, decal: &Decal, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_rotated_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, center: P, angle: f32, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_rotated_decal_scaled_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, center: P, angle: f32, scale: P, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_partial_rotated_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, angle: f32, center: P, source_pos: P, source_size: P, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

fn draw_partial_rotated_decal_scaled_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, angle: f32, center: P, source_pos: P, source_size: P, scaled: P, tint: Color, )

Same as the non tinted variant, but with an tint color parameter
Source§

impl DecalText for Engine

Source§

fn draw_text_decal( &mut self, pos: impl Into<Vf2d>, text: impl AsRef<str>, scale: impl Into<Vf2d>, color: impl Into<Color>, )

Draw the given string starting at the position given and scaled
Source§

impl DrawSpriteTrait for Engine

Source§

fn size(&self) -> Vu2d

Source§

fn get_pixel(&self, pos: Vi2d) -> Option<Color>

Source§

fn set_pixel(&mut self, pos: Vi2d, col: Color)

Source§

unsafe fn get_pixel_unchecked(&self, pos: Vu2d) -> Color

Get the pixel at the given location, but bypassing any bounds check Read more
Source§

unsafe fn set_pixel_unchecked(&mut self, pos: Vu2d, col: Color)

Set the pixel at the given location, but bypassing any bounds check Read more
Source§

impl SmartDrawingTrait for Engine

Source§

fn draw<P: Into<Vi2d>>(&mut self, pos: P, col: Color)

Set the pixel data at the given coordinates to the given Color Will use the current PixelMode
Source§

fn clear(&mut self, col: Color)

Clear the Sprite With the given Color
Source§

fn get_size(&self) -> Vu2d

Get the size of the target
Source§

fn set_pixel_mode(&mut self, mode: PixelMode)

Set the PixelMode
Source§

fn get_pixel<P: Into<Vi2d>>(&self, pos: P) -> Option<Color>

Get the Pixel Data at the given coordinates
Source§

fn set_blend_factor(&mut self, f: f32)

Set the Blend Factor Used for alpha calculations
Source§

fn get_textsheet(&self) -> &'static Sprite

Get The textsheet (A Sprite)
Source§

fn get_pixel_mode(&self) -> PixelMode

Return the PixelMode
Source§

fn get_blend_factor(&self) -> f32

Get the Blend Factor Used for alpha calculations

Auto Trait Implementations§

§

impl !Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl !Send for Engine

§

impl !Sync for Engine

§

impl Unpin for Engine

§

impl !UnwindSafe for Engine

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> DottedShapeTrait for T

Source§

fn draw_line_dotted<P>(&mut self, p1: P, p2: P, col: Color, pattern: u32)
where P: Into<Vec2d<i32>>,

Draw a dotted line
Source§

fn draw_rect_dotted<P>(&mut self, pos: P, size: P, col: Color, pattern: u32)
where P: Into<Vec2d<i32>>,

Draw a rectangle with the top left corner at (x, y) and the bottom right corner at (x + w, y + h) (both inclusive) This is the dotted form
Source§

fn draw_triangle_dotted<P>( &mut self, pts1: P, pts2: P, pts3: P, col: Color, pattern: u32, )
where P: Into<Vec2d<i32>>,

Draw the edges of a triangle between the three points This is the dotted form
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ShapesTrait for T

Source§

fn draw_text<P>(&mut self, pos: P, scale: u32, col: Color, text: &str)
where P: Into<Vec2d<i32>>,

Draw text to the screen scale must be >= 1 The textsize will be equal to scale * 8 for the height and scale * 8 * text.len() for the width This will handle \n treating it as a new line, but wont do any newline stuff if it is drawing out of the screen
Source§

fn draw_line<P>(&mut self, p1: P, p2: P, col: Color)
where P: Into<Vec2d<i32>>,

Draw a line between two points, You don’t need to do anything with the points for it to work, it will swap them it needed.
Source§

fn draw_rect<P>(&mut self, pos: P, size: P, col: Color)
where P: Into<Vec2d<i32>>,

Draw a rectangle with the top left corner at (x, y) and the bottom right corner at (x + w, y + h) (both inclusive)
Source§

fn fill_rect<P>(&mut self, pos: P, size: P, col: Color)
where P: Into<Vec2d<i32>>,

Fill a rectangle with the top left corner at (x, y) and the bottom right corner at (x + w, y + h) (both inclusive)
Source§

fn draw_circle<P>(&mut self, pos: P, r: u32, col: Color)
where P: Into<Vec2d<i32>>,

Draw a circle with center (x, y) and raduis r
Source§

fn fill_circle<P>(&mut self, pos: P, r: u32, col: Color)
where P: Into<Vec2d<i32>>,

Fill a circle with center (x, y) and raduis r
Source§

fn draw_triangle<P>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
where P: Into<Vec2d<i32>>,

Draw the edges of a triangle between the three points
Source§

fn fill_triangle<P>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
where P: Into<Vec2d<i32>>,

Fill the given triangle
Source§

impl<T> SpriteTrait for T

Source§

fn draw_sprite<P>( &mut self, pos: P, scale: u32, sprite: &Sprite, flip: (bool, bool), )
where P: Into<Vec2d<i32>>,

Draw a Sprite with the top left corner at (x, y) the flip arguement will allow fliping of the axis flip: (horizontal, vertical) scale is the scale of the result (must be >= 1)
Source§

fn draw_partial_sprite<P>( &mut self, coords: P, sprite: &Sprite, o: P, size: P, scale: u32, flip: (bool, bool), )
where P: Into<Vec2d<i32>>,

Draw a chunk of the given Sprite onto the Target coords is the top left corner of the Target o is the Top left corner of the Sprite Chunk and size is the (width, height) of the chunk flip and scale is the same as SpriteTrait::draw_sprite()
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>