Skip to content

Commit

Permalink
Merge pull request #64 from lyonbeckers/optional-sprite-drawing
Browse files Browse the repository at this point in the history
Optionally draw and update sprites
  • Loading branch information
boozook authored Sep 13, 2023
2 parents 48b1efa + fca2628 commit a1e9fb7
Showing 1 changed file with 13 additions and 4 deletions.
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

0 comments on commit a1e9fb7

Please sign in to comment.