From 6e958debf0b4b44c8c17f10d978719e48a0786da Mon Sep 17 00:00:00 2001 From: frank <420@shampoo.ooo> Date: Thu, 16 Jun 2022 16:46:17 -0400 Subject: [PATCH] added velocity to delta helper function --- lib/sb | 2 +- src/Pepy.cpp | 9 +++++---- src/Pepy.hpp | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/sb b/lib/sb index ee119ec..3444afc 160000 --- a/lib/sb +++ b/lib/sb @@ -1 +1 @@ -Subproject commit ee119ecc7e4287838cec5aac127820d4738de17f +Subproject commit 3444afc2c1291814d97efb94ca8aecb6e6698c40 diff --git a/src/Pepy.cpp b/src/Pepy.cpp index 960bd76..51dbf56 100644 --- a/src/Pepy.cpp +++ b/src/Pepy.cpp @@ -115,18 +115,19 @@ void Pepy::respond(SDL_Event& event) { /* Will check if reset should be triggered */ bool reset = false; - /* Check for any direction when waiting to reset */ + /* Check for any direction key when waiting to reset */ if (stopped && delegate.compare(event, {"up", "down", "left", "right"})) { reset = true; } + /* Check mouse buttons for grabbing */ if (event.type == SDL_MOUSEBUTTONDOWN) { if (shaking) { grabbed = true; } - /* Mouse button will trigger reset when stopped */ + /* Mouse button will trigger reset when game is waiting to reset */ else if (stopped) { reset = true; @@ -136,7 +137,7 @@ void Pepy::respond(SDL_Event& event) { grabbed = false; } - /* Reset to countdown */ + /* Reset to cuckoo time */ if (reset) { float size = configuration()["sim"]["ball-scale"]; @@ -251,7 +252,7 @@ void Pepy::update() ball.second.x = angle + glm::half_pi(); } } - glm::vec2 step {glm::sin(ball.second.x) * ball.second.y, -glm::cos(ball.second.x) * ball.second.y}; + glm::vec2 step = sb::velocity_to_delta(ball.second); ball.first.transformation(glm::translate(glm::vec3{step.x, step.y, 0.0f}) * ball.first.transformation()); if (ball.second.y > 0) { diff --git a/src/Pepy.hpp b/src/Pepy.hpp index 7010756..b1c2fed 100644 --- a/src/Pepy.hpp +++ b/src/Pepy.hpp @@ -3,7 +3,7 @@ #ifndef PEPY_H_ #define PEPY_H_ -/* Enable swizzling in GLM */ +/* GLM */ #define GLM_ENABLE_EXPERIMENTAL #include #include @@ -11,6 +11,7 @@ /* [SPACE BOX] headers */ #include "Game.hpp" #include "VBO.hpp" +#include "math.hpp" /* Project headers */ #include "Model.hpp"