From 1ce793c6e8c4e3e53f3410ee136a4ef23ad8250d Mon Sep 17 00:00:00 2001 From: Jan Mrna Date: Sun, 12 Oct 2025 16:09:12 +0200 Subject: [PATCH] Fixed selection rectangle glitch --- cpp/src/gameloop.cpp | 2 +- cpp/src/pathfindingdemo.cpp | 1 + cpp/src/window.cpp | 4 +--- cpp/src/window.hpp | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cpp/src/gameloop.cpp b/cpp/src/gameloop.cpp index d2db912..4cf4097 100644 --- a/cpp/src/gameloop.cpp +++ b/cpp/src/gameloop.cpp @@ -57,7 +57,7 @@ void GameLoop::Draw() { if (m_Game->IsSelectionBoxActive()) { const auto& [corner_pos, size] = m_Game->GetSelectionBoxPosSize(); - m_Window->DrawRect(corner_pos, size, 200, 20, 20, 100); + m_Window->DrawRect(corner_pos, size, 200, 20, 20); } diff --git a/cpp/src/pathfindingdemo.cpp b/cpp/src/pathfindingdemo.cpp index f82c41c..47631cd 100644 --- a/cpp/src/pathfindingdemo.cpp +++ b/cpp/src/pathfindingdemo.cpp @@ -207,6 +207,7 @@ void PathFindingDemo::HandleActions(const std::vector &actions) { m_SelectionBox.active = true; m_SelectionBox.start = action.Argument.position; + m_SelectionBox.end = action.Argument.position; } else if (action.type == UserAction::Type::SELECTION_END) { diff --git a/cpp/src/window.cpp b/cpp/src/window.cpp index d1675f9..3a60fc4 100644 --- a/cpp/src/window.cpp +++ b/cpp/src/window.cpp @@ -91,12 +91,10 @@ void Window::DrawFilledRect(const WindowPos &position, const WindowSize size, ui SDL_RenderFillRect(m_Renderer.get(), &rect); } -void Window::DrawRect(const WindowPos &position, const WindowSize size, uint8_t R, - uint8_t G, uint8_t B, uint8_t fill_alpha) { +void Window::DrawRect(const WindowPos &position, const WindowSize size, uint8_t R, uint8_t G, uint8_t B) { SDL_FRect rect = {position.x(), position.y(), size.x(), size.y()}; SDL_SetRenderDrawColor(m_Renderer.get(), R, G, B, 255); SDL_RenderRect(m_Renderer.get(), &rect); - //SDL_RenderFillRect(m_Renderer.get(), &rect); } void Window::ClearWindow() { diff --git a/cpp/src/window.hpp b/cpp/src/window.hpp index a34566c..49391c5 100644 --- a/cpp/src/window.hpp +++ b/cpp/src/window.hpp @@ -25,8 +25,7 @@ public: void DrawSprite(const WindowPos &position, Sprite &s, float scale = 1.0f); void DrawFilledRect(const WindowPos &position, const WindowSize size, uint8_t R, uint8_t G, uint8_t B, uint8_t A); - void DrawRect(const WindowPos &position, const WindowSize size, uint8_t R, - uint8_t G, uint8_t B, uint8_t fill_alpha); + void DrawRect(const WindowPos &position, const WindowSize size, uint8_t R, uint8_t G, uint8_t B); void ClearWindow(); void Flush(); void DrawCircle(const WindowPos &position, float radius);