From 85551cf669662cab535b5b77c2c7e749f1ea05af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82?= <pwalig03@gmail.com>
Date: Fri, 16 Aug 2024 17:51:30 +0200
Subject: [PATCH] Add dash cooldown ui bar

---
 src/player_script.cpp | 10 +++++++++-
 src/player_script.h   |  3 +++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/player_script.cpp b/src/player_script.cpp
index 32d6b66..104563f 100644
--- a/src/player_script.cpp
+++ b/src/player_script.cpp
@@ -14,7 +14,9 @@ std::vector<game::player*> game::player::players;
 game::player::player(const glm::vec3& initial_position, const float& y_rotation) :
 	rb(), col(&rb, this), dir(glm::vec3(0.0f, 0.0f, 1.0f)), floor_normal(VEC3_UP),
 	gun_cooldown(std::bind(&game::player::auto_shoot, this)),
-	l(glm::vec3(initial_position), glm::vec3(25.0f)) {
+	l(glm::vec3(initial_position), glm::vec3(25.0f)),
+	ui_dash_cooldown("../assets/textures/White_Square.png", glm::vec3(0.5f, 0.05f, 0.2f))
+{
 	// set up rigidbody
 	rb.mass = 80.0f;
 	rb.force = physics::gravity * rb.mass;
@@ -57,6 +59,9 @@ game::player::player(const glm::vec3& initial_position, const float& y_rotation)
 
 	// add yourself to players list
 	players.push_back(this);
+
+	// ui
+	ui_dash_cooldown.color.a = 0.5f;
 }
 
 void game::player::start()
@@ -110,6 +115,9 @@ void game::player::update()
 
 	// light
 	this->l.position = this->rb.position;
+
+	//ui
+	ui_dash_cooldown.model_matrix = glm::scale(glm::mat4(1.0f), glm::vec3(0.2f * dash_cooldown.time, 0.005f, 0.1f));
 }
 
 void game::player::damage(int damage, glm::vec3 damage_source_position)
diff --git a/src/player_script.h b/src/player_script.h
index 91e1e6d..ad79c5a 100644
--- a/src/player_script.h
+++ b/src/player_script.h
@@ -9,6 +9,7 @@
 #include <deque>
 #include <weapon.h>
 #include "light.h"
+#include "ui_image.h"
 
 namespace game {
 	class power_cube;
@@ -72,6 +73,8 @@ namespace game {
 		// light
 		renderer::light l;
 
+		ui_system::ui_image ui_dash_cooldown;
+
 	public:
 		float max_speed = 7.0f; // [m/s]
 		float responsiveness = 1.0f; // [m/s^2]