Skip to main content

GameInstance

Struct GameInstance 

Source
pub struct GameInstance {
    pub fixed_delta_time: f32,
    pub unfocused_fixed_delta_time_scale: f32,
    pub color_shader: &'static str,
    pub image_shader: &'static str,
    pub text_shader: &'static str,
    pub input_maintain_on_fixed_step: bool,
    /* private fields */
}

Fields§

§fixed_delta_time: f32§unfocused_fixed_delta_time_scale: f32§color_shader: &'static str§image_shader: &'static str§text_shader: &'static str§input_maintain_on_fixed_step: bool

Implementations§

Source§

impl GameInstance

Source

pub fn new(state: impl GameState + 'static) -> Self

Examples found in repository?
examples/spine.rs (line 26)
25fn main() -> Result<(), Box<dyn Error>> {
26    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
27        *assets = make_directory_database("./resources/").unwrap();
28    }))
29    .title("Spine 2D")
30    .config(Config::load_from_file("./resources/GameConfig.toml")?)
31    .run();
32    Ok(())
33}
More examples
Hide additional examples
examples/scripting.rs (line 40)
39fn main() -> Result<(), Box<dyn Error>> {
40    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
41        *assets = make_directory_database("./resources/").unwrap();
42    }))
43    .title("Scripting")
44    .config(Config::load_from_file("./resources/GameConfig.toml")?)
45    .run();
46    Ok(())
47}
examples/coroutines.rs (line 29)
28fn main() -> Result<(), Box<dyn Error>> {
29    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
30        *assets = make_directory_database("./resources/").unwrap();
31    }))
32    .title("Coroutines")
33    .config(Config::load_from_file("./resources/GameConfig.toml")?)
34    .run();
35    Ok(())
36}
examples/gc.rs (line 32)
31fn main() -> Result<(), Box<dyn Error>> {
32    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
33        *assets = make_directory_database("./resources/").unwrap();
34    }))
35    .title("GC")
36    .config(Config::load_from_file("./resources/GameConfig.toml")?)
37    .run();
38    Ok(())
39}
examples/path.rs (line 23)
22fn main() -> Result<(), Box<dyn Error>> {
23    GameLauncher::new(GameInstance::new(State::default()).setup_assets(|assets| {
24        *assets = make_directory_database("./resources/").unwrap();
25    }))
26    .title("Path")
27    .config(Config::load_from_file("./resources/GameConfig.toml")?)
28    .run();
29    Ok(())
30}
examples/gltf.rs (line 39)
38fn main() -> Result<(), Box<dyn Error>> {
39    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
40        *assets = make_directory_database("./resources/").unwrap();
41    }))
42    .title("GLTF")
43    .config(Config::load_from_file("./resources/GameConfig.toml")?)
44    .run();
45    Ok(())
46}
Source

pub fn with_editor(self, editor: Editor) -> Self

Examples found in repository?
examples/editable.rs (lines 39-43)
29fn main() -> Result<(), Box<dyn Error>> {
30    GameLauncher::new(
31        GameInstance::new(Preloader)
32            .setup_assets(|assets| {
33                *assets = make_directory_database("./resources/").unwrap();
34            })
35            .setup(|instance| {
36                #[cfg(feature = "editor")]
37                {
38                    use quaso::editor::ui::editor_game_edit;
39                    instance.with_editor(
40                        Editor::default()
41                            .with_gui_drawer(editor_game_edit)
42                            .show_editor_while_running(false),
43                    )
44                }
45                #[cfg(not(feature = "editor"))]
46                instance
47            }),
48    )
49    .title("Editable")
50    .config(Config::load_from_file("./resources/GameConfig.toml")?)
51    .run();
52    Ok(())
53}
Source

pub fn with_fixed_time_step(self, value: f32) -> Self

Source

pub fn with_fps(self, frames_per_second: usize) -> Self

Source

pub fn with_unfocused_fixed_time_step_scale(self, value: f32) -> Self

Examples found in repository?
examples/pcg_island.rs (line 50)
47fn main() -> Result<(), Box<dyn Error>> {
48    GameLauncher::new(
49        GameInstance::new(State::default())
50            .with_unfocused_fixed_time_step_scale(15.0)
51            .setup_assets(|assets| {
52                *assets = make_directory_database("./resources/").unwrap();
53            }),
54    )
55    .title("Procedural Content Generator - Island")
56    .config(Config::load_from_file("./resources/GameConfig.toml")?)
57    .run();
58    Ok(())
59}
Source

pub fn with_color_shader(self, name: &'static str) -> Self

Source

pub fn with_image_shader(self, name: &'static str) -> Self

Source

pub fn with_text_shader(self, name: &'static str) -> Self

Source

pub fn with_input_maintain_on_fixed_step(self, value: bool) -> Self

Source

pub fn with_subsystem(self, subsystem: impl GameSubsystem + 'static) -> Self

Source

pub fn with_globals<T: 'static>(self, value: T) -> Self

Source

pub fn with_jobs(self, jobs: Jobs) -> Self

Source

pub fn with_jobs_unnamed_worker(self, iteration_timeout: Duration) -> Self

Source

pub fn with_jobs_named_worker( self, iteration_timeout: Duration, name: impl ToString, ) -> Self

Source

pub fn with_network(self, network: GameNetwork) -> Self

Source

pub fn with_gamepads(self) -> Self

Source

pub fn with_gamepads_custom(self, gamepads: Gilrs) -> Self

Source

pub fn setup_assets(self, f: impl FnOnce(&mut AssetDatabase)) -> Self

Examples found in repository?
examples/spine.rs (lines 26-28)
25fn main() -> Result<(), Box<dyn Error>> {
26    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
27        *assets = make_directory_database("./resources/").unwrap();
28    }))
29    .title("Spine 2D")
30    .config(Config::load_from_file("./resources/GameConfig.toml")?)
31    .run();
32    Ok(())
33}
More examples
Hide additional examples
examples/scripting.rs (lines 40-42)
39fn main() -> Result<(), Box<dyn Error>> {
40    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
41        *assets = make_directory_database("./resources/").unwrap();
42    }))
43    .title("Scripting")
44    .config(Config::load_from_file("./resources/GameConfig.toml")?)
45    .run();
46    Ok(())
47}
examples/coroutines.rs (lines 29-31)
28fn main() -> Result<(), Box<dyn Error>> {
29    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
30        *assets = make_directory_database("./resources/").unwrap();
31    }))
32    .title("Coroutines")
33    .config(Config::load_from_file("./resources/GameConfig.toml")?)
34    .run();
35    Ok(())
36}
examples/gc.rs (lines 32-34)
31fn main() -> Result<(), Box<dyn Error>> {
32    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
33        *assets = make_directory_database("./resources/").unwrap();
34    }))
35    .title("GC")
36    .config(Config::load_from_file("./resources/GameConfig.toml")?)
37    .run();
38    Ok(())
39}
examples/path.rs (lines 23-25)
22fn main() -> Result<(), Box<dyn Error>> {
23    GameLauncher::new(GameInstance::new(State::default()).setup_assets(|assets| {
24        *assets = make_directory_database("./resources/").unwrap();
25    }))
26    .title("Path")
27    .config(Config::load_from_file("./resources/GameConfig.toml")?)
28    .run();
29    Ok(())
30}
examples/gltf.rs (lines 39-41)
38fn main() -> Result<(), Box<dyn Error>> {
39    GameLauncher::new(GameInstance::new(Preloader).setup_assets(|assets| {
40        *assets = make_directory_database("./resources/").unwrap();
41    }))
42    .title("GLTF")
43    .config(Config::load_from_file("./resources/GameConfig.toml")?)
44    .run();
45    Ok(())
46}
Source

pub fn setup(self, f: impl FnOnce(Self) -> Self) -> Self

Examples found in repository?
examples/editable.rs (lines 35-47)
29fn main() -> Result<(), Box<dyn Error>> {
30    GameLauncher::new(
31        GameInstance::new(Preloader)
32            .setup_assets(|assets| {
33                *assets = make_directory_database("./resources/").unwrap();
34            })
35            .setup(|instance| {
36                #[cfg(feature = "editor")]
37                {
38                    use quaso::editor::ui::editor_game_edit;
39                    instance.with_editor(
40                        Editor::default()
41                            .with_gui_drawer(editor_game_edit)
42                            .show_editor_while_running(false),
43                    )
44                }
45                #[cfg(not(feature = "editor"))]
46                instance
47            }),
48    )
49    .title("Editable")
50    .config(Config::load_from_file("./resources/GameConfig.toml")?)
51    .run();
52    Ok(())
53}
Source

pub fn fps(&self) -> usize

Source

pub fn set_fps(&mut self, frames_per_second: usize)

Source

pub fn process_frame(&mut self, graphics: &mut Graphics<Vertex>)

Source

pub fn process_event(&mut self, event: &Event<'_, ()>) -> bool

Trait Implementations§

Source§

impl AppState<Vertex> for GameInstance

Source§

fn on_init(&mut self, _graphics: &mut Graphics<Vertex>, _: &mut AppControl)

Source§

fn on_redraw(&mut self, graphics: &mut Graphics<Vertex>, _: &mut AppControl)

Source§

fn on_event(&mut self, event: Event<'_, ()>, _: &mut Window) -> bool

Source§

impl Default for GameInstance

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> Finalize for T

Source§

unsafe fn finalize_raw(data: *mut ())

Drops the value stored at data in place. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Initialize for T
where T: Default,

Source§

fn initialize() -> T

Returns the initial value of this type.
Source§

unsafe fn initialize_raw(data: *mut ())

Writes the initial value into already allocated memory. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more