Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally draw and update sprites #64

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ pub trait Game {
fn draw_fps(&self) -> bool {
false
}

fn draw_and_update_sprites(&self) -> bool {
true
}
}

pub type GamePtr<T> = Box<T>;
Expand Down Expand Up @@ -145,11 +149,16 @@ impl<T: 'static + Game> GameRunner<T> {
Err(err) => log_to_console!("Error in update: {}", err),
_ => (),
}
match SpriteManager::get_mut().update_and_draw_sprites() {
Err(err) => {
log_to_console!("Error from sprite_manager.update_and_draw_sprites: {}", err)
if game.draw_and_update_sprites() {
match SpriteManager::get_mut().update_and_draw_sprites() {
Err(err) => {
log_to_console!(
"Error from sprite_manager.update_and_draw_sprites: {}",
err
)
}
_ => (),
}
_ => (),
}
if game.draw_fps() {
match System::get().draw_fps(0, 0) {
Expand Down