Struct nitro::App
[−]
[src]
pub struct App { pub input: Input, pub camera: Camera, pub world: World<f32>, pub audio: Audio, pub screen_to_world_ratio: f32, pub cull_padding: u32, // 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
screen_to_world_ratio: f32
How many pixels = 1 game world unit. Defaults to 100.
cull_padding: u32
Distance in pixels from screen at which an object won't be drawn. Defaults to 750.
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, profiling: bool)
Begin execution of the game.
This function won't return until the game has been quit. If profiling is true then additional information on game processing durations will be printed to console.
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)