#include "tower.h" Sound BEAM_SOUND; tower_t make_tower(int damage, int range, int x, int y, int width, int height, Texture2D *texture){ return (tower_t) { .texture = texture, .damage = damage, .range = range, .position = (Vector2){ x, y }, .size = (Vector2){ width, height }, .center = (Vector2){ x + width / 2, y + height / 2}, .cooldown = 0.0, .cooldown_max = 1.0 }; } tower_beam_t make_beam(Vector2 src, Vector2 dest, float live_time){ return (tower_beam_t){ .src = src, .dest = dest, .live_time = live_time }; } char _tower_cooldown_text[16]; void draw_tower(tower_t *tower){ DrawTexture(*tower->texture, tower->position.x, tower->position.y, WHITE); /* DrawRectangleV(tower->position, tower->size, BLUE); */ DrawCircleLinesV(tower->center, tower->range, LIGHTGRAY); const Vector2 p = tower->position; const Vector2 s = tower->size; DrawRectangle(p.x, p.y - 15, s.x * ((tower->cooldown_max - tower->cooldown) / tower->cooldown_max), 5, BLUE); DrawRectangleLines(p.x, p.y - 15, s.x, 5, BLACK); /* snprintf(_tower_cooldown_text, 16, "%.2f", tower->cooldown); DrawText(_tower_cooldown_text, tower->position.x + (tower->size.x / 2), tower->position.y - 25, 10, LIGHTGRAY); */ } void update_tower(tower_t *t, float dt){ if (t->cooldown > 0){ t->cooldown -= dt; } }