fight monsters, collect artifacts
This commit is contained in:
19
src/level.rs
19
src/level.rs
@@ -45,8 +45,8 @@ impl Level {
|
||||
discovered: [[false; LEVEL_HEIGHT]; LEVEL_WIDTH],
|
||||
monsters: Vec::with_capacity(10),
|
||||
artifacts: Vec::with_capacity(10),
|
||||
start: (0,0),
|
||||
end: (0,0),
|
||||
start: (0, 0),
|
||||
end: (0, 0),
|
||||
}
|
||||
}
|
||||
pub fn get_element(&mut self, x: i16, y: i16) -> (Option<StructureElement>, Option<&mut Monster>, Option<&mut Box<(dyn Artifact + 'static)>>) {
|
||||
@@ -172,6 +172,21 @@ impl Level {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&mut self) {
|
||||
for (index, a) in &mut self.artifacts.iter().enumerate() {
|
||||
if a.was_collected() {
|
||||
self.artifacts.remove(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (index, m) in &mut self.monsters.iter().enumerate() {
|
||||
if m.is_dead() {
|
||||
self.monsters.remove(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user