diff --git a/OpenGL/src/Input.cpp b/OpenGL/src/Input.cpp index 056e1015..a21562bf 100644 --- a/OpenGL/src/Input.cpp +++ b/OpenGL/src/Input.cpp @@ -7,8 +7,10 @@ float Input::deltaTime = 0.01; bool Input::keys_pressed[GLFW_KEY_LAST] = {false}; bool Input::keys_pressed_last_frame[GLFW_KEY_LAST] = {false}; bool Input::keys_pressed_down[GLFW_KEY_LAST] = {false}; -bool Input::mouse_pressed = false; -bool Input::mouse_pressed_down = false; +bool Input::left_mouse_pressed = false; +bool Input::left_mouse_pressed_down = false; +bool Input::right_mouse_pressed = false; +bool Input::right_mouse_pressed_down = false; float zeno(float current, float target, float timeConstant) { float alpha = 1.0f - std::exp(-Input::deltaTime / timeConstant); diff --git a/OpenGL/src/Input.h b/OpenGL/src/Input.h index 9c12fb53..3a86235b 100644 --- a/OpenGL/src/Input.h +++ b/OpenGL/src/Input.h @@ -7,8 +7,10 @@ class Input { public: static bool keys_pressed[GLFW_KEY_LAST]; static bool keys_pressed_down[GLFW_KEY_LAST]; - static bool mouse_pressed; - static bool mouse_pressed_down; + static bool left_mouse_pressed; + static bool left_mouse_pressed_down; + static bool right_mouse_pressed; + static bool right_mouse_pressed_down; static float startTime; static float deltaTime; @@ -26,8 +28,10 @@ class Input { keys_pressed_down[key] = !keys_pressed_last_frame[key] && keys_pressed[key]; } - mouse_pressed_down = !mouse_pressed && glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_PRESS; - mouse_pressed = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_PRESS; + left_mouse_pressed_down = !left_mouse_pressed && glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_PRESS; + left_mouse_pressed = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_PRESS; + right_mouse_pressed_down = !right_mouse_pressed && glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_2) == GLFW_PRESS; + right_mouse_pressed = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_2) == GLFW_PRESS; } }; diff --git a/OpenGL/src/game_objects/Bomb.cpp b/OpenGL/src/game_objects/Bomb.cpp index a287d776..d0abfea5 100644 --- a/OpenGL/src/game_objects/Bomb.cpp +++ b/OpenGL/src/game_objects/Bomb.cpp @@ -9,6 +9,7 @@ Bomb::Bomb(const std::string& name, float x, float y) } void Bomb::tickUpdate() { + tintColor.a = zeno(tintColor.a, 0.0, 0.5); // Explode the bomb if (ExplodeTick > 6) { explode(); diff --git a/OpenGL/src/game_objects/Player.cpp b/OpenGL/src/game_objects/Player.cpp index db4acbd4..0f8e3af8 100644 --- a/OpenGL/src/game_objects/Player.cpp +++ b/OpenGL/src/game_objects/Player.cpp @@ -10,7 +10,7 @@ Player::Player(const std::string& name, int tile_x, int tile_y) : Character(name, tile_x, tile_y, "Textures/alternate-player.png") { drawPriority = DrawPriority::Character; - health = 3; + health = 5; Camera::position = {tile_x, tile_y}; healthText = std::make_unique("Health", Renderer::jacquard12_big, glm::vec2{20, 20}); @@ -71,7 +71,7 @@ void Player::update() { void Player::render(Renderer& renderer) { Character::render(renderer); - if (Input::mouse_pressed_down) { + if (Input::left_mouse_pressed_down) { if (gunCooldown == 0) { Renderer::DebugLine(position, renderer.MousePos(), {1, 0, 0, 1}); audio().Zap.play(); @@ -86,6 +86,19 @@ void Player::render(Renderer& renderer) { gunCooldown = playerGunCooldown; } } + if (Input::right_mouse_pressed) { + if (hasSlomo) { + Renderer::DebugLine(position, renderer.MousePos(), {1, 0, 0, 1}); + // get what is at mouse position + for (auto& character : World::at(renderer.MousePos().x + 0.5, renderer.MousePos().y + 0.5)) { + character->tintColor = {1.0, 0.5, 0.0, 0.5}; + } + for (auto& bomb : World::at(renderer.MousePos().x + 0.5, renderer.MousePos().y + 0.5)) { + bomb->tintColor = {1.0, 0.5, 0.0, 0.5}; + } + // need to figure out some way to slow tick rate and also make all things zeno at a fraction of normal speed + } + } } void Player::hurt() { diff --git a/OpenGL/src/game_objects/Player.h b/OpenGL/src/game_objects/Player.h index 7d11185a..95d91618 100644 --- a/OpenGL/src/game_objects/Player.h +++ b/OpenGL/src/game_objects/Player.h @@ -23,4 +23,5 @@ class Player : public Character { // Powerups int playerBunnyHopCoolDown = 6; int playerGunCooldown = 3; + bool hasSlomo = true; }; diff --git a/OpenGL/src/game_objects/SquareObject.cpp b/OpenGL/src/game_objects/SquareObject.cpp index 82a4e793..1a71f7aa 100644 --- a/OpenGL/src/game_objects/SquareObject.cpp +++ b/OpenGL/src/game_objects/SquareObject.cpp @@ -43,4 +43,5 @@ void SquareObject::render(Renderer& renderer) { void SquareObject::update() { position = zeno(position, glm::vec2(tile_x, tile_y), 0.05); + tintColor.a = zeno(tintColor.a, 0.0, 0.3); }