[][src]Struct crystal_engine::GameState

pub struct GameState {
    pub camera: Matrix4<f32>,
    pub keyboard: KeyboardState,
    pub light: LightState,
    // some fields omitted
}

Contains the game state. This struct is passed to Game::init and Game::update.

Fields

camera: Matrix4<f32>

The matrix of the camera currently in use.

It is currently not possible to change the near and far boundaries of the camera. This might be added in a later version.

keyboard: KeyboardState

Get the current keyboard state.

light: LightState

The state of the lights currently in the world.

Implementations

impl GameState[src]

pub fn window(&self) -> &Window[src]

Get a reference to the winit window. This can be used to set the title with set_title, grap the cursor with set_cursor_grab and set_cursor_visible, and more.

pub fn set_cursor_position<P: Pixel>(&self, position: (P, P))[src]

Set the cursor position. This is short for:

state.window()
     .set_cursor_position(winit::dpi::PhysicalPosition::new(0u32, 0u32))
     .unwrap();

Platform-specific

On iOS this always returns an error, so this function is empty

pub fn terminate_game(&mut self)[src]

Exit the game. Once this function is called, it cannot be cancelled. This does not confirm with Game::can_shutdown.

pub fn new_triangle_model(&mut self) -> ModelBuilder[src]

Create a new triangle at the origin of the world.

See ModelHandle for information on how to move, rotate and clone the triangle.

Note: you must store the handle somewhere. When the handle is dropped, the rectangle is removed from your world and resources are unloaded.

Example

let triangle: ModelHandle = game_state.new_triangle_model()
    .build();

pub fn new_rectangle_model(&mut self) -> ModelBuilder[src]

Create a new rectangle at the origin of the world. This can be useful to render simple textures in the world.

See ModelHandle for information on how to move, rotate and clone the rectangle.

Note: you must store the handle somewhere. When the handle is dropped, the rectangle is removed from your world and resources are unloaded.

Example

let rust_logo: ModelHandle = game_state.new_rectangle_model()
    .with_texture_from_file("assets/rust_logo.png")
    .build();

pub fn new_obj_model<'a>(&'a mut self, path: &'a str) -> ModelBuilder<'a>[src]

Load a model from the given path and place it at the origin of the world. See ModelHandle for information on how to move, rotate and clone the model.

This method is only available when the format-obj feature is enabled.

pub fn new_fbx_model<'a>(&'a mut self, path: &'a str) -> ModelBuilder<'a>[src]

Load a model from the given path and place it at the origin of the world. See ModelHandle for information on how to move, rotate and clone the model.

This method is only available when the format-fbx feature is enabled.

Auto Trait Implementations

impl !RefUnwindSafe for GameState

impl !Send for GameState

impl !Sync for GameState

impl Unpin for GameState

impl !UnwindSafe for GameState

Blanket Implementations

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

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

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

impl<T> Content for T[src]

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

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

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

impl<T> SetParameter for T

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.