xp bar stub

This commit is contained in:
Alula 2020-08-26 03:19:25 +02:00
parent f12a619669
commit f6bba5958f
No known key found for this signature in database
GPG Key ID: 3E00485503A1D8BA
1 changed files with 8 additions and 1 deletions

View File

@ -102,10 +102,16 @@ impl GameScene {
// lv
batch.add_rect(16.0, 32.0,
&Rect::<usize>::new_size(80, 80, 16, 8));
// xp box
batch.add_rect(40.0, 32.0,
&Rect::<usize>::new_size(0, 72, 40, 8));
// experience
//batch.add_rect(40.0, 32.0,
// &Rect::<usize>::new_size(0, 80, (40), 8)); // todo
// life box
batch.add_rect(16.0, 40.0,
&Rect::<usize>::new_size(0, 40, 64, 8));
// bar
// yellow bar
batch.add_rect(40.0, 40.0,
&Rect::<usize>::new_size(0, 32, ((self.life_bar as usize * 40) / self.player.max_life as usize) - 1, 8));
// life
@ -114,6 +120,7 @@ impl GameScene {
batch.draw(ctx)?;
self.draw_number(40.0, 32.0, 0, Alignment::Right, state, ctx)?;
self.draw_number(40.0, 40.0, self.life_bar as usize, Alignment::Right, state, ctx)?;
Ok(())