Isle-Slingers/js/physics/damage/index.js
Relay dc68c6e3dd Physics upgrade + repo modularization (RC-375D84)
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>
2026-09-29 13:21:18 +00:00

45 lines
1.9 KiB
JavaScript

/* ISLE SLINGERS -- physics/damage/index.js (submodule: damage)
* 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: damageBlock, damageEnemy.
*/
(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.damageBlock = function(g, bl, dmg, src) {
if (bl.hp <= 0) return;
bl.toppled = false; // a real hit can dislodge a settled board to tip again
bl.hp -= dmg;
if (bl.hp <= 0) {
bl.hp = 0;
g.score += P.MATERIALS[bl.mat].score;
g.stats.destroyedBlocks++;
g.scorePopups.push({ x: bl.x, y: bl.y, text: '+' + P.MATERIALS[bl.mat].score, age: 0 });
g.events.push({ type: 'break', x: bl.x, y: bl.y, mat: bl.mat, big: bl.w * bl.h > 12000 });
g.camera.shake = Math.max(g.camera.shake, 4 + bl.w * bl.h / 4000);
} else if (dmg > 40) {
g.events.push({ type: 'crack', x: bl.x, y: bl.y, mat: bl.mat });
}
}
P.damageEnemy = function(g, e, dmg) {
if (e.dead) return;
e.hp -= dmg;
if (e.hp <= 0) {
e.dead = true;
e.deathAge = 0;
g.score += P.ENEMY_TYPES[e.kind].score;
g.stats.destroyedEnemies++;
g.scorePopups.push({ x: e.x, y: e.y - 30, text: '+' + P.ENEMY_TYPES[e.kind].score, age: 0 });
g.events.push({ type: 'pop', x: e.x, y: e.y, kind: e.kind });
g.camera.shake = Math.max(g.camera.shake, 7);
}
}
};
});