Improvements

This commit is contained in:
Thomas Forgione 2019-03-30 14:36:04 +01:00
parent 93171a5123
commit a00e39e3f5
No known key found for this signature in database
GPG Key ID: BFD17A2D71B3B5E7
2 changed files with 29 additions and 20 deletions

View File

@ -108,9 +108,11 @@ impl Renderer {
} }
for c in scene.characters() { for c in scene.characters() {
if c.is_alive() {
self.draw(c); self.draw(c);
} }
} }
}
/// Triggers the display. /// Triggers the display.
pub fn display(&mut self) { pub fn display(&mut self) {

View File

@ -89,6 +89,10 @@ impl Scene {
let mut state = State::Finished; let mut state = State::Finished;
for c in &mut self.characters { for c in &mut self.characters {
// Don't need to update if the character is dead
if c.is_alive() {
let old = c.bbox(); let old = c.bbox();
// Compute the offset between position and bbox // Compute the offset between position and bbox
@ -112,9 +116,12 @@ impl Scene {
c.fall_off(); c.fall_off();
} }
if c.controls().is_some() && c.is_alive() { // If a character is alive and still have controls, the game should continue
if c.controls().is_some() {
state = State::Running; state = State::Running;
} }
}
} }
state state