Isle-Slingers/js/physics/constants/index.js

55 lines
2.7 KiB
JavaScript
Raw Permalink Normal View History

/* ISLE SLINGERS -- physics/constants/index.js (submodule: constants)
* Modularization pass (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: WORLD, VIEW, MATERIALS, BIRD_TYPES, ENEMY_TYPES, GRAVITY, LAUNCH_POWER, MAX_PULL, MIN_PULL, AIR_DRAG, BIRD_BOUNCE, BIRD_GROUND_FRICTION, REST_SPEED, SETTLE_TIME, BIRD_MAX_AGE, ABILITY_CD, BIRD_BONUS.
*/
(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.WORLD = { w: 2400, ground: 900 };
P.VIEW = { w: 1280, h: 720 }; // base viewport (renderer renders at this size,
// then CSS-scales; camera math lives in the core)
P.MATERIALS = {
wood: { hp: 1300, density: 1.0, restitution: 0.18, dmgFactor: 0.9, score: 500, maxVel: 520 },
ice: { hp: 480, density: 0.7, restitution: 0.05, dmgFactor: 1.6, score: 800, maxVel: 560 },
// stone: retuned 2026-09-28 (playtest finding: "blocks and pig
// bad guys too hard to kill"): at hp 3400 with dmgFactor 0.35 a 70x70
// cube took ~11 full-power direct hits — stone walls were functionally
// unbreakable, so every enemy behind one was unkillable. Now ~2-3 hits.
stone: { hp: 1400, density: 2.2, restitution: 0.04, dmgFactor: 0.8, score: 300, maxVel: 480 }
};
P.BIRD_TYPES = {
wren: { r: 20, mass: 3.0, label: 'Wren', ability: 'fury' }, // tap: horizontal burst
zippy: { r: 17, mass: 2.2, label: 'Zippy', ability: 'dive' }, // tap: steep dive
boulder: { r: 26, mass: 6.5, label: 'Boulder', ability: 'quake' } // tap: radial shock
};
P.ENEMY_TYPES = {
mogg: { hp: 1, r: 24, score: 5000, crushVel: 330, crushDmg: 1.2 },
grum: { hp: 2, r: 32, score: 8000, crushVel: 380, crushDmg: 1.0 },
king: { hp: 3, r: 38, score: 15000, crushVel: 430, crushDmg: 0.85 }
};
P.GRAVITY = 1500;
P.LAUNCH_POWER = 11.5; // velocity per px of pull
P.MAX_PULL = 150;
P.MIN_PULL = 14;
P.AIR_DRAG = 0.999;
P.BIRD_BOUNCE = 0.34;
P.BIRD_GROUND_FRICTION = 0.86;
P.REST_SPEED = 14; // below this a bird counts as settling
P.SETTLE_TIME = 0.9; // seconds under P.REST_SPEED before bird is spent
P.BIRD_MAX_AGE = 12;
P.ABILITY_CD = 0.35; // min seconds after P.launch before ability usable
P.BIRD_BONUS = 10000;
};
});