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
impl Engine
Sourcepub fn get_mouse_btn(&self, btn: MouseBtn) -> Input
pub fn get_mouse_btn(&self, btn: MouseBtn) -> Input
Get the status of a Mouse Button
Sourcepub fn get_mouse_location(&self) -> Vu2d
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
Sourcepub fn get_mouse_wheel(&self) -> MouseWheel
pub fn get_mouse_wheel(&self) -> MouseWheel
Get the scroll wheel direction (If Any) during the frame
Sourcepub fn get_pressed(&self) -> HashSet<Keycodes>
pub fn get_pressed(&self) -> HashSet<Keycodes>
Get all Keys pressed during the last frame
Sourcepub fn get_held(&self) -> HashSet<Keycodes>
pub fn get_held(&self) -> HashSet<Keycodes>
Get all the keys that were held during the last frame
Sourcepub fn get_released(&self) -> HashSet<Keycodes>
pub fn get_released(&self) -> HashSet<Keycodes>
Get all the keys that were released during the last frame
Sourcepub fn create_decal(&mut self, sprite: &Sprite) -> Decal
pub fn create_decal(&mut self, sprite: &Sprite) -> Decal
Create a GPU version of Sprite
Sourcepub fn clear_input_buffer(&mut self)
pub fn clear_input_buffer(&mut self)
Will clear the input buffer and set the cursor to 0
Sourcepub fn set_input_buffer(&mut self, value: impl AsRef<str>)
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
Sourcepub fn insert_input_buffer(&mut self, value: impl AsRef<str>)
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
Sourcepub fn append_input_buffer(&mut self, value: impl AsRef<str>)
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
Sourcepub fn add_input_passthrough(
&mut self,
iterator: impl Iterator<Item = Keycodes>,
)
pub fn add_input_passthrough( &mut self, iterator: impl Iterator<Item = Keycodes>, )
Add keys onto the input pass through list
Sourcepub fn remove_input_passthrough(
&mut self,
iterator: impl Iterator<Item = Keycodes>,
)
pub fn remove_input_passthrough( &mut self, iterator: impl Iterator<Item = Keycodes>, )
Remove keys onto the input pass through list
Sourcepub fn set_input_passthrough(
&mut self,
iterator: impl Iterator<Item = Keycodes>,
)
pub fn set_input_passthrough( &mut self, iterator: impl Iterator<Item = Keycodes>, )
Set the input to the iterator
Sourcepub fn set_ignore_passthrough_chars(&mut self, val: bool)
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
Sourcepub fn get_input_buffer(&self) -> &str
pub fn get_input_buffer(&self) -> &str
Return a view into the input buffer
Sourcepub fn get_input_cursor(&self) -> usize
pub fn get_input_cursor(&self) -> usize
Return the input cursor
Sourcepub fn start_input(&mut self)
pub fn start_input(&mut self)
Switch to text input mode, return true if it wasn’t in this mode before
Sourcepub fn force_stop_input_mode(&mut self)
pub fn force_stop_input_mode(&mut self)
This will clear the input buffer, reset the input cursor and stop the input mode
Sourcepub fn is_in_input_mode(&self) -> bool
pub fn is_in_input_mode(&self) -> bool
Is the engine in input mode
Sourcepub fn end_input_mode(&mut self) -> &str
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 DecalDraw for Engine
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,
)
fn draw_explicit_decal<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], uv: [P; 4], decal: &Decal, tint: Color, )
Source§fn draw_decal<P: Into<Vf2d> + Copy>(&mut self, pos: P, decal: &Decal)
fn draw_decal<P: Into<Vf2d> + Copy>(&mut self, pos: P, decal: &Decal)
Source§fn draw_decal_scaled<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
scale: P,
)
fn draw_decal_scaled<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, scale: P, )
Source§fn draw_partial_decal<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
source_pos: P,
source_size: P,
)
fn draw_partial_decal<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, source_pos: P, source_size: P, )
Source§fn draw_partial_decal_scaled<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
source_pos: P,
source_size: P,
scale: P,
)
fn draw_partial_decal_scaled<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, source_pos: P, source_size: P, scale: P, )
Source§fn draw_warped_decal<P: Into<Vf2d> + Copy>(
&mut self,
pos: [P; 4],
decal: &Decal,
)
fn draw_warped_decal<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], decal: &Decal, )
Source§fn draw_warped_partial_decal<P: Into<Vf2d> + Copy>(
&mut self,
pos: [P; 4],
source_pos: P,
source_size: P,
decal: &Decal,
)
fn draw_warped_partial_decal<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], source_pos: P, source_size: P, decal: &Decal, )
Source§fn draw_rotated_decal<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
angle: f32,
center: P,
)
fn draw_rotated_decal<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, angle: f32, center: P, )
angle
radians around center
center is an offset in pixel from the top left corner of the decalSource§fn draw_rotated_decal_scaled<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
angle: f32,
center: P,
scale: P,
)
fn draw_rotated_decal_scaled<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, angle: f32, center: P, scale: P, )
draw_rotated_decal
but with scalingSource§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,
)
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, )
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,
)
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, )
Source§fn draw_decal_tinted<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
tint: Color,
)
fn draw_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, tint: Color, )
Source§fn draw_decal_scaled_tinted<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
scale: P,
tint: Color,
)
fn draw_decal_scaled_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, scale: P, tint: Color, )
Source§fn draw_partial_decal_tinted<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
source_pos: P,
source_size: P,
tint: Color,
)
fn draw_partial_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, source_pos: P, source_size: P, tint: Color, )
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,
)
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, )
Source§fn draw_warped_decal_tinted<P: Into<Vf2d> + Copy>(
&mut self,
pos: [P; 4],
decal: &Decal,
tint: Color,
)
fn draw_warped_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: [P; 4], decal: &Decal, tint: Color, )
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,
)
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, )
Source§fn draw_rotated_decal_tinted<P: Into<Vf2d> + Copy>(
&mut self,
pos: P,
decal: &Decal,
center: P,
angle: f32,
tint: Color,
)
fn draw_rotated_decal_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, center: P, angle: f32, tint: Color, )
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,
)
fn draw_rotated_decal_scaled_tinted<P: Into<Vf2d> + Copy>( &mut self, pos: P, decal: &Decal, center: P, angle: f32, scale: P, tint: Color, )
Source§impl DrawSpriteTrait for Engine
impl DrawSpriteTrait for Engine
Source§impl SmartDrawingTrait for Engine
impl SmartDrawingTrait for Engine
Source§fn draw<P: Into<Vi2d>>(&mut self, pos: P, col: Color)
fn draw<P: Into<Vi2d>>(&mut self, pos: P, col: Color)
PixelMode
Source§fn set_pixel_mode(&mut self, mode: PixelMode)
fn set_pixel_mode(&mut self, mode: PixelMode)
PixelMode
Source§fn get_pixel<P: Into<Vi2d>>(&self, pos: P) -> Option<Color>
fn get_pixel<P: Into<Vi2d>>(&self, pos: P) -> Option<Color>
Source§fn set_blend_factor(&mut self, f: f32)
fn set_blend_factor(&mut self, f: f32)
Source§fn get_textsheet(&self) -> &'static Sprite
fn get_textsheet(&self) -> &'static Sprite
Sprite
)Source§fn get_pixel_mode(&self) -> PixelMode
fn get_pixel_mode(&self) -> PixelMode
PixelMode
Source§fn get_blend_factor(&self) -> f32
fn get_blend_factor(&self) -> f32
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> DottedShapeTrait for Twhere
T: SmartDrawingTrait,
impl<T> DottedShapeTrait for Twhere
T: SmartDrawingTrait,
Source§fn draw_line_dotted<P>(&mut self, p1: P, p2: P, col: Color, pattern: u32)
fn draw_line_dotted<P>(&mut self, p1: P, p2: P, col: Color, pattern: u32)
Source§fn draw_rect_dotted<P>(&mut self, pos: P, size: P, col: Color, pattern: u32)
fn draw_rect_dotted<P>(&mut self, pos: P, size: P, col: Color, pattern: u32)
(x, y)
and the bottom right corner at (x + w, y + h)
(both inclusive)
This is the dotted formSource§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ShapesTrait for Twhere
T: SmartDrawingTrait,
impl<T> ShapesTrait for Twhere
T: SmartDrawingTrait,
Source§fn draw_text<P>(&mut self, pos: P, scale: u32, col: Color, text: &str)
fn draw_text<P>(&mut self, pos: P, scale: u32, col: Color, text: &str)
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 screenSource§fn draw_line<P>(&mut self, p1: P, p2: P, col: Color)
fn draw_line<P>(&mut self, p1: P, p2: P, col: Color)
Source§fn draw_rect<P>(&mut self, pos: P, size: P, col: Color)
fn draw_rect<P>(&mut self, pos: P, size: P, col: Color)
(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)
fn fill_rect<P>(&mut self, pos: P, size: P, col: Color)
(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)
fn draw_circle<P>(&mut self, pos: P, r: u32, col: Color)
(x, y)
and raduis r
Source§fn fill_circle<P>(&mut self, pos: P, r: u32, col: Color)
fn fill_circle<P>(&mut self, pos: P, r: u32, col: Color)
(x, y)
and raduis r
Source§fn draw_triangle<P>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
fn draw_triangle<P>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
Source§impl<T> SpriteTrait for Twhere
T: SmartDrawingTrait,
impl<T> SpriteTrait for Twhere
T: SmartDrawingTrait,
Source§fn draw_sprite<P>(
&mut self,
pos: P,
scale: u32,
sprite: &Sprite,
flip: (bool, bool),
)
fn draw_sprite<P>( &mut self, pos: P, scale: u32, sprite: &Sprite, flip: (bool, bool), )
(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),
)
fn draw_partial_sprite<P>( &mut self, coords: P, sprite: &Sprite, o: P, size: P, scale: u32, flip: (bool, bool), )
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()