Skip to content
Snippets Groups Projects
Commit 965f9462 authored by radow's avatar radow
Browse files

foe hit highlight

parent 3d68fdb5
Branches
No related tags found
No related merge requests found
...@@ -270,6 +270,7 @@ impl GameState { ...@@ -270,6 +270,7 @@ impl GameState {
self.grant_xp(ctx); self.grant_xp(ctx);
} else { } else {
enemy.hp -= damage; enemy.hp -= damage;
enemy.hit = true;
self.current_run.combat_log.player_action = Option::from(PlayerAction::Attack(damage, enemy.hp)); self.current_run.combat_log.player_action = Option::from(PlayerAction::Attack(damage, enemy.hp));
self.play_sound_player_attack(ctx); self.play_sound_player_attack(ctx);
} }
...@@ -494,7 +495,13 @@ impl GameState { ...@@ -494,7 +495,13 @@ impl GameState {
Tile::Empty => GameState::draw_tile(self, Color::WHITE, draw_x, draw_y, ctx), Tile::Empty => GameState::draw_tile(self, Color::WHITE, draw_x, draw_y, ctx),
Tile::Wall => GameState::draw_wall(self, draw_x, draw_y, ctx), Tile::Wall => GameState::draw_wall(self, draw_x, draw_y, ctx),
Tile::Player => GameState::draw_player(self, draw_x, draw_y, ctx), Tile::Player => GameState::draw_player(self, draw_x, draw_y, ctx),
Tile::Enemy(_) => GameState::draw_enemy(self, draw_x, draw_y, ctx), Tile::Enemy(id) => {
let mut color = Color::WHITE;
if let Some(enemy) = self.current_run.level.enemies.get_mut(id) {
color = enemy.coloration();
enemy.hit = false;
}
GameState::draw_enemy(self, draw_x, draw_y, ctx, color);},
Tile::Exit => GameState::draw_exit(self, draw_x, draw_y, ctx), Tile::Exit => GameState::draw_exit(self, draw_x, draw_y, ctx),
Tile::Treasure(_, _) => GameState::draw_treasure(self, draw_x, draw_y, ctx), Tile::Treasure(_, _) => GameState::draw_treasure(self, draw_x, draw_y, ctx),
} }
...@@ -623,10 +630,10 @@ impl GameState { ...@@ -623,10 +630,10 @@ impl GameState {
self.draw_texture(&self.textures.player, x, y, Vec2::new(1.15*self.current_run.player.orientation,1.15), 16.0, Color::WHITE, ctx); self.draw_texture(&self.textures.player, x, y, Vec2::new(1.15*self.current_run.player.orientation,1.15), 16.0, Color::WHITE, ctx);
} }
fn draw_enemy(&mut self, x: usize, y: usize, ctx: &mut Context) { fn draw_enemy(&mut self, x: usize, y: usize, ctx: &mut Context, color :Color) {
GameState::draw_tile(self, Color::WHITE, x, y, ctx); GameState::draw_tile(self, Color::WHITE, x, y, ctx);
self.draw_texture(&self.textures.enemy, x, y, Vec2::new(1.15,1.15), 14.0, Color::WHITE, ctx); self.draw_texture(&self.textures.enemy, x, y, Vec2::new(1.15,1.15), 14.0, color, ctx);
} }
fn draw_stats(&self, ctx: &mut Context) { fn draw_stats(&self, ctx: &mut Context) {
......
use tetra::graphics::Color;
pub struct Enemy { pub struct Enemy {
pub hp: usize, pub hp: usize,
pub strength: usize, pub strength: usize,
pub weapon_strength: usize, pub weapon_strength: usize,
pub hit: bool,
} }
impl Enemy { impl Enemy {
...@@ -14,6 +17,13 @@ impl Enemy { ...@@ -14,6 +17,13 @@ impl Enemy {
hp, hp,
strength, strength,
weapon_strength, weapon_strength,
hit: false,
}
}
pub fn coloration(&self)-> Color{
if self.hit{
return Color::RED
} }
return Color::WHITE
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment