Skip to content

Commit

Permalink
Add dash cooldown ui bar
Browse files Browse the repository at this point in the history
  • Loading branch information
pwalig committed Aug 16, 2024
1 parent 802b4f0 commit 85551cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/player_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/player_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <deque>
#include <weapon.h>
#include "light.h"
#include "ui_image.h"

namespace game {
class power_cube;
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 85551cf

Please sign in to comment.