td

animations.rs at [1c4f2f89eb]
Login

animations.rs at [1c4f2f89eb]

File src/animations.rs artifact 4700724f07 part of check-in 1c4f2f89eb


use macroquad::{
    color::{Color, GREEN, RED},
    math::Vec2,
    shapes::{draw_circle, draw_rectangle},
    text::draw_text,
};

use crate::world::{CENTER_X, CENTER_Y};

#[derive(Debug, Clone, Copy)]
pub enum AnimationTypes {
    EnemeyDeathAnimation,
}

#[derive(Debug, Clone)]
pub struct Animation {
    pub duration: f32,
    pub elapsed: f32,
    pub pos: Vec2,
    pub kind: AnimationTypes,
    pub id: u64,
}

impl Animation {
    pub fn animate(&self) {
        match self.kind {
            AnimationTypes::EnemeyDeathAnimation => animate_enemy_death(self),
        }
    }
}

fn animate_enemy_death(animation: &Animation) {
    let normalized = (animation.duration - animation.elapsed) / (animation.duration);
    let radius = 10.0;
    let blue: Color = Color::new(normalized, 0.47, 0.95, 1.00);
    draw_circle(animation.pos.x, animation.pos.y, radius, blue);
}

fn draw_weapon_crate() {
    draw_rectangle(CENTER_X + 40., CENTER_Y + 10., 30.0, 10.0, GREEN);
}