From 15525c227857223afe37e4544fb503bcff461f0c Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Mon, 16 Mar 2026 13:36:17 -0700 Subject: [PATCH] Use raylib-cpp draw calls instead of raylib.h --- as6/EnergyBarRaygui.hpp | 4 ++-- as6/Entities.cpp | 49 +++++++++++++++++++++------------------- as6/scene/DeathScene.cpp | 10 ++++++++ 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/as6/EnergyBarRaygui.hpp b/as6/EnergyBarRaygui.hpp index 4946b70..8ca5c41 100644 --- a/as6/EnergyBarRaygui.hpp +++ b/as6/EnergyBarRaygui.hpp @@ -17,8 +17,8 @@ #include "raygui.h" #include "raylib.h" -inline constexpr int WINDOW_WIDTH = 700; -inline constexpr int WINDOW_HEIGHT = 460; +inline constexpr float WINDOW_WIDTH = 700; +inline constexpr float WINDOW_HEIGHT = 460; //---------------------------------------------------------------------------------- // Controls Functions Declaration diff --git a/as6/Entities.cpp b/as6/Entities.cpp index 9787331..b23f199 100644 --- a/as6/Entities.cpp +++ b/as6/Entities.cpp @@ -4,7 +4,6 @@ #include "EnergyBarRaygui.hpp" #include "raylib-cpp.hpp" -#include "raylib.h" #include std::shared_ptr CreateProbe() { @@ -39,12 +38,12 @@ std::shared_ptr CreateProbe() { return; } - const Color PROBE_COLOR = Color{120, 210, 255, 255}; - const Color PROBE_HIGHLIGHT = Color{255, 255, 255, 120}; + const raylib::Color probeColor(120, 210, 255, 255); + const raylib::Color probeHighlight(255, 255, 255, 120); - DrawCircleV({transform->get().x, transform->get().y}, 7.0f, PROBE_COLOR); - - DrawCircleV({transform->get().x - 1, transform->get().y - 1}, 3.0f, PROBE_HIGHLIGHT); + raylib::Vector2(transform->get().x, transform->get().y).DrawCircle(7.0f, probeColor); + raylib::Vector2(transform->get().x - 1.0f, transform->get().y - 1.0f) + .DrawCircle(3.0f, probeHighlight); }; return e; } @@ -92,9 +91,10 @@ std::shared_ptr CreateBlackHole(float x, float y) { const int cx = static_cast(transform->get().x); const int cy = static_cast(transform->get().y); - DrawCircle(cx, cy, 18.0f, Color{8, 10, 20, 255}); - DrawCircleLines(cx, cy, 18.0f, Color{70, 95, 170, 240}); - DrawCircleLines(cx, cy, 24.0f, Color{95, 120, 200, 120}); + raylib::Vector2(static_cast(cx), static_cast(cy)) + .DrawCircle(18.0f, raylib::Color(8, 10, 20, 255)); + ::DrawCircleLines(cx, cy, 18.0f, raylib::Color(70, 95, 170, 240)); + ::DrawCircleLines(cx, cy, 24.0f, raylib::Color(95, 120, 200, 120)); }; return e; @@ -138,9 +138,10 @@ std::shared_ptr CreatePlayerBlackHole(float worldX, float y, float scrol const int cx = static_cast(transform->get().x); const int cy = static_cast(transform->get().y); float t = 360 * lifetime->get().remaining / 1; - DrawCircleSector({(float)cx, (float)cy}, 28.0f, 0.0f, t, 32, Color{70, 95, 170, 25}); - DrawCircleLines(cx, cy, 18.0f, Color{70, 95, 170, 240}); - DrawCircleLines(cx, cy, 24.0f, Color{95, 120, 200, 120}); + ::DrawCircleSector({(float)cx, (float)cy}, 28.0f, 0.0f, t, 32, + raylib::Color(70, 95, 170, 25)); + ::DrawCircleLines(cx, cy, 18.0f, raylib::Color(70, 95, 170, 240)); + ::DrawCircleLines(cx, cy, 24.0f, raylib::Color(95, 120, 200, 120)); }; return e; @@ -163,12 +164,12 @@ std::shared_ptr CreateStar(float x, float y) { if (!transform) { return; } - Vector2 center = {transform->get().x, transform->get().y}; - Color STAR_COLOR = Color{255, 223, 86, 255}; - Color GLOW_COLOR = Color{255, 223, 86, 80}; - DrawCircleV(center, 20.0f, GLOW_COLOR); - DrawPoly(center, 3, 10.0f, transform->get().x, STAR_COLOR); - DrawPoly(center, 3, 10.0f, transform->get().x + 180, STAR_COLOR); + raylib::Vector2 center(transform->get().x, transform->get().y); + const raylib::Color starColor(255, 223, 86, 255); + const raylib::Color glowColor(255, 223, 86, 80); + center.DrawCircle(20.0f, glowColor); + center.DrawPoly(3, 10.0f, transform->get().x, starColor); + center.DrawPoly(3, 10.0f, transform->get().x + 180.0f, starColor); }; return e; } @@ -191,7 +192,8 @@ std::shared_ptr CreateAsteroid(float x, float y) { if (!transform) { return; } - DrawCircleV({transform->get().x, transform->get().y}, 13.0f, Color{116, 126, 142, 255}); + raylib::Vector2(transform->get().x, transform->get().y) + .DrawCircle(13.0f, raylib::Color(116, 126, 142, 255)); }; return e; } @@ -216,7 +218,8 @@ std::shared_ptr CreateDebris(float x, float y, float vx, float vy, float if (!transform) { return; } - DrawCircleV({transform->get().x, transform->get().y}, 3.0f, Color{245, 196, 104, 220}); + raylib::Vector2(transform->get().x, transform->get().y) + .DrawCircle(3.0f, raylib::Color(245, 196, 104, 220)); }; return e; @@ -241,9 +244,9 @@ std::shared_ptr CreateNullZone(float x, float width) { int x = (int)(transform->get().x); - DrawRectangle(x, 0, (int)(zone->get().width), GetScreenHeight(), Color{96, 64, 146, 80}); - - DrawText("Null Zone", x + 8, 12, 16, Color{96, 64, 146, 200}); + raylib::Color(96, 64, 146, 80) + .DrawRectangle(x, 0, (int)(zone->get().width), raylib::Window::GetHeight()); + raylib::Color(96, 64, 146, 200).DrawText("Null Zone", x + 8, 12, 16); }; return e; } diff --git a/as6/scene/DeathScene.cpp b/as6/scene/DeathScene.cpp index 1978d49..6334b00 100644 --- a/as6/scene/DeathScene.cpp +++ b/as6/scene/DeathScene.cpp @@ -21,4 +21,14 @@ void DeathScene::Draw() { // Draw centered death stats using the HUD helper // collectedStars is a private member; access via this-> to satisfy older compilers / linters DrawDeathStats(this->collectedStars); + + if (GuiButton((Rectangle){WINDOW_WIDTH / 2 - 150, WINDOW_HEIGHT / 2 + 28, 300, 20}, + "Main Menu")) { + manager.QueueSceneChange(); + } + + if (GuiButton((Rectangle){WINDOW_WIDTH / 2 - 150, WINDOW_HEIGHT / 2 + 60, 300, 20}, + "Retry")) { + manager.QueueSceneChange(); + } }