[][src]Struct pixel_engine::Engine

pub struct Engine<'a> {
    pub name: String,
    pub size: (u32, u32, u32),
    pub screen: Window,
    pub elapsed: f64,
    pub main: &'a dyn Fn(&mut Engine) -> Result<(), String>,
    // some fields omitted
}

The core of this library Engine handle the backend of drawing and deals with sdl2

Fields

name: String

The name the engine

size: (u32, u32, u32)

The size of the Window, formated (width,height,pixel_size)

screen: Window

The window , where the drawing methods are

elapsed: f64

the time elapsed between the start of this frame and the old one

main: &'a dyn Fn(&mut Engine) -> Result<(), String>

The user code run by the Engine

Methods

impl<'a> Engine<'a>[src]

pub fn new(
    name: &str,
    size: (u32, u32, u32),
    main: &'a dyn Fn(&mut Engine) -> Result<(), String>
) -> Result<Engine<'a>, String>
[src]

Create a new game Engine

pub fn new_frame(&mut self) -> Result<bool, String>[src]

The core of the engine, where crucial value are calculated, like elapsed or the key's vector

pub fn start(&mut self) -> Result<(), String>[src]

Start the engine, lanch the "main" function

pub fn get_key_state(&self, key: Keycode) -> KeyState[src]

Return the state of "key" via KeyState enum

pub fn get_pressed(&self) -> HashSet<Keycode>[src]

Return a clone of the vector conataining pressed keys

pub fn get_held(&self) -> HashSet<Keycode>[src]

Return a clone of the vector conataining held keys

pub fn get_released(&self) -> HashSet<Keycode>[src]

Return a clone of the vector conataining released keys

pub fn is_pressed(&self, key: Keycode) -> bool[src]

Return true if "key" is pressed this frame, else, return false

pub fn is_held(&self, key: Keycode) -> bool[src]

Return true if "key" is held this frame, else, return false

pub fn is_released(&self, key: Keycode) -> bool[src]

Return true if "key" is released this frame, else , return false

Trait Implementations

impl<'a> Debug for Engine<'a>[src]

Auto Trait Implementations

impl<'a> Unpin for Engine<'a>

impl<'a> !Sync for Engine<'a>

impl<'a> !Send for Engine<'a>

impl<'a> !UnwindSafe for Engine<'a>

impl<'a> !RefUnwindSafe for Engine<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]