pub struct Game {
pub name: String,
pub author: String,
pub graphics: Graphics,
pub audio: Audio,
pub resource_manager: Arc<Mutex<ResourceManager>>,
}Expand description
Main game struct
Holds basic metadata and a reference to the graphics subsystem.
User must create a Game in order to feed it to the EventHandler
Fields§
§name: StringHuman-readable game title.
Author or owner of the game.
graphics: GraphicsGraphics subsystem used to render frames.
audio: AudioAudio subsystem
resource_manager: Arc<Mutex<ResourceManager>>Resource management
Implementations§
Source§impl Game
impl Game
Sourcepub fn new(
name: String,
author: String,
graphics: Graphics,
resource_manager: Arc<Mutex<ResourceManager>>,
) -> Game
pub fn new( name: String, author: String, graphics: Graphics, resource_manager: Arc<Mutex<ResourceManager>>, ) -> Game
Create a new Game instance.
§Parameters
name: title of the gameauthor: author/owner namegraphics: initialized graphics subsystem
§Returns
A Game instance ready to be used by an EventHandler.
Examples found in repository?
examples/hello.rs (lines 75-80)
68async fn main() {
69 let resource_manager = Arc::new(Mutex::new(ResourceManager::new()));
70 let graphics = graphics::Graphics::new(
71 String::from("my cool game"),
72 (500, 500),
73 resource_manager.clone(),
74 );
75 let mut game = fennel_engine::Game::new(
76 String::from("my cool game"),
77 String::from("wiltshire"),
78 graphics.unwrap(),
79 resource_manager,
80 );
81 events::run(&mut game, Box::new(State {})).await;
82}Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more