#include "Entities.hpp" #include "Components.hpp" #include "EnergyBarRaygui.hpp" #include "raylib-cpp.hpp" #include "raylib.h" #include std::shared_ptr CreateProbe() { auto e = std::make_shared(); auto &transform = e->AddComponent(); transform.x = 96.0f; transform.y = 230.0f; e->AddComponent(); auto &physics = e->AddComponent(); physics.vx = 16.0f; physics.vy = 0.0f; physics.speedCap = 8192.0f; auto &collider = e->AddComponent(); collider.radius = 7.0f; collider.monitorable = true; auto &probeState = e->AddComponent(); probeState.spawnX = 96.0f; probeState.spawnY = 230.0f; probeState.spawnVx = 165.0f; probeState.spawnVy = 0.0f; e->AddComponent(); e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } const Color PROBE_COLOR = Color{120, 210, 255, 255}; const Color PROBE_HIGHLIGHT = Color{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); }; return e; } std::shared_ptr CreateGravityWell() { auto e = std::make_shared(); auto &transform = e->AddComponent(); transform.x = 96.0f; transform.y = 230.0f; auto &well = e->AddComponent(); well.mass = 0.0f; well.minDist = 28.0f; return e; } std::shared_ptr CreateBlackHole(float x, float y) { auto e = std::make_shared(); auto &transform = e->AddComponent(); transform.x = x; transform.y = y; auto &scrollable = e->AddComponent(); scrollable.worldX = x; auto &well = e->AddComponent(); well.mass = static_cast(1 << 21); well.minDist = 24.0f; well.controlledByMouse = false; well.alwaysActive = true; // shader removed: previously used for black hole lensing auto &collider = e->AddComponent(); collider.radius = 18.0f; e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } 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}); }; return e; } std::shared_ptr CreatePlayerBlackHole(float worldX, float y, float scrollX, float ttl) { auto e = std::make_shared(); auto &transform = e->AddComponent(); transform.x = worldX - scrollX; transform.y = y; auto &scrollable = e->AddComponent(); scrollable.worldX = worldX; auto &well = e->AddComponent(); well.mass = static_cast(1 << 22); well.minDist = 28.0f; well.controlledByMouse = false; well.alwaysActive = true; // shader removed: previously used for black hole lensing auto &lifetime = e->AddComponent(); lifetime.remaining = ttl; // Mark this as a player-created black hole so it can be removed via right-click e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } auto lifetime = e->GetComponent(); if (!lifetime) { return; } 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}); }; return e; } std::shared_ptr CreateStar(float x, float y) { auto e = std::make_shared(); auto &t = e->AddComponent(); t.x = x; t.y = y; auto &scrollable = e->AddComponent(); scrollable.worldX = x; auto &collider = e->AddComponent(); collider.radius = 20.0f; e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); 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); }; return e; } std::shared_ptr CreateAsteroid(float x, float y) { auto e = std::make_shared(); auto &t = e->AddComponent(); t.x = x; t.y = y; auto &scrollable = e->AddComponent(); scrollable.worldX = x; auto &collider = e->AddComponent(); collider.radius = 13.0f; e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } DrawCircleV({transform->get().x, transform->get().y}, 13.0f, Color{116, 126, 142, 255}); }; return e; } std::shared_ptr CreateDebris(float x, float y, float vx, float vy, float ttl) { auto e = std::make_shared(); auto &t = e->AddComponent(); t.x = x; t.y = y; auto &physics = e->AddComponent(); physics.vx = vx; physics.vy = vy; physics.speedCap = 260.0f; auto &lifetime = e->AddComponent(); lifetime.remaining = ttl; auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } DrawCircleV({transform->get().x, transform->get().y}, 3.0f, Color{245, 196, 104, 220}); }; return e; } std::shared_ptr CreateNullZone(float x, float width) { auto e = std::make_shared(); auto &t = e->AddComponent(); t.x = x; auto &scrollable = e->AddComponent(); scrollable.worldX = x; auto &nullZone = e->AddComponent(); nullZone.width = width; auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); auto zone = e->GetComponent(); if (!transform || !zone) { return; } 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}); }; return e; } std::shared_ptr CreateWorld() { auto e = std::make_shared(); e->AddComponent(); e->AddComponent(); return e; } std::shared_ptr CreateStats() { auto e = std::make_shared(); e->AddComponent(); auto &audio = e->AddComponent(); audio.volume = 0.6f; audio.Load("assets/audio/ping.wav"); auto &render = e->AddComponent(); render.draw = [e]() { auto stats = e->GetComponent(); if (!stats) { return; } const float ratio = std::clamp(stats->get().value / stats->get().maxValue, 0.0f, 1.0f); DrawHud(ratio, stats->get().GetStarCount()); }; return e; }