Switch from specs to hecs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c0ce37aa38
commit
d9606e8b87
27 changed files with 514 additions and 673 deletions
27
src/resources/stats.rs
Normal file
27
src/resources/stats.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
pub struct Stats {
|
||||
pub score: u32,
|
||||
pub gems: u32,
|
||||
pub whips: u32,
|
||||
pub whip_power: u32,
|
||||
pub teleports: u32,
|
||||
pub keys: u32,
|
||||
}
|
||||
|
||||
type PlayerSurvived = bool;
|
||||
|
||||
impl Stats {
|
||||
pub fn take_gems(&mut self, num_gems: u32) -> PlayerSurvived {
|
||||
let new_num_gems = self.gems as i64 - num_gems as i64;
|
||||
if new_num_gems <= 0 {
|
||||
self.gems = 0;
|
||||
false
|
||||
} else {
|
||||
self.gems = new_num_gems as u32;
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_score(&mut self, score: u32) {
|
||||
self.score += score;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue