86 lines
3.1 KiB
C++
86 lines
3.1 KiB
C++
#include "Components.hpp"
|
|
#include "Draw.hpp"
|
|
#include "Entities.hpp"
|
|
#include "Entity.hpp"
|
|
#include "Systems.hpp"
|
|
|
|
#include "raylib-cpp.hpp"
|
|
|
|
int main() {
|
|
raylib::Window window(700, 460, "Gravity Surfing");
|
|
window.SetState(FLAG_WINDOW_RESIZABLE);
|
|
window.SetTargetFPS(60);
|
|
|
|
std::vector<std::shared_ptr<Entity>> entities;
|
|
entities.reserve(20);
|
|
|
|
entities.push_back(CreateWorld());
|
|
entities.push_back(CreateGravityWell());
|
|
entities.push_back(CreateProbe());
|
|
entities.push_back(CreateStar(900.0f, 120.0f));
|
|
entities.push_back(CreateAsteroid(1100.0f, 330.0f));
|
|
entities.push_back(CreateNullZone(1280.0f, 70.0f));
|
|
entities.push_back(CreateHUD());
|
|
|
|
while (!window.ShouldClose()) {
|
|
float dt = window.GetFrameTime();
|
|
|
|
UpdateAllSystems(entities, dt);
|
|
|
|
auto worldScroll = entities[0]->GetComponent<ScrollComponent>();
|
|
auto wellTransform = entities[1]->GetComponent<TransformComponent>();
|
|
auto probeTransform = entities[2]->GetComponent<TransformComponent>();
|
|
auto starTransform = entities[3]->GetComponent<TransformComponent>();
|
|
auto asteroidTransform = entities[4]->GetComponent<TransformComponent>();
|
|
auto nullTransform = entities[5]->GetComponent<TransformComponent>();
|
|
auto nullZone = entities[5]->GetComponent<NullZoneComponent>();
|
|
|
|
window.BeginDrawing();
|
|
window.ClearBackground(raylib::Color(11, 15, 26, 255));
|
|
|
|
DrawSceneOutline();
|
|
|
|
raylib::DrawText("Gravity Surfing", 14, 12, 20, raylib::Color::RayWhite());
|
|
|
|
if (worldScroll) {
|
|
// debug readout for early loop validation
|
|
raylib::DrawText(TextFormat("scrollX: %.2f", worldScroll->get().scrollX), 14, 40, 16,
|
|
raylib::Color(125, 225, 205, 255));
|
|
}
|
|
|
|
if (probeTransform) {
|
|
const auto &probe = probeTransform->get();
|
|
::DrawCircleV({probe.x, probe.y}, 7.0f, raylib::Color(250, 244, 227, 255));
|
|
raylib::DrawText(TextFormat("probe: (%.1f, %.1f)", probe.x, probe.y), 14, 60, 16,
|
|
raylib::Color(235, 215, 125, 255));
|
|
}
|
|
|
|
if (wellTransform) {
|
|
const auto &well = wellTransform->get();
|
|
::DrawCircleLines(static_cast<int>(well.x), static_cast<int>(well.y), 18.0f,
|
|
raylib::Color(86, 197, 255, 255));
|
|
}
|
|
|
|
if (starTransform) {
|
|
const auto &star = starTransform->get();
|
|
::DrawCircleV({star.x, star.y}, 6.0f, raylib::Color(255, 223, 86, 255));
|
|
}
|
|
|
|
if (asteroidTransform) {
|
|
const auto &asteroid = asteroidTransform->get();
|
|
::DrawCircleV({asteroid.x, asteroid.y}, 13.0f, raylib::Color(116, 126, 142, 255));
|
|
}
|
|
|
|
if (nullTransform && nullZone) {
|
|
const auto &zone = nullTransform->get();
|
|
const int width = static_cast<int>(nullZone->get().width);
|
|
::DrawRectangle(static_cast<int>(zone.x), 0, width, GetScreenHeight(),
|
|
raylib::Color(96, 64, 146, 80));
|
|
}
|
|
|
|
window.EndDrawing();
|
|
}
|
|
|
|
return 0;
|
|
}
|