Struct nitro::App
[−]
[src]
pub struct App { pub input: Input, pub camera: Camera, pub world: World<f32>, pub audio: Audio, // some fields omitted }
This structure represents a game instance.
This structure is responsible for managing asset loading, processing input, rendering the game and playing audio.
Fields
input: Input
camera: Camera
world: World<f32>
audio: Audio
Methods
impl App
[src]
fn new(name: &str) -> App
Constructs a new App using the given name for the window title.
fn run(&mut self)
Begin execution of the game.
This function won't return until the game has been quit.
fn quit(&mut self)
Exit the game
Signals that it's time to quit. Execution will stop at the end of the current frame.
fn camera(&self) -> &Camera
fn camera_mut(&mut self) -> &mut Camera
fn world_mouse_pos(&self) -> Vector
fn new_gameobject<F>(&mut self, f: F) -> u64 where
F: FnOnce(&mut App, &mut GameObject),
F: FnOnce(&mut App, &mut GameObject),
Creates a new GameObject
GameObjects are typically physical objects in your game world, such as characters or decorative objects.
Parameter f will be called on the newly created GameObject, allowing you to initialize it. Returns the id of the new GameObject, which can be used to retrieve this GameObject later.
fn game_object_by_id(&self, id: u64) -> OptionLoaned<&GameObject>
Retrieves a reference to an existing GameObject by the GameObject's id.
Returns Away if and only if the GameObject exists but is currently loaned out in another borrow.
Hint: That borrow is most likely in the game_object parameter of the receive_message function.
fn game_object_by_id_mut(&mut self, id: u64) -> OptionLoaned<&mut GameObject>
Retrieves a mutable reference to an existing GameObject by the GameObject's id.
Returns Away if and only if the GameObject exists but is currently loaned out in another borrow.
Hint: That borrow is most likely in the game_object parameter of the receive_message function.
fn fetch_texture(&mut self, texture_name: &str) -> Result<Texture, String>
Loads a texture and returns it for use.
texture_name is the file name of the texture relative to assets/textures (assets\textures on Windows)