Better AOE animation

This commit is contained in:
Evan Pratten 2021-04-24 18:32:08 -04:00
parent 9493baedf5
commit 99e7e02d0c

View File

@ -169,18 +169,27 @@ impl Player {
// Calculate AOE ring // Calculate AOE ring
if self.is_stun_gun_active() { if self.is_stun_gun_active() {
let aoe_ring = calculate_linear_slide( let animation_progression =
self.attacking_timer / self.inventory.stun_gun.as_ref().unwrap().duration, self.attacking_timer / self.inventory.stun_gun.as_ref().unwrap().duration;
) as f32; let aoe_ring = calculate_linear_slide(animation_progression) as f32;
self.attacking_timer = (self.attacking_timer - dt).max(0.0); self.attacking_timer = (self.attacking_timer - dt).max(0.0);
// Render attack AOE // Render attack AOE
context_2d.draw_circle_lines( if animation_progression <= 0.5 {
self.position.x as i32, context_2d.draw_circle_lines(
self.position.y as i32, self.position.x as i32,
self.inventory.stun_gun.as_ref().unwrap().range * aoe_ring, self.position.y as i32,
TRANSLUCENT_WHITE_64, self.inventory.stun_gun.as_ref().unwrap().range * aoe_ring,
); TRANSLUCENT_WHITE_64,
);
} else {
context_2d.draw_circle_lines(
self.position.x as i32,
self.position.y as i32,
self.inventory.stun_gun.as_ref().unwrap().range,
TRANSLUCENT_WHITE_64.fade(aoe_ring),
);
}
} }
// Render the player based on what is happening // Render the player based on what is happening