Use raylib-cpp draw calls instead of raylib.h

master
John Montagu, the 4th Earl of Sandvich 2026-03-16 13:36:17 -07:00
parent b74b0dbb9d
commit 15525c2278
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
3 changed files with 38 additions and 25 deletions

View File

@ -17,8 +17,8 @@
#include "raygui.h" #include "raygui.h"
#include "raylib.h" #include "raylib.h"
inline constexpr int WINDOW_WIDTH = 700; inline constexpr float WINDOW_WIDTH = 700;
inline constexpr int WINDOW_HEIGHT = 460; inline constexpr float WINDOW_HEIGHT = 460;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Controls Functions Declaration // Controls Functions Declaration

View File

@ -4,7 +4,6 @@
#include "EnergyBarRaygui.hpp" #include "EnergyBarRaygui.hpp"
#include "raylib-cpp.hpp" #include "raylib-cpp.hpp"
#include "raylib.h"
#include <algorithm> #include <algorithm>
std::shared_ptr<Entity> CreateProbe() { std::shared_ptr<Entity> CreateProbe() {
@ -39,12 +38,12 @@ std::shared_ptr<Entity> CreateProbe() {
return; return;
} }
const Color PROBE_COLOR = Color{120, 210, 255, 255}; const raylib::Color probeColor(120, 210, 255, 255);
const Color PROBE_HIGHLIGHT = Color{255, 255, 255, 120}; const raylib::Color probeHighlight(255, 255, 255, 120);
DrawCircleV({transform->get().x, transform->get().y}, 7.0f, PROBE_COLOR); raylib::Vector2(transform->get().x, transform->get().y).DrawCircle(7.0f, probeColor);
raylib::Vector2(transform->get().x - 1.0f, transform->get().y - 1.0f)
DrawCircleV({transform->get().x - 1, transform->get().y - 1}, 3.0f, PROBE_HIGHLIGHT); .DrawCircle(3.0f, probeHighlight);
}; };
return e; return e;
} }
@ -92,9 +91,10 @@ std::shared_ptr<Entity> CreateBlackHole(float x, float y) {
const int cx = static_cast<int>(transform->get().x); const int cx = static_cast<int>(transform->get().x);
const int cy = static_cast<int>(transform->get().y); const int cy = static_cast<int>(transform->get().y);
DrawCircle(cx, cy, 18.0f, Color{8, 10, 20, 255}); raylib::Vector2(static_cast<float>(cx), static_cast<float>(cy))
DrawCircleLines(cx, cy, 18.0f, Color{70, 95, 170, 240}); .DrawCircle(18.0f, raylib::Color(8, 10, 20, 255));
DrawCircleLines(cx, cy, 24.0f, Color{95, 120, 200, 120}); ::DrawCircleLines(cx, cy, 18.0f, raylib::Color(70, 95, 170, 240));
::DrawCircleLines(cx, cy, 24.0f, raylib::Color(95, 120, 200, 120));
}; };
return e; return e;
@ -138,9 +138,10 @@ std::shared_ptr<Entity> CreatePlayerBlackHole(float worldX, float y, float scrol
const int cx = static_cast<int>(transform->get().x); const int cx = static_cast<int>(transform->get().x);
const int cy = static_cast<int>(transform->get().y); const int cy = static_cast<int>(transform->get().y);
float t = 360 * lifetime->get().remaining / 1; float t = 360 * lifetime->get().remaining / 1;
DrawCircleSector({(float)cx, (float)cy}, 28.0f, 0.0f, t, 32, Color{70, 95, 170, 25}); ::DrawCircleSector({(float)cx, (float)cy}, 28.0f, 0.0f, t, 32,
DrawCircleLines(cx, cy, 18.0f, Color{70, 95, 170, 240}); raylib::Color(70, 95, 170, 25));
DrawCircleLines(cx, cy, 24.0f, Color{95, 120, 200, 120}); ::DrawCircleLines(cx, cy, 18.0f, raylib::Color(70, 95, 170, 240));
::DrawCircleLines(cx, cy, 24.0f, raylib::Color(95, 120, 200, 120));
}; };
return e; return e;
@ -163,12 +164,12 @@ std::shared_ptr<Entity> CreateStar(float x, float y) {
if (!transform) { if (!transform) {
return; return;
} }
Vector2 center = {transform->get().x, transform->get().y}; raylib::Vector2 center(transform->get().x, transform->get().y);
Color STAR_COLOR = Color{255, 223, 86, 255}; const raylib::Color starColor(255, 223, 86, 255);
Color GLOW_COLOR = Color{255, 223, 86, 80}; const raylib::Color glowColor(255, 223, 86, 80);
DrawCircleV(center, 20.0f, GLOW_COLOR); center.DrawCircle(20.0f, glowColor);
DrawPoly(center, 3, 10.0f, transform->get().x, STAR_COLOR); center.DrawPoly(3, 10.0f, transform->get().x, starColor);
DrawPoly(center, 3, 10.0f, transform->get().x + 180, STAR_COLOR); center.DrawPoly(3, 10.0f, transform->get().x + 180.0f, starColor);
}; };
return e; return e;
} }
@ -191,7 +192,8 @@ std::shared_ptr<Entity> CreateAsteroid(float x, float y) {
if (!transform) { if (!transform) {
return; 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; return e;
} }
@ -216,7 +218,8 @@ std::shared_ptr<Entity> CreateDebris(float x, float y, float vx, float vy, float
if (!transform) { if (!transform) {
return; 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; return e;
@ -241,9 +244,9 @@ std::shared_ptr<Entity> CreateNullZone(float x, float width) {
int x = (int)(transform->get().x); int x = (int)(transform->get().x);
DrawRectangle(x, 0, (int)(zone->get().width), GetScreenHeight(), Color{96, 64, 146, 80}); raylib::Color(96, 64, 146, 80)
.DrawRectangle(x, 0, (int)(zone->get().width), raylib::Window::GetHeight());
DrawText("Null Zone", x + 8, 12, 16, Color{96, 64, 146, 200}); raylib::Color(96, 64, 146, 200).DrawText("Null Zone", x + 8, 12, 16);
}; };
return e; return e;
} }

View File

@ -21,4 +21,14 @@ void DeathScene::Draw() {
// Draw centered death stats using the HUD helper // Draw centered death stats using the HUD helper
// collectedStars is a private member; access via this-> to satisfy older compilers / linters // collectedStars is a private member; access via this-> to satisfy older compilers / linters
DrawDeathStats(this->collectedStars); DrawDeathStats(this->collectedStars);
if (GuiButton((Rectangle){WINDOW_WIDTH / 2 - 150, WINDOW_HEIGHT / 2 + 28, 300, 20},
"Main Menu")) {
manager.QueueSceneChange<StartMenuScene>();
}
if (GuiButton((Rectangle){WINDOW_WIDTH / 2 - 150, WINDOW_HEIGHT / 2 + 60, 300, 20},
"Retry")) {
manager.QueueSceneChange<GameplayScene>();
}
} }