Struct EngineWrapper

Source
pub struct EngineWrapper(/* private fields */);
Expand description

A Wrapper around an Engine

Implementations§

Source§

impl EngineWrapper

Source

pub async fn new(title: String, size: (u32, u32, u32)) -> Self

Create the Engine and the Wrapper

Source

pub fn new_sync(title: String, size: (u32, u32, u32)) -> Self

Create the Engine and the Wrapper

Source

pub fn run_init<G: Game + 'static>(self) -> !

This will first create the game instance, then run the main loop of the game

Source

pub fn run<G: Game + 'static>(self, game: G) -> !

The core of your program, This takes an already existing implementation of a Game G

Methods from Deref<Target = 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 EngineWrapper

Source§

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

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

impl Deref for EngineWrapper

Source§

type Target = Engine

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for EngineWrapper

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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>