Struct GameControl

Source
pub struct GameControl { /* private fields */ }
Expand description

Main context, for controlling the game while it is running. You don’t normally need to create this yourself as Gameloop::new() does this for you, but it can be useful to create this directly if you need to run automated tests.

Implementations§

Source§

impl GameControl

Source

pub fn new_headless(gameinfo: &GameInfo) -> Result<GameControl, InitError>

Creates a GameControl in a headless configuration, allowing you to run automated tests, validation, or other processes without needing a gameloop, window, renderer, or audio.

Source

pub fn input(&self) -> &Input

Retrieves the Input object for reading player input such as keyboard, mouse, and gamepad.

Source

pub fn input_mut(&mut self) -> &mut Input

Retrieves the Input object mutably for changing input bindings and deadzones

Source

pub fn renderer(&self) -> &Renderer

Retrieves the Renderer object to read various parameters for the renderer window

Source

pub fn renderer_mut(&mut self) -> &mut Renderer

Retrieves the Renderer object mutably to change various parameters for the renderer window

Source

pub fn audio(&self) -> &Box<dyn Audio>

Retrieves the Audio object for reading information about audio playback

Source

pub fn audio_mut(&mut self) -> &mut Box<dyn Audio>

Retrieves the Audio object mutably to control audio playback

Source

pub fn source_manager(&self) -> Rc<RefCell<SourceManager>>

Retrieves the SourceManager for registering and querying data Sources

Source

pub fn res(&self) -> &DataMultistore

Retrieves the DataMultistore for accessing data resources

Source

pub fn singleton_mut<T: 'static + GameSingleton + Default>(&mut self) -> &mut T

Retrieves the GameSingleton of the current type mutably. If it has not been created yet, it will be Default-constructed.

Source

pub fn target_framerate(&self) -> f64

Returns the framerate that game logic is synchronized to, in frames per second

Source

pub fn set_target_framerate(&mut self, new_framerate: f64)

Sets the framerate that game logic is synchronized to, in frames per second

Source

pub fn frame_interpolation(&self) -> FrameInterpolationMode

Returns the mode to use for interpolating frames in the renderer.

Source

pub fn set_frame_interpolation(&mut self, mode: FrameInterpolationMode)

Sets the mode to use for interpolating frames in the renderer.

Source

pub fn frame_interpolation_cap(&self) -> FrameInterpolationCap

Returns the framerate cap mode for when frame interpolation is enabled.

Source

pub fn set_frame_interpolation_cap(&mut self, cap: FrameInterpolationCap)

Sets the framerate cap mode for when frame interpolation is enabled.

Source

pub fn frame_interpolation_pacing(&self) -> FrameInterpolationPacing

Returns the framerate pacing mode for when frame interpolation is enabled.

Source

pub fn set_frame_interpolation_pacing( &mut self, pacing: FrameInterpolationPacing, )

Sets the framerate pacing mode for when frame interpolation is enabled.

Source

pub fn frame_interpolation_active(&self) -> bool

Returns true if frame interpolation is currently active. For the automatic mode, returns true if the refresh rate of the window’s current monitor does not match with the target logic framerate.

Source

pub fn console_history(&self) -> MutexGuard<'_, ConsoleHistory>

Retrieves the ConsoleHistory object, which is useful for implementing an in-game console window

Source

pub fn stats(&self) -> &GameStats

Retrieves the GameStats object, which contains timing statistics

Source

pub fn goto_new_scene<T: SceneType + 'static>(&mut self)

Switches the game to a new scene of the given SceneType after the current frame is done. Doing this will perform automatic unloading of unused data resources (ones without an active crate::datapack::DataHandle or crate::datapack::PackageUseToken) if it is configured to do so via the GameInfo passed in during creation of the Gameloop or GameControl.

Source

pub fn quit(&mut self)

Leaves the main gameloop. This usually means closing the game.

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 for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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> Same for T

Source§

type Output = T

Should always be Self
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> Erased for T