FBC: NIGHT SHIFT - active skills with autoplay

Add CONCRETE CALL (J) and WARP (K) as player-triggered skills that also autoplay when no skill keys are pressed. Includes cooldown HUD stamps, target telegraphs, warp pull/collapse VFX, a generic SkillSystem, Blender-enhanced concrete rubble, and regression tests.
This commit is contained in:
dandovlatov 2026-11-24 22:53:07 +04:00
parent fa36042493
commit 763301b50f
17 changed files with 668 additions and 6 deletions

View file

@ -46,12 +46,18 @@ set(GAME_SIM_SOURCES
src/game/enemies.cpp
src/game/weapons.cpp
src/game/pickups.cpp
src/game/skills.cpp
src/game/game.cpp)
add_executable(player_movement_test tests/player_movement_test.cpp ${GAME_SIM_SOURCES})
target_link_libraries(player_movement_test PRIVATE level_core)
add_dependencies(player_movement_test bake_level)
add_test(NAME player_movement_through_enemy_contact COMMAND player_movement_test)
add_executable(skills_test tests/skills_test.cpp ${GAME_SIM_SOURCES})
target_link_libraries(skills_test PRIVATE level_core)
add_dependencies(skills_test bake_level)
add_test(NAME concrete_call_skill COMMAND skills_test)
set(LEVEL_JSON ${CMAKE_SOURCE_DIR}/assets/levels/floor01.json)
set(BAKED_HPP ${CMAKE_SOURCE_DIR}/src/game/level_baked.hpp)
add_custom_command(
@ -96,6 +102,7 @@ add_executable(cntrl
src/game/enemies.cpp
src/game/weapons.cpp
src/game/pickups.cpp
src/game/skills.cpp
src/game/game.cpp
src/render/presenter.cpp
src/render/dressing.cpp

View file

@ -9,6 +9,11 @@ the player is not Jesse.)
**Signature mechanic:** reach an Object of Power's ritual — complete it, and it
becomes your permanent skill for the run (Mega Man structure, Control skin).
Active skills — CONCRETE CALL (`[J]`, hurls rubble at a crowd) and WARP
(`[K]`, magnetizes enemies together before collapsing them) — also **autoplay**
when the player isn't pressing their keys; pressing one takes manual control
briefly, and `[L]` switches autoplay off entirely. The HUD stamps show both
cooldowns and the shared mode.
**Difficulty:** Risk of Rain 2-style continuous *Corruption* scaling — the clock is the
enemy. See `docs/GAME_DESIGN.md`.
@ -141,6 +146,9 @@ set `CNTRL_LEVEL` to import a different level file.
| WASD | Move |
| Stick (XInput/GLFW, M7) | Move |
| Shift / Space | Dash (*Evade*) |
| J / gamepad Y | CONCRETE CALL — hurl a pile of concrete at the nearest crowd |
| K / gamepad B | WARP — magnetize enemies together, then collapse them |
| L / gamepad Back | Toggle skill autoplay (AUTO / MANUAL / OFF on the HUD stamps) |
| R | Restart run (on death) |
| Esc | Quit |

Binary file not shown.

Binary file not shown.

View file

@ -116,6 +116,18 @@ means "fires on cooldown" (auto-implemented, like Vampire Survivors); disabled
means dormant. There is no separate hotkey-driven skill wheel to open during
the run — toggling happens in the OoP loadout (HUD).
**Active skills** are a separate, keyed layer: CONCRETE CALL (`J` / gamepad Y)
gathers a heap of concrete at the agent and throws it at the nearest enemy
crowd (6 s cooldown, 3.4 m blast, brief ground telegraph at the landing zone).
**WARP** (`K` / gamepad B) grabs the nearest crowd, drags every enemy in a 4.5 m
field together over 0.75 s, then collapses the field for 75 damage (9 s
cooldown, teal containment rings telegraph the collapse).
Every active skill also **autoplays** when the player hasn't pressed its key
recently — a manual press takes control for a few seconds, then autoplay
resumes; `[L]` disables autoplay for players who want fully manual skills.
New active skills join the same `SkillSystem` cast/autoplay path, so the
no-button playstyle keeps working.
## 3. Corruption — Risk of Rain 2 progressive difficulty, FBC skin
The clock is the enemy. The longer you loot, the more the House decays. RoR2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 629 KiB

After

Width:  |  Height:  |  Size: 574 KiB

View file

@ -10,6 +10,8 @@ enum class EventType {
WeaponFired,
AreaDetonation,
PlayerDamaged,
SkillCast, // pos = target, magnitude = radius, flags = skill index
WarpBurst, // warp field collapses; pos = centre, magnitude = radius
ShardCollected,
TierUp,
KeyAcquired,

View file

@ -108,6 +108,7 @@ void apply_offer(Game& g, const Offer& o) {
Game::Game(std::uint64_t seed, const std::string& level_path)
: floor(level_path), rng(seed), seed_(seed) {
weapon_system.reset();
skill_system.reset();
ritual_system.init(floor);
player.pos = floor.spawn();
}
@ -127,6 +128,7 @@ void Game::reset() {
for (bool& claimed : side_reward_claimed_) claimed = false;
enemy_system.clear();
weapon_system.reset();
skill_system.reset();
pickup_system.clear();
corruption = Corruption{};
director = Director{};
@ -184,6 +186,7 @@ void Game::update(const InputState& in, float dt) {
player.pos = floor.resolve(player.pos, 0.45f);
if (config.no_player_damage) player.hp = player.stats.max_hp; // stress mode
weapon_system.update(dt, player, enemy_system, events, rng, floor);
skill_system.update(dt, in, player, enemy_system, events);
if (length_sq({in.move_x, in.move_y}) < 1e-4f && !in.dash) idle_time += dt;
else idle_time = 0.0f;
@ -245,6 +248,9 @@ void Game::floor_pass() {
events.push(EventType::FloorCleared, floor.door_pos(),
static_cast<float>(floor_number));
enemy_system.clear();
// Don't carry active skill fields across the floor jump.
skill_system.piles.clear();
skill_system.warps.clear();
pickup_system.clear();
buff_system = BuffSystem{};
ritual_system = RitualSystem{};

View file

@ -15,6 +15,7 @@
#include "game/pickups.hpp"
#include "game/player.hpp"
#include "game/ritual.hpp"
#include "game/skills.hpp"
#include "game/weapons.hpp"
enum class GameState { Title, Playing, GameOver };
@ -50,6 +51,7 @@ public:
Player player;
EnemySystem enemy_system;
WeaponSystem weapon_system;
SkillSystem skill_system; // player-triggered / autoplayed active skills
PickupSystem pickup_system;
BuffSystem buff_system;
Corruption corruption;

View file

@ -6,5 +6,8 @@ struct InputState {
float move_x = 0.0f; // -1..1 (screen axes: +x right, +y down/"south")
float move_y = 0.0f;
bool dash = false; // one-shot
bool skill_concrete = false; // one-shot: CONCRETE CALL (J / gamepad Y)
bool skill_warp = false; // one-shot: WARP (K / gamepad B)
bool toggle_autoplay = false; // one-shot (L / gamepad Back)
bool restart = false; // one-shot
};

232
src/game/skills.cpp Normal file
View file

@ -0,0 +1,232 @@
#include "game/skills.hpp"
#include <algorithm>
#include <cmath>
#include <cstddef>
#include "core/events.hpp"
#include "core/spatial_hash.hpp"
#include "game/enemies.hpp"
#include "game/player.hpp"
namespace {
constexpr float kConcreteCooldown = 6.0f;
constexpr float kWarpCooldown = 9.0f;
constexpr float kWarpDuration = 0.75f;
constexpr float kWarpRadius = 4.5f;
constexpr float kWarpDamage = 75.0f;
constexpr float kWarpPull = 7.0f;
constexpr float kGatherTime = 0.38f;
constexpr float kFlightSpeed = 17.0f;
constexpr float kBlastRadius = 3.4f;
constexpr float kBlastDamage = 95.0f;
constexpr float kCastRange = 18.0f;
constexpr float kManualHold = 5.0f;
constexpr float kCrowdRadius = 2.6f;
// Picks the densest nearby crowd and returns its centroid; a lone enemy is a
// valid target. Returns false when there is nothing in casting range.
bool pick_crowd(const EnemySystem& enemies, Vec2 from, Vec2& center) {
SpatialHash hash(kCrowdRadius);
for (std::size_t i = 0; i < enemies.enemies.size(); ++i)
hash.insert(static_cast<int>(i), enemies.enemies[i].pos);
hash.build();
const std::size_t stride = enemies.enemies.size() > 200
? enemies.enemies.size() / 100 : 1;
int best_count = -1;
float best_dist = 0.0f;
Vec2 best_center{};
for (std::size_t i = 0; i < enemies.enemies.size(); i += stride) {
const Vec2 here = enemies.enemies[i].pos;
const float dist = distance(here, from);
if (dist > kCastRange) continue;
int count = 0;
Vec2 sum{};
hash.query(here, kCrowdRadius, [&](int id) {
const Vec2 other = enemies.enemies[static_cast<std::size_t>(id)].pos;
if (distance(here, other) <= kCrowdRadius) {
++count;
sum += other;
}
});
// Density wins; ties go to the closest crowd so the pile doesn't fly
// across the whole floor for an equally sized group.
if (count > best_count || (count == best_count && dist < best_dist)) {
best_count = count;
best_dist = dist;
best_center = sum * (1.0f / static_cast<float>(count));
}
}
if (best_count < 0) return false;
center = best_center;
return true;
}
void try_cast(SkillSystem& skills, Player& player, EnemySystem& enemies,
EventQueue& events) {
const int index = static_cast<int>(SkillType::ConcreteCall);
if (skills.cooldowns[index] > 0.0f || !player.alive()) return;
Vec2 center{};
if (!pick_crowd(enemies, player.pos, center)) return; // keep the cast ready
ConcretePile pile;
pile.pos = player.pos;
pile.target = center;
pile.phase = PilePhase::Gather;
pile.phase_duration = kGatherTime;
pile.damage = kBlastDamage * player.stats.damage_mult;
pile.blast_radius = kBlastRadius;
skills.piles.add(pile);
skills.cooldowns[index] = kConcreteCooldown;
// The event carries the landing zone and blast radius for a brief ground
// telegraph; the presenter knows the player position for the gather dust.
events.push(EventType::SkillCast, center, pile.blast_radius);
}
void try_cast_warp(SkillSystem& skills, Player& player, EnemySystem& enemies,
EventQueue& events) {
const int index = static_cast<int>(SkillType::Warp);
if (skills.cooldowns[index] > 0.0f || !player.alive()) return;
Vec2 center{};
if (!pick_crowd(enemies, player.pos, center)) return;
WarpField field;
field.pos = center;
field.duration = kWarpDuration;
field.radius = kWarpRadius;
field.damage = kWarpDamage * player.stats.damage_mult;
skills.warps.add(field);
skills.cooldowns[index] = kWarpCooldown;
events.push(EventType::SkillCast, center, field.radius,
static_cast<unsigned>(index));
}
void detonate(const ConcretePile& pile, EnemySystem& enemies, EventQueue& events) {
for (Enemy& e : enemies.enemies) {
if (distance(pile.pos, e.pos) >= pile.blast_radius + e.radius) continue;
e.hp -= pile.damage * e.mods.damage_taken_mult;
e.hit_flash = 0.15f;
events.push(EventType::EnemyHit, e.pos, pile.damage);
}
events.push(EventType::AreaDetonation, pile.pos, pile.blast_radius,
kDetonateConcrete);
}
void warp_burst(const WarpField& field, EnemySystem& enemies, EventQueue& events) {
for (Enemy& e : enemies.enemies) {
if (distance(field.pos, e.pos) >= field.radius + e.radius) continue;
e.hp -= field.damage * e.mods.damage_taken_mult;
e.hit_flash = 0.15f;
events.push(EventType::EnemyHit, e.pos, field.damage);
}
events.push(EventType::WarpBurst, field.pos, field.radius);
}
} // namespace
const char* skill_name(SkillType type) {
switch (type) {
case SkillType::ConcreteCall: return "CONCRETE CALL";
case SkillType::Warp: return "WARP";
default: return "UNKNOWN";
}
}
float skill_cooldown(SkillType type) {
switch (type) {
case SkillType::ConcreteCall: return kConcreteCooldown;
case SkillType::Warp: return kWarpCooldown;
default: return 1.0f;
}
}
void SkillSystem::reset() {
for (float& cd : cooldowns) cd = 0.0f;
manual_hold = 0.0f;
autoplay_enabled = true;
piles.clear();
warps.clear();
}
void SkillSystem::update(float dt, const InputState& in, Player& player,
EnemySystem& enemies, EventQueue& events) {
if (in.toggle_autoplay) autoplay_enabled = !autoplay_enabled;
manual_hold = std::max(0.0f, manual_hold - dt);
for (float& cd : cooldowns) cd = std::max(0.0f, cd - dt);
if (in.skill_concrete || in.skill_warp) {
// A manual press takes control; autoplay stays off for a short window
// even if the skill is still cooling down.
manual_hold = kManualHold;
}
if (in.skill_concrete) try_cast(*this, player, enemies, events);
if (in.skill_warp) try_cast_warp(*this, player, enemies, events);
if (autoplay_active()) {
// Generic autoplay: every skill is cast from this same path when the
// player isn't driving them by hand.
try_cast(*this, player, enemies, events);
try_cast_warp(*this, player, enemies, events);
}
for (std::size_t i = 0; i < piles.size();) {
ConcretePile& pile = piles[i];
pile.phase_time += dt;
if (pile.phase == PilePhase::Gather) {
pile.pos = player.pos; // the heap forms around the agent
pile.size = std::min(1.0f, pile.phase_time / pile.phase_duration);
if (pile.phase_time >= pile.phase_duration) {
pile.phase = PilePhase::Flight;
pile.phase_time = 0.0f;
pile.phase_duration = std::max(
0.05f, distance(pile.pos, pile.target) / kFlightSpeed);
}
++i;
continue;
}
const Vec2 delta = pile.target - pile.pos;
const float dist = length(delta);
const float step = kFlightSpeed * dt;
if (dist <= step + 0.25f) {
pile.pos = pile.target;
detonate(pile, enemies, events);
piles.remove_at(i);
continue;
}
pile.pos += normalized(delta) * step;
++i;
}
// WARP: drag the whole crowd inward, then burst it.
for (std::size_t i = 0; i < warps.size();) {
WarpField& field = warps[i];
field.timer += dt;
for (Enemy& e : enemies.enemies) {
const Vec2 delta = field.pos - e.pos;
const float dist = length(delta);
if (dist > field.radius || dist < 0.25f) continue;
const float pull = std::min(kWarpPull, dist * 3.0f) * dt;
e.pos += normalized(delta) * pull;
}
if (field.timer >= field.duration) {
warp_burst(field, enemies, events);
warps.remove_at(i);
continue;
}
++i;
}
}
float SkillSystem::readiness(SkillType type) const {
return std::clamp(1.0f - cooldown_left(type) / skill_cooldown(type),
0.0f, 1.0f);
}
float SkillSystem::cooldown_left(SkillType type) const {
return cooldowns[static_cast<int>(type)];
}

60
src/game/skills.hpp Normal file
View file

@ -0,0 +1,60 @@
#pragma once
#include "core/math.hpp"
#include "core/pool.hpp"
#include "game/input.hpp"
// Player-triggered active skills (distinct from the always-on OoP weapons).
// Skills can always be cast with their key, and auto-fire when the player is
// not using them — future skills only need a new enum value and a cast rule.
enum class SkillType { ConcreteCall = 0, Warp, Count };
constexpr int kSkillCount = static_cast<int>(SkillType::Count);
const char* skill_name(SkillType type);
float skill_cooldown(SkillType type);
enum class PilePhase { Gather, Flight };
// A telekinetically assembled heap of concrete on its way to a crowd.
struct ConcretePile {
Vec2 pos{};
Vec2 target{};
PilePhase phase = PilePhase::Gather;
float phase_time = 0.0f;
float phase_duration = 0.0f;
float size = 0.0f; // 0..1, grows during the gather phase
float damage = 0.0f;
float blast_radius = 0.0f;
};
// Enemies inside a warp field are dragged together, then burst for damage.
struct WarpField {
Vec2 pos{};
float timer = 0.0f;
float duration = 0.0f;
float radius = 0.0f;
float damage = 0.0f;
};
struct EventQueue;
struct EnemySystem;
struct Player;
struct SkillSystem {
float cooldowns[kSkillCount]{};
float manual_hold = 0.0f; // manual-control window after a key press
bool autoplay_enabled = true;
DensePool<ConcretePile> piles{16};
DensePool<WarpField> warps{4};
void reset();
void update(float dt, const InputState& in, Player& player,
EnemySystem& enemies, EventQueue& events);
// 1 = ready, 0 = just cast. Drives the HUD icon.
float readiness(SkillType type) const;
float cooldown_left(SkillType type) const;
bool autoplay_active() const {
return autoplay_enabled && manual_hold <= 0.0f;
}
};

View file

@ -115,6 +115,9 @@ Options parse_options(int argc, char** argv) {
struct InputFrame {
int pad = -1;
bool dash = false;
bool skill_concrete = false;
bool skill_warp = false;
bool toggle_autoplay = false;
bool restart = false;
};
@ -142,11 +145,20 @@ int select_gamepad(int current) {
void poll_input(InputFrame& frame) {
frame.pad = select_gamepad(frame.pad);
frame.dash = frame.dash || IsKeyPressed(KEY_LEFT_SHIFT) || IsKeyPressed(KEY_SPACE);
frame.skill_concrete = frame.skill_concrete || IsKeyPressed(KEY_J);
frame.skill_warp = frame.skill_warp || IsKeyPressed(KEY_K);
frame.toggle_autoplay = frame.toggle_autoplay || IsKeyPressed(KEY_L);
frame.restart = frame.restart || IsKeyPressed(KEY_R);
if (frame.pad >= 0) {
const bool confirm = IsGamepadButtonPressed(frame.pad, GAMEPAD_BUTTON_RIGHT_FACE_DOWN);
frame.dash = frame.dash || confirm
|| IsGamepadButtonPressed(frame.pad, GAMEPAD_BUTTON_RIGHT_TRIGGER_1);
frame.skill_concrete = frame.skill_concrete
|| IsGamepadButtonPressed(frame.pad, GAMEPAD_BUTTON_RIGHT_FACE_UP);
frame.skill_warp = frame.skill_warp
|| IsGamepadButtonPressed(frame.pad, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT);
frame.toggle_autoplay = frame.toggle_autoplay
|| IsGamepadButtonPressed(frame.pad, GAMEPAD_BUTTON_MIDDLE_LEFT);
frame.restart = frame.restart || confirm
|| IsGamepadButtonPressed(frame.pad, GAMEPAD_BUTTON_MIDDLE_RIGHT);
}
@ -174,6 +186,10 @@ InputState read_input(const Game& game, bool bot, const InputFrame& frame) {
in.move_x = dir.x;
in.move_y = dir.y;
in.dash = nearest_enemy < 2.0f;
// Skills autoplay in SkillSystem; the bot doesn't need a key press.
in.skill_concrete = false;
in.skill_warp = false;
in.toggle_autoplay = false;
return in;
}
in.move_x = (IsKeyDown(KEY_D) ? 1.0f : 0.0f) - (IsKeyDown(KEY_A) ? 1.0f : 0.0f);
@ -199,6 +215,9 @@ InputState read_input(const Game& game, bool bot, const InputFrame& frame) {
in.move_y = std::clamp(in.move_y + gy, -1.0f, 1.0f);
}
in.dash = frame.dash;
in.skill_concrete = frame.skill_concrete;
in.skill_warp = frame.skill_warp;
in.toggle_autoplay = frame.toggle_autoplay;
in.restart = frame.restart;
return in;
}
@ -362,6 +381,9 @@ int main(int argc, char** argv) {
if (in.restart) presenter.reset();
game.update(in, kFixedDt);
input.dash = false;
input.skill_concrete = false;
input.skill_warp = false;
input.toggle_autoplay = false;
input.restart = false;
}
accumulator -= kFixedDt;

View file

@ -1106,6 +1106,27 @@ void Presenter::draw_scene(Game& game) {
shake_ = std::max(shake_, 0.45f);
damage_flash_ = 1.0f;
spawn_sparks(e.pos, 1.0f, Color{255, 80, 70, 255}, 6, 3.0f);
} else if (e.type == EventType::SkillCast) {
// Both skills telegraph their landing zone; only concrete kicks up
// dust, warp uses the teal containment palette.
const bool warp = (e.flags & static_cast<unsigned>(SkillType::Warp)) != 0;
if (warp) {
spawn_sparks(e.pos, 0.6f, Color{80, 225, 205, 255}, 12, 3.0f);
} else {
concrete_debris_.burst(game.player.pos, 1.2f, 6);
spawn_sparks(game.player.pos, 0.35f, Color{180, 176, 166, 255},
8, 2.6f);
}
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
std::max(1.0f, e.magnitude),
warp ? 0.9f : 0.55f, anim_time_);
shake_ = std::max(shake_, 0.08f);
} else if (e.type == EventType::WarpBurst) {
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
std::max(1.0f, e.magnitude) * 1.2f, 1.0f,
anim_time_);
spawn_sparks(e.pos, 0.9f, Color{120, 240, 220, 255}, 16, 4.5f);
shake_ = std::max(shake_, 0.22f);
} else if (e.type == EventType::EnemyKilled) {
shake_ = std::max(shake_, 0.10f);
spawn_sparks(e.pos, 0.9f, Color{255, 60, 50, 255}, 8, 3.4f);
@ -1335,6 +1356,51 @@ void Presenter::draw_scene(Game& game) {
flash, !mold, walk, flash, e.bob_phase, enemy_hiss(e));
}
// CONCRETE CALL: a rough heap of slabs gathered around the agent, then
// hurled at the nearest crowd. Six orbiting slabs read as one pile.
for (const ConcretePile& pile : game.skill_system.piles) {
if (!cull.visible(pile.pos.x, 1.0f, pile.pos.y, 3.0f)) continue;
const float flight = pile.phase == PilePhase::Flight
? std::min(1.0f, pile.phase_time
/ std::max(0.01f, pile.phase_duration))
: 0.0f;
const float height = 0.05f
+ std::sin(flight * 3.14159265f) * 1.7f;
const float spin = anim_time_ * 2.4f;
const float scale = 0.42f + 0.78f * pile.size;
// Three rubble heaps drift inward while gathering, then resolve to
// one solid pile that flies at the crowd. Reuses the existing
// concrete debris GLB (enhanced in build_props.py).
const int pieces = (pile.phase == PilePhase::Gather && pile.size < 0.95f)
? 3 : 1;
for (int k = 0; k < pieces; ++k) {
const float a = spin + k * 2.0943951f;
const float drift = pieces == 1 ? 0.0f
: (1.0f - pile.size) * 1.6f;
const Vector3 center = {
pile.pos.x + std::cos(a) * drift,
height + std::sin(spin + k * 1.7f) * 0.08f * pile.size,
pile.pos.y + std::sin(a) * drift,
};
models_.draw(ActorModel::Debris, center, a, scale, WHITE);
}
}
// WARP: shrinking containment rings pull the eye (and the horde) into
// the collapse centre while the sim drags enemies together.
for (const WarpField& field : game.skill_system.warps) {
if (!cull.visible(field.pos.x, 1.0f, field.pos.y, field.radius)) continue;
const float t = std::clamp(
field.timer / std::max(0.01f, field.duration), 0.0f, 1.0f);
const float r = field.radius * (1.0f - 0.55f * t);
const Color ring{80, 225, 205,
static_cast<unsigned char>(210 - 90 * t)};
const Vector3 center{field.pos.x, 0.12f + t * 0.6f, field.pos.y};
DrawCircle3D(center, r, Vector3{0.0f, 1.0f, 0.0f}, t * 2.0f, ring);
DrawCircle3D(center, r * 0.62f, Vector3{0.0f, 1.0f, 0.0f},
-t * 3.0f, ring);
}
// Enemy drops: small cyan Resonance crystals, spun by the crystal rig.
for (const XpShard& s : game.pickup_system.shards) {
if (!cull.visible(s.pos.x, 0.25f, s.pos.y, 0.6f)) continue;

View file

@ -1,6 +1,7 @@
#include "render/ui.hpp"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
@ -19,6 +20,47 @@ void draw_bar(float x, float y, float w, float h, float frac, Color fill, const
if (label != nullptr) ui_font::draw_text(label, x + 8, y + h / 2 - 8, 16, Color{235, 232, 224, 235});
}
void draw_skill_icon(const Game& game, SkillType type, float x, float y,
const char* key) {
const SkillSystem& skills = game.skill_system;
const float ready = skills.readiness(type);
const Color stamp = ready >= 1.0f ? Color{245, 197, 24, 250}
: Color{150, 148, 142, 220};
constexpr float size = 58.0f;
DrawRectangle(x, y, size, size, Color{14, 14, 16, 230});
const float fill = (size - 8.0f) * ready;
if (fill > 0.0f)
DrawRectangle(x + 4.0f, y + size - 4.0f - fill, size - 8.0f, fill,
Color{86, 84, 80, 190});
DrawRectangleLines(x, y, size, size, stamp);
if (type == SkillType::ConcreteCall) {
// Stacked concrete slabs.
DrawRectangle(x + 20.0f, y + 23.0f, 18.0f, 7.0f, stamp);
DrawRectangle(x + 14.0f, y + 31.0f, 30.0f, 7.0f, stamp);
DrawRectangle(x + 10.0f, y + 39.0f, 38.0f, 8.0f, stamp);
} else {
// Concentric collapse rings.
DrawCircleLines(x + 29.0f, y + 34.0f, 16.0f, stamp);
DrawCircleLines(x + 29.0f, y + 34.0f, 9.0f, stamp);
DrawCircleLines(x + 29.0f, y + 34.0f, 3.0f, stamp);
}
ui_font::draw_text(key, static_cast<int>(x) + 4, static_cast<int>(y) + 2,
14, stamp);
if (ready < 1.0f) {
char wait[8];
std::snprintf(wait, sizeof(wait), "%.0fs",
std::ceil(skills.cooldown_left(type)));
ui_font::draw_text(wait, static_cast<int>(x) + static_cast<int>(size) - 28,
static_cast<int>(y) + 3, 12, stamp);
}
const char* title = skill_name(type);
ui_font::draw_text(title,
static_cast<int>(x + size / 2.0f)
- ui_font::measure_text(title, 14) / 2,
static_cast<int>(y) - 17, 14, stamp);
}
void draw_hud(const Game& game) {
// Top left: agent vitals.
char hp_label[64];
@ -173,6 +215,25 @@ void draw_hud(const Game& game) {
draw_bar(GetScreenWidth() / 2.0f - xp_w / 2.0f, GetScreenHeight() - 44, xp_w, 18,
game.xp / game.xp_to_next, Color{245, 197, 24, 235}, "RESONANCE SHARDS");
// Two active-skill stamps above the XP bar. Both share one autoplay mode
// label, since autoplay drives the whole SkillSystem.
{
constexpr float kSize = 58.0f, kGap = 22.0f;
const float total = kSize * 2.0f + kGap;
const float x0 = GetScreenWidth() / 2.0f - total / 2.0f;
const float y = GetScreenHeight() - 110.0f;
draw_skill_icon(game, SkillType::ConcreteCall, x0, y, "J");
draw_skill_icon(game, SkillType::Warp, x0 + kSize + kGap, y, "K");
const SkillSystem& skills = game.skill_system;
const char* mode = !skills.autoplay_enabled ? "OFF"
: skills.autoplay_active() ? "AUTO" : "MANUAL";
const Color mode_color = skills.autoplay_enabled
? Color{245, 197, 24, 235} : Color{150, 148, 142, 220};
ui_font::draw_text(mode, static_cast<int>(x0 + total + 12),
static_cast<int>(y) + 22, 13, mode_color);
}
// Dev readout (pre-alpha): frame rate + entity counts + director bank.
char debug[160];
std::snprintf(debug, sizeof(debug),

162
tests/skills_test.cpp Normal file
View file

@ -0,0 +1,162 @@
// Active skills: CONCRETE CALL and WARP — manual casts, autoplay, effects.
#include <cstdio>
#include "game/game.hpp"
namespace {
constexpr float kDt = 1.0f / 60.0f;
float total_hp(const EnemySystem& enemies) {
float hp = 0.0f;
for (const Enemy& e : enemies.enemies) hp += e.hp;
return hp;
}
void spawn_crowd(Game& game) {
game.enemy_system.clear();
game.player.pos = {0.0f, 0.0f};
game.enemy_system.spawn(EnemyType::HissBrute, {1.5f, 0.0f}, game.corruption);
game.enemy_system.spawn(EnemyType::HissBrute, {2.5f, 0.0f}, game.corruption);
game.enemy_system.spawn(EnemyType::HissBrute, {2.0f, 1.0f}, game.corruption);
}
bool failed = false;
void check(bool ok, const char* what) {
if (!ok) {
std::printf("FAIL: %s\n", what);
failed = true;
}
}
} // namespace
int main() {
// --- Manual cast (J) ---
{
Game game(7);
spawn_crowd(game);
const float hp_before = total_hp(game.enemy_system);
InputState in{};
in.skill_concrete = true;
game.update(in, kDt);
check(game.skill_system.piles.size() == 1, "J spawns a concrete pile");
check(game.skill_system.cooldowns[static_cast<int>(SkillType::ConcreteCall)] > 0.0f,
"J starts the skill cooldown");
check(!game.skill_system.autoplay_active(), "manual press pauses autoplay");
bool cast_event = false;
for (int i = 0; i < game.events.count; ++i)
if (game.events.items[i].type == EventType::SkillCast) cast_event = true;
check(cast_event, "J emits a SkillCast event");
game.events.clear();
in.skill_concrete = false;
bool detonated = false;
for (int tick = 0; tick < 120; ++tick) {
game.update(in, kDt);
for (int i = 0; i < game.events.count; ++i) {
const GameEvent& e = game.events.items[i];
if (e.type == EventType::AreaDetonation
&& (e.flags & kDetonateConcrete)) detonated = true;
}
game.events.clear();
}
check(detonated, "pile detonates with concrete debris");
check(total_hp(game.enemy_system) < hp_before - 100.0f,
"detonation damages the crowd");
}
// --- Autoplay without any key press (generic for future skills) ---
{
Game game(8);
spawn_crowd(game);
InputState in{}; // no skill button
game.update(in, kDt);
check(game.skill_system.piles.size() == 1, "skill autoplays when idle");
check(game.skill_system.autoplay_active(), "autoplay stays active");
game.events.clear();
for (int tick = 0; tick < 120; ++tick) {
game.update(in, kDt);
game.events.clear();
}
check(game.skill_system.piles.empty(), "autoplayed pile completes");
}
// --- Autoplay can be switched off; manual casts still work ---
{
Game game(9);
spawn_crowd(game);
InputState in{};
in.toggle_autoplay = true;
game.update(in, kDt);
check(!game.skill_system.autoplay_enabled, "L disables autoplay");
check(!game.skill_system.autoplay_active(), "disabled autoplay is inactive");
game.events.clear();
in.toggle_autoplay = false;
in.skill_concrete = true;
game.update(in, kDt);
check(game.skill_system.piles.size() == 1,
"manual cast works with autoplay off");
game.events.clear();
}
// --- WARP (K): enemies magnetize together, then burst ---
{
Game game(10);
game.enemy_system.clear();
game.player.pos = {0.0f, 0.0f};
game.enemy_system.spawn(EnemyType::HissBrute, {2.0f, 0.0f}, game.corruption);
game.enemy_system.spawn(EnemyType::HissBrute, {5.0f, 0.0f}, game.corruption);
game.enemy_system.spawn(EnemyType::HissBrute, {3.0f, 2.0f}, game.corruption);
const float hp_before = total_hp(game.enemy_system);
const auto spread = [](const EnemySystem& enemies, Vec2 center) {
float sum = 0.0f;
for (const Enemy& e : enemies.enemies) sum += distance(e.pos, center);
return sum / static_cast<float>(enemies.enemies.size());
};
InputState in{};
in.skill_warp = true;
game.update(in, kDt);
check(game.skill_system.warps.size() == 1, "K spawns a warp field");
check(game.skill_system.cooldowns[static_cast<int>(SkillType::Warp)] > 0.0f,
"K starts the warp cooldown");
bool cast_event = false;
for (int i = 0; i < game.events.count; ++i) {
const GameEvent& e = game.events.items[i];
if (e.type == EventType::SkillCast
&& e.flags == static_cast<unsigned>(SkillType::Warp))
cast_event = true;
}
check(cast_event, "warp emits a tagged SkillCast event");
const Vec2 center = game.skill_system.warps[0].pos;
const float spread_before = spread(game.enemy_system, center);
in.skill_warp = false;
for (int tick = 0; tick < 30; ++tick) {
game.update(in, kDt);
game.events.clear();
}
check(spread(game.enemy_system, center) < spread_before * 0.8f,
"warp pulls enemies together");
bool burst = false;
for (int tick = 0; tick < 40; ++tick) {
game.update(in, kDt);
for (int i = 0; i < game.events.count; ++i)
if (game.events.items[i].type == EventType::WarpBurst) burst = true;
game.events.clear();
}
check(burst, "warp field collapses with a burst event");
check(game.skill_system.warps.empty(), "warp field is consumed");
check(total_hp(game.enemy_system) < hp_before - 100.0f,
"warp burst damages the crowd");
}
if (failed) return 1;
std::printf("skills: OK\n");
return 0;
}

View file

@ -31,7 +31,8 @@ importlib.reload(K)
K.clear_scene()
P = K.PALETTE
P.update({"plastic": "#2a2d33", "screen": "#10151c", "duck": "#f2c230",
"brass": "#b89348", "glass": "#9fc4cf"})
"brass": "#b89348", "glass": "#9fc4cf",
"concrete_lt": "#9d9c96", "concrete_mid": "#6f7072"})
def place(obj, rot=(0.0, 0.0, 0.0), offset=(0.0, 0.0, 0.0)):
@ -233,19 +234,31 @@ def build_crate():
# -------------------------------------------------------------------- debris
def build_debris():
# A heap of broken concrete, not a single floating slab: the active skill
# CONCRETE CALL reuses this model as its flying pile, so the silhouette has
# to read as rubble at tactical distance. Feet stay at the origin.
r = K.new_actor("Debris")
K.blob(r, "slab", (0, 0, 0.42), (0.92, 0.70, 0.30), P["concrete"],
K.blob(r, "slab", (0, 0, 0.42), (0.92, 0.70, 0.30), P["concrete_lt"],
subdiv=3, warp=0.34, seed=7, smooth=False, ao=0.12)
chunks = [
((-0.55, 0.08, 0.22), (0.40, 0.32, 0.22), 11, "concrete_lt"),
((0.50, 0.18, 0.24), (0.38, 0.30, 0.24), 12, "concrete_mid"),
((0.18, -0.48, 0.20), (0.36, 0.28, 0.20), 13, "concrete_lt"),
((-0.34, -0.38, 0.26), (0.30, 0.26, 0.28), 14, "concrete"),
((0.52, -0.36, 0.32), (0.28, 0.26, 0.32), 15, "concrete_lt"),
((0.00, 0.52, 0.24), (0.34, 0.26, 0.24), 16, "concrete_mid"),
]
for i, (center, scale, seed, tone) in enumerate(chunks):
K.blob(r, "chunk_%d" % i, center, scale, P[tone],
subdiv=2, warp=0.30, seed=seed, smooth=False, ao=0.10)
K.plate(r, "rebar_plate", K.octagon(0.34, 0.22), 0.68, 0.72, 0.9,
P["steel_dk"], shift=(0.14, 0.0))
for i, (x, y, z, tilt) in enumerate([
(-0.40, -0.14, 0.66, (0.3, -0.2, 0.4)),
(0.30, 0.22, 0.70, (-0.4, 0.3, -0.2)),
(0.46, -0.26, 0.60, (0.2, 0.4, 0.3)),
(-0.12, 0.34, 0.62, (-0.3, -0.3, 0.1)),
(0.08, -0.36, 0.64, (0.1, 0.2, -0.4)),
]):
K.crystal(r, "growth_%d" % i, (x, y, z), 0.30, P["hiss"],
K.crystal(r, "growth_%d" % i, (x, y, z), 0.26, P["hiss"],
sides=5, seed=30 + i, tilt=tilt)
for i in range(3):
K.tube(r, "crack_%d" % i,
@ -253,6 +266,12 @@ def build_debris():
(-0.3 + i * 0.45, -0.1, 0.68),
(-0.1 + i * 0.45, 0.2, 0.62)],
[0.018, 0.02, 0.014], P["hiss_hot"], sides=5)
# One chunk dips 3 cm under the origin; lift the whole heap so its feet
# sit exactly on the floor after export.
for part in r.children:
for v in part.data.vertices:
v.co.z += 0.03
part.data.update()
return r
@ -263,7 +282,7 @@ BUILDERS = [
("duck", build_duck, 1000),
("cabinet", build_cabinet, 1200),
("crate", build_crate, 1000),
("debris", build_debris, 1000),
("debris", build_debris, 3000),
]
exported = []