82 lines
2.4 KiB
C++
82 lines
2.4 KiB
C++
#include "Components.hpp"
|
|
#include "Draw.hpp"
|
|
#include "Entities.hpp"
|
|
#include "Entity.hpp"
|
|
#include "GameContext.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);
|
|
|
|
GameContext context;
|
|
|
|
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, context, dt);
|
|
|
|
auto worldScroll = entities[0]->GetComponent<ScrollComponent>();
|
|
auto probeTransform = entities[2]->GetComponent<TransformComponent>();
|
|
auto hudMeter = entities.back()->GetComponent<MeterComponent>();
|
|
|
|
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();
|
|
raylib::DrawText(TextFormat("probe: (%.1f, %.1f)", probe.x, probe.y), 14, 60, 16,
|
|
raylib::Color(235, 215, 125, 255));
|
|
}
|
|
|
|
if (hudMeter) {
|
|
raylib::DrawText(TextFormat("meter: %.1f", hudMeter->get().value), 14, 80, 16,
|
|
raylib::Color(120, 210, 190, 255));
|
|
}
|
|
|
|
for (auto &entity : entities) {
|
|
if (!entity) {
|
|
continue;
|
|
}
|
|
|
|
auto collectible = entity->GetComponent<CollectibleComponent>();
|
|
if (collectible && collectible->get().collected) {
|
|
continue;
|
|
}
|
|
|
|
auto render = entity->GetComponent<RenderComponent>();
|
|
if (render) {
|
|
render->get().Draw();
|
|
}
|
|
}
|
|
|
|
window.EndDrawing();
|
|
}
|
|
|
|
return 0;
|
|
}
|