pub struct Game<S: Resource + Send + Sync + 'static> { /* private fields */ }
Expand description
A Game
represents the entire game and its data.
By default the game will spawn an empty window, and exit upon Esc or closing of the window.
Under the hood, Rusty Engine syncs the game data to Bevy to power
most of the underlying functionality.
Game
forwards method calls to Engine
when it can, so you should be able to use all
of the methods from Engine
on Game
during your game setup in your main()
function.
Implementations§
Source§impl<S: Resource + Send + Sync + 'static> Game<S>
impl<S: Resource + Send + Sync + 'static> Game<S>
Sourcepub fn window_settings(&mut self, window: Window) -> &mut Self
pub fn window_settings(&mut self, window: Window) -> &mut Self
Use this to set properties of the native OS window before running the game. See the window example for more information.
Sourcepub fn add_logic(&mut self, logic_function: fn(&mut Engine, &mut S))
pub fn add_logic(&mut self, logic_function: fn(&mut Engine, &mut S))
logic_function
is a function or closure that takes two parameters and returns nothing:
engine: &mut Engine
game_state
, which is a mutable reference (&mut
) to the game state struct you defined, or&mut ()
if you didn’t define one.
Methods from Deref<Target = Engine>§
Sourcepub fn add_sprite<T: Into<String>, P: Into<PathBuf>>(
&mut self,
label: T,
file_or_preset: P,
) -> &mut Sprite
pub fn add_sprite<T: Into<String>, P: Into<PathBuf>>( &mut self, label: T, file_or_preset: P, ) -> &mut Sprite
Create and add a Sprite
to the game. Use the &mut Sprite
that is returned to adjust
the translation, rotation, etc. Use a unique label for each sprite. Attempting to add two
sprites with the same label will cause a crash.
Trait Implementations§
Auto Trait Implementations§
impl<S> !Freeze for Game<S>
impl<S> !RefUnwindSafe for Game<S>
impl<S> Send for Game<S>
impl<S> !Sync for Game<S>
impl<S> Unpin for Game<S>
impl<S> !UnwindSafe for Game<S>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.