cs381/as6/main.cpp

55 lines
1.6 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(CreateHUD());
while (!window.ShouldClose()) {
float dt = window.GetFrameTime();
UpdateAllSystems(entities, dt);
auto worldScroll = entities[0]->GetComponent<ScrollComponent>();
auto probeTransform = entities[2]->GetComponent<TransformComponent>();
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));
}
window.EndDrawing();
}
return 0;
}