Control-universe Vampire Survivors-like horde survivor (C++23 + CMake + raylib 6.2 via FetchContent). - sim/render split: raylib-free core/game, deterministic 60 Hz tick, PCG32 seeds - RoR2-style corruption scaling + credit spawn director (too-cheap rule) - 4 Objects of Power weapons with levels 1-4 and Altered Form evolutions - VS-style Board Directive drafts, damage numbers, brutalist diorama presenter - docs: game design, art direction, technical design, roadmap Milestones M0-M2 complete and validated (250 enemies @ 60 fps stress capture).
140 lines
5.2 KiB
C++
140 lines
5.2 KiB
C++
// FBC: NIGHT SHIFT — entry point.
|
|
// Owns the window, the fixed 60 Hz tick, and the raylib<->sim translation.
|
|
// Everything else lives in src/game (simulation) and src/render (presentation).
|
|
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
|
|
#include "raylib.h"
|
|
|
|
#include "game/game.hpp"
|
|
#include "render/presenter.hpp"
|
|
#include "render/ui.hpp"
|
|
|
|
namespace {
|
|
|
|
constexpr float kFixedDt = 1.0f / 60.0f;
|
|
|
|
struct Options {
|
|
std::uint64_t seed = 0xC0FFEEULL;
|
|
const char* screenshot_path = nullptr; // --screenshot <path>: capture the framebuffer
|
|
float screenshot_at = 3.0f; // --screenshot-at <sec>: when to capture
|
|
const char* screenshot_on_levelup = nullptr; // capture when the Directive cards appear
|
|
bool bot = false; // --bot: kiting autopilot (M6 balance-bot seed)
|
|
bool no_damage = false; // --no-damage: stress-test mode
|
|
};
|
|
|
|
Options parse_options(int argc, char** argv) {
|
|
Options opts;
|
|
for (int i = 1; i < argc; ++i) {
|
|
if (std::strcmp(argv[i], "--seed") == 0 && i + 1 < argc) {
|
|
opts.seed = std::strtoull(argv[i + 1], nullptr, 10);
|
|
} else if (std::strcmp(argv[i], "--screenshot") == 0 && i + 1 < argc) {
|
|
opts.screenshot_path = argv[i + 1];
|
|
} else if (std::strcmp(argv[i], "--screenshot-at") == 0 && i + 1 < argc) {
|
|
opts.screenshot_at = static_cast<float>(std::atof(argv[i + 1]));
|
|
} else if (std::strcmp(argv[i], "--screenshot-on-levelup") == 0 && i + 1 < argc) {
|
|
opts.screenshot_on_levelup = argv[i + 1];
|
|
} else if (std::strcmp(argv[i], "--bot") == 0) {
|
|
opts.bot = true;
|
|
} else if (std::strcmp(argv[i], "--no-damage") == 0) {
|
|
opts.no_damage = true;
|
|
}
|
|
}
|
|
return opts;
|
|
}
|
|
|
|
InputState read_input(const Game& game, bool bot) {
|
|
InputState in;
|
|
if (bot) {
|
|
// Kiting autopilot: seek the nearest shard, repel enemies that get close,
|
|
// dash when cornered, pick the first Directive. Drives itself.
|
|
if (game.state == GameState::LevelUp) {
|
|
in.levelup_choice = 0;
|
|
return in;
|
|
}
|
|
Vec2 goal = game.player.pos;
|
|
float best = 1e9f;
|
|
for (const XpShard& s : game.pickup_system.shards) {
|
|
const float d = distance(s.pos, game.player.pos);
|
|
if (d < best) { best = d; goal = s.pos; }
|
|
}
|
|
Vec2 dir = normalized(goal - game.player.pos);
|
|
float nearest_enemy = 1e9f;
|
|
for (const Enemy& e : game.enemy_system.enemies) {
|
|
const float d = distance(e.pos, game.player.pos);
|
|
nearest_enemy = std::min(nearest_enemy, d);
|
|
if (d < 3.5f) dir += normalized(game.player.pos - e.pos) * (3.5f - d) * 0.8f;
|
|
}
|
|
if (length_sq(dir) > 1.0f) dir = normalized(dir);
|
|
in.move_x = dir.x;
|
|
in.move_y = dir.y;
|
|
in.dash = nearest_enemy < 2.0f;
|
|
return in;
|
|
}
|
|
in.move_x = (IsKeyDown(KEY_D) ? 1.0f : 0.0f) - (IsKeyDown(KEY_A) ? 1.0f : 0.0f);
|
|
in.move_y = (IsKeyDown(KEY_S) ? 1.0f : 0.0f) - (IsKeyDown(KEY_W) ? 1.0f : 0.0f);
|
|
in.dash = IsKeyPressed(KEY_LEFT_SHIFT) || IsKeyPressed(KEY_SPACE);
|
|
in.restart = IsKeyPressed(KEY_R);
|
|
if (IsKeyPressed(KEY_ONE)) in.levelup_choice = 0;
|
|
if (IsKeyPressed(KEY_TWO)) in.levelup_choice = 1;
|
|
if (IsKeyPressed(KEY_THREE)) in.levelup_choice = 2;
|
|
return in;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main(int argc, char** argv) {
|
|
SetTraceLogLevel(LOG_WARNING);
|
|
InitWindow(1280, 720, "FBC: NIGHT SHIFT — pre-alpha grey-box");
|
|
SetTargetFPS(60);
|
|
|
|
const Options opts = parse_options(argc, argv);
|
|
Game game(opts.seed);
|
|
game.config.no_player_damage = opts.no_damage;
|
|
Presenter presenter;
|
|
presenter.init();
|
|
|
|
float accumulator = 0.0f;
|
|
bool screenshot_taken = false;
|
|
while (!WindowShouldClose()) {
|
|
accumulator += GetFrameTime();
|
|
if (accumulator > 0.25f) accumulator = 0.25f; // avoid spiral of death
|
|
|
|
while (accumulator >= kFixedDt) {
|
|
game.update(read_input(game, opts.bot), kFixedDt);
|
|
accumulator -= kFixedDt;
|
|
}
|
|
|
|
BeginDrawing();
|
|
ClearBackground(Color{24, 24, 27, 255});
|
|
presenter.draw_scene(game);
|
|
ui::draw_all(game);
|
|
EndDrawing();
|
|
|
|
// Dev tools: --screenshot <path> [--screenshot-at <sec>] captures the
|
|
// framebuffer (works regardless of compositor/window visibility);
|
|
// --screenshot-on-levelup <path> catches the Directive cards;
|
|
// F12 saves one on demand.
|
|
if (opts.screenshot_path != nullptr && !screenshot_taken
|
|
&& static_cast<float>(GetTime()) >= opts.screenshot_at) {
|
|
TakeScreenshot(opts.screenshot_path);
|
|
screenshot_taken = true;
|
|
}
|
|
if (opts.screenshot_on_levelup != nullptr && !screenshot_taken
|
|
&& game.state == GameState::LevelUp) {
|
|
TakeScreenshot(opts.screenshot_on_levelup);
|
|
screenshot_taken = true;
|
|
}
|
|
if (IsKeyPressed(KEY_F12)) TakeScreenshot("screenshot.png");
|
|
|
|
// The presenter has consumed this frame's sim events.
|
|
game.events.clear();
|
|
}
|
|
|
|
presenter.shutdown();
|
|
CloseWindow();
|
|
return 0;
|
|
}
|