Delivered by Hermies Qwen, gated and deployed by Relay. - Board tip/topple: full continuous rotation when a board's center of mass passes its support edge (Q1: smooth pivot swing, no discrete snap). Falling boards deal impact damage and can kill enemies in their fall path. - Falling-object impact damage: blocks and birds can now kill enemies from vertical drops and side plows (velocity-aware crush gate), chain momentum transfers correctly through stacks (mass-weighted contact), repeated impacts finish tougher enemies. - Landed-bird physics: a bird resting on a board remains a real physical body under continuous gravity (Q2: no lifetime timer). If its platform is destroyed it falls, damages what it lands on (chain reaction), and can kill enemies. - Repo modularized: folders = modules, subfolders = submodules, architecture.md + MODULES.md at root, an agents.md card in every module and submodule (17 total). - Test suite grown from 27 to 47 (20 new RED-watched tests for the above behaviors), all green. Golden differential against the original core confirmed the only behavioral changes are the intended ones. Live at http://10.244.136.121:8093/, independently re-verified by Relay (full suite re-run, module structure check, headless Chromium smoke) before this push. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
85 lines
3.1 KiB
JavaScript
85 lines
3.1 KiB
JavaScript
/* ISLE SLINGERS -- physics/state/index.js (submodule: state)
|
|
* RC-375D84 S-2 modularization (behavior-neutral split of the original
|
|
* js/core.js monolith). Installs its units into ONE shared physics scope `P`
|
|
* that every physics submodule sees -- the same single-scope semantics the
|
|
* monolith had. Must load before js/physics/index.js (the aggregator that
|
|
* attaches the public ISLE_CORE API). Surface installed: createGame, makeBird, activeBird.
|
|
*/
|
|
(function (root, factory) {
|
|
var part = factory();
|
|
if (typeof module !== 'undefined' && module.exports) module.exports = part;
|
|
else (root.ISLE_PHYSICS_PARTS = root.ISLE_PHYSICS_PARTS || []).push(part);
|
|
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
|
|
'use strict';
|
|
return function (P) {
|
|
P.createGame = function(levelDef) {
|
|
var g = {
|
|
level: levelDef,
|
|
world: { w: P.WORLD.w, ground: P.WORLD.ground },
|
|
time: 0,
|
|
score: 0,
|
|
birds: [],
|
|
blocks: [],
|
|
enemies: [],
|
|
events: [], // visual/audio events for the renderer
|
|
scorePopups: [], // {x,y,text,age}
|
|
hadEnemies: levelDef.enemies.length > 0,
|
|
camera: { x: levelDef.sling.x + 260, y: 560, zoom: 1, shake: 0, snap: true },
|
|
status: 'ready', // ready | flying | won | lost
|
|
activeBird: -1,
|
|
launched: 0,
|
|
wonAt: null,
|
|
lostAt: null,
|
|
stats: { impacts: 0, destroyedBlocks: 0, destroyedEnemies: 0, abilityUses: 0, distance: 0 }
|
|
};
|
|
g.blocks = levelDef.blocks.map(function (b, i) {
|
|
var m = P.MATERIALS[b.mat];
|
|
return {
|
|
id: i, x: b.x, y: b.y, w: b.w, h: b.h, mat: b.mat,
|
|
hp: m.hp, maxHp: m.hp,
|
|
vx: 0, vy: 0, rest: 1,
|
|
// S-3 rotational degree of freedom (topple). ang/angVel stay 0 for
|
|
// every supported stack, so pre-S-3 motion is preserved exactly.
|
|
ang: 0, angVel: 0, pivoting: false,
|
|
mass: m.density * b.w * b.h / 1400
|
|
};
|
|
});
|
|
g.enemies = levelDef.enemies.map(function (e, i) {
|
|
var t = P.ENEMY_TYPES[e.kind];
|
|
// level data y is the CENTER (the level-integrity test treats it the
|
|
// same way); spawning at e.y - r made every enemy drop 24-38px on
|
|
// load — a visible "objects moving on their own" wobble at start
|
|
return {
|
|
id: i, kind: e.kind, x: e.x, y: e.y, r: t.r,
|
|
hp: t.hp, maxHp: t.hp, vx: 0, vy: 0, rest: 1, dead: false, deathAge: 0
|
|
};
|
|
});
|
|
var i;
|
|
for (i = 0; i < levelDef.birds.length; i++) {
|
|
g.birds.push(P.makeBird(levelDef.birds[i], i));
|
|
}
|
|
g.activeBird = g.birds.length ? 0 : -1;
|
|
if (g.activeBird >= 0) {
|
|
var fb = g.birds[0];
|
|
fb.state = 'aiming';
|
|
fb.x = levelDef.sling.x;
|
|
fb.y = levelDef.sling.y;
|
|
}
|
|
return g;
|
|
}
|
|
|
|
P.makeBird = function(kind, idx) {
|
|
var t = P.BIRD_TYPES[kind];
|
|
return {
|
|
id: idx, kind: kind, r: t.r, mass: t.mass,
|
|
x: 0, y: 0, vx: 0, vy: 0,
|
|
state: 'queued', // queued | aiming | flying | spent
|
|
abilityUsed: false,
|
|
settleTimer: 0, age: 0,
|
|
launchT: 0
|
|
};
|
|
}
|
|
|
|
P.activeBird = function(g) { return g.activeBird >= 0 ? g.birds[g.activeBird] : null; }
|
|
};
|
|
});
|