Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8991bde943 | ||
|
|
2cf8dc89fe | ||
|
|
988e04b2d4 |
No files matched your search
@@ -7,3 +7,6 @@ dist/
|
||||
served-state.txt
|
||||
__pycache__/
|
||||
*.pyc
|
||||
assets/raw/models/
|
||||
assets/raw/meshy/
|
||||
assets/raw/meshy_manifest.jsonl
|
||||
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
---
|
||||
|
||||
## [0.9.5] — 2026-08-15
|
||||
|
||||
### Added
|
||||
- **Boss-room loading overlay** — first visit of a boss room holds combat in `bossload` for at least 1s while the boss action sheet is warmed (decode + GPU upload) so the roar is not cut by the hitch. Re-entering a visited boss room skips the overlay. A failed sheet cannot deadlock the screen.
|
||||
|
||||
### Changed
|
||||
- **Elite Brood Sac summons** — an elite sac now seeds 4–6 minis per cycle (normal remains 2). Wave elite rolls still exclude Brood Sac; debug/other elite paths are the intended case. Death burst is unchanged (4).
|
||||
|
||||
### Removed
|
||||
- **Redundant RUN DATA pressure multiplier** — the `×N.NN` number next to score is gone; `PRESSURE NN%` and the bar remain.
|
||||
|
||||
|
||||
## [0.9.1] — 2026-08-13
|
||||
|
||||
### Changed
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ Its 180px aura grants +35% speed and heals nearby non-boss monsters ~1.8% max HP
|
||||
| XP | 4 |
|
||||
| First appears | Floor 7 (spawn weight 6) |
|
||||
|
||||
Spawns 2 Minis every 4s and 4 on death. At most two are wave-selected; the brood population cap is 40. Cannot be elite and is excluded from thin halls.
|
||||
Spawns 2 Minis every 4s (elite: 4–6 every 3s) and 4 on death. At most two are wave-selected; the brood population cap is 40. Excluded from normal wave elite rolls and thin halls; an elite sac (debug or other spawn paths) still uses the elite summon count.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+3
-2
@@ -119,7 +119,7 @@ Right-click is disabled (context menu suppressed). There is **no interact key**
|
||||
### Healing
|
||||
|
||||
- Hearts restore 2 HP (1 heart) each.
|
||||
- Healing past max HP normally goes to waste — unless you have the **Second Stomach** item, which converts overflow healing into shield HP. Hearts are not consumed at full HP (they stay on the floor for later, and the magnet won't drag them).
|
||||
- Healing past max HP normally goes to waste — unless you have the **Second Stomach** item, which converts overflow healing into shield HP. Hearts stay on the floor at full HP unless Second Stomach has unused overflow-shield room (then they magnetize, collect, and fill shields).
|
||||
- Other healing sources: Vampire Dentures (kill procs), Hemophage (hit procs), Worm Gut / Bone Knit (post-combat heals).
|
||||
|
||||
---
|
||||
@@ -271,7 +271,7 @@ Full formulas are in [enemies.md](enemies.md) and [bosses.md](bosses.md).
|
||||
- **Top-left — BUTCHER // VITALS:** level, hearts (red, 2 HP per heart; half containers render as half outlines) and shield hearts (cyan, 2 shield HP per heart), shown on up to two rows, XP bar, active weapon + ammo (red when below 25%), holstered weapon with `[R]` swap hint.
|
||||
- **Item tray** (below vitals): up to 24 item icons with tier numerals I–IX.
|
||||
- **Top-right — SECTOR MAP:** minimap. White = current room, red = boss, gold = item, gray = cleared, maroon = uncleared. Includes floor number.
|
||||
- **Bottom-right — RUN DATA:** floor, kills, score (with the live pressure multiplier), PRESSURE % (with the dial setting), STREAK, pressure bar.
|
||||
- **Bottom-right — RUN DATA:** floor, kills, score, PRESSURE % (with the dial setting), STREAK, pressure bar.
|
||||
- **HUD opacity** is adjustable from the pause menu (`;` / `'` or the HUD slider, 25%–100%). The boss HP bar and toast notifications always stay fully opaque.
|
||||
- **Bottom-center:** boss HP bar (during boss fights).
|
||||
- **Top-center:** toast notifications (pickups, floor intros, boss events).
|
||||
@@ -281,6 +281,7 @@ Full formulas are in [enemies.md](enemies.md) and [bosses.md](bosses.md).
|
||||
| Screen | What it offers |
|
||||
|---|---|
|
||||
| **Title** | INITIATE DESCENT, PRESSURE DIAL (−10…+10), HD REMASTER ON/OFF tag, control reference, best score, confirmed desktop exit |
|
||||
| **Boss approach** | Full-screen hold on first boss-room entry: boss name + FRESH MEAT APPROACHES, ≥1s, then combat |
|
||||
| **Pause** | Jukebox (track cycling), SFX/music volume + HUD opacity sliders, resume/swap/auto/mute hints, Field Manual (`H` / `?` button) |
|
||||
| **Mutation Draft** | 3 perk cards, random cut, reroll, auto-draft |
|
||||
| **Game Over ("BUTCHERED")** | Floor, kills, score, NEW BEST CUT tag, restart |
|
||||
|
||||
+1
-1
@@ -295,7 +295,7 @@ Point-blank slam — no projectile, an instant circular blast in front of you. B
|
||||
|
||||
| Stat | Value |
|
||||
|---|---|
|
||||
| Damage | 95 (× 0.4–1.0 by charge) |
|
||||
| Damage | 190 (× 0.4–1.0 by charge) |
|
||||
| Charge time | 0.85 s (minimum 40% charge = 0.34 s to fire) |
|
||||
| Beam length | 900 × rangeMul |
|
||||
| Beam width | 14 × √sizeMul |
|
||||
|
||||
+22
-22
@@ -6,32 +6,32 @@
|
||||
<meta name="theme-color" content="#0a0305">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 64 64%22><text y=%2252%22 x=%2250%22 text-anchor=%22middle%22 dominant-baseline=%22middle%22 font-size=%2252%22>🔪</text></svg>">
|
||||
<title>MEATSLICER</title>
|
||||
<link rel="stylesheet" href="css/style.css?v=58">
|
||||
<link rel="stylesheet" href="css/style.css?v=60">
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrap">
|
||||
<canvas id="game" width="960" height="640"></canvas>
|
||||
</div>
|
||||
<script src="js/utils.js?v=58"></script>
|
||||
<script src="js/state.js?v=58"></script>
|
||||
<script src="js/input.js?v=58"></script>
|
||||
<script src="js/sfx.js?v=58"></script>
|
||||
<script src="js/sfxbank.js?v=58"></script>
|
||||
<script src="js/audio.js?v=58"></script>
|
||||
<script src="js/sprites.js?v=58"></script>
|
||||
<script src="js/particles.js?v=58"></script>
|
||||
<script src="js/weapons.js?v=58"></script>
|
||||
<script src="js/bullets.js?v=58"></script>
|
||||
<script src="js/pickups.js?v=58"></script>
|
||||
<script src="js/items.js?v=58"></script>
|
||||
<script src="js/perks.js?v=58"></script>
|
||||
<script src="js/enemies.js?v=58"></script>
|
||||
<script src="js/bosses.js?v=58"></script>
|
||||
<script src="js/rooms.js?v=58"></script>
|
||||
<script src="js/player.js?v=58"></script>
|
||||
<script src="js/hud.js?v=58"></script>
|
||||
<script src="js/help.js?v=58"></script>
|
||||
<script src="js/debug.js?v=58"></script>
|
||||
<script src="js/main.js?v=58"></script>
|
||||
<script src="js/utils.js?v=60"></script>
|
||||
<script src="js/state.js?v=60"></script>
|
||||
<script src="js/input.js?v=60"></script>
|
||||
<script src="js/sfx.js?v=60"></script>
|
||||
<script src="js/sfxbank.js?v=60"></script>
|
||||
<script src="js/audio.js?v=60"></script>
|
||||
<script src="js/sprites.js?v=60"></script>
|
||||
<script src="js/particles.js?v=60"></script>
|
||||
<script src="js/weapons.js?v=60"></script>
|
||||
<script src="js/bullets.js?v=60"></script>
|
||||
<script src="js/pickups.js?v=60"></script>
|
||||
<script src="js/items.js?v=60"></script>
|
||||
<script src="js/perks.js?v=60"></script>
|
||||
<script src="js/enemies.js?v=60"></script>
|
||||
<script src="js/bosses.js?v=60"></script>
|
||||
<script src="js/rooms.js?v=60"></script>
|
||||
<script src="js/player.js?v=60"></script>
|
||||
<script src="js/hud.js?v=60"></script>
|
||||
<script src="js/help.js?v=60"></script>
|
||||
<script src="js/debug.js?v=60"></script>
|
||||
<script src="js/main.js?v=60"></script>
|
||||
</body>
|
||||
</html>
|
||||
+7
-3
@@ -100,6 +100,8 @@ function spawnPosAwayFromPlayer() {
|
||||
const y = rand(a.y0 + 40, a.y1 - 40);
|
||||
if (dist(x, y, p.x, p.y) <= safeDist) continue;
|
||||
if (nearAnyDoor(x, y)) continue;
|
||||
const obstacles = G.cur && G.cur.obstacles;
|
||||
if (obstacles && obstacles.some(o => dist(x, y, o.x, o.y) < 16 + o.r)) continue;
|
||||
return { x, y };
|
||||
}
|
||||
// fallback: a bounded central region, valid even in the thin hall variants
|
||||
@@ -458,8 +460,8 @@ function updateEnemies(dt) {
|
||||
e.x += px; e.y += py; o.x -= px; o.y -= py;
|
||||
}
|
||||
}
|
||||
e.x = clamp(e.x, G.arena.x0 + e.r, G.arena.x1 - e.r);
|
||||
e.y = clamp(e.y, G.arena.y0 + e.r, G.arena.y1 - e.r);
|
||||
const pos = resolveSolids(e.x, e.y, e.r);
|
||||
e.x = pos.x; e.y = pos.y;
|
||||
|
||||
// contact damage
|
||||
if (e.hitT > 0) e.hitT -= dt;
|
||||
@@ -522,6 +524,8 @@ function updateEnemyAI(e, dt) {
|
||||
const behind = p.aim + Math.PI, range = rand(90, 125);
|
||||
e.x = clamp(p.x + Math.cos(behind) * range, G.arena.x0 + e.r, G.arena.x1 - e.r);
|
||||
e.y = clamp(p.y + Math.sin(behind) * range, G.arena.y0 + e.r, G.arena.y1 - e.r);
|
||||
const landed = resolveSolids(e.x, e.y, e.r);
|
||||
e.x = landed.x; e.y = landed.y;
|
||||
e.phased = false; e.alpha = 1; e.ambushState = 'lunge'; e.lungeT = 0.48;
|
||||
e.faceDir = angleTo(e.x, e.y, p.x, p.y); e.attackT = 0.48; e.actionT = 0;
|
||||
}
|
||||
@@ -547,7 +551,7 @@ function updateEnemyAI(e, dt) {
|
||||
e.summonT -= dt;
|
||||
if (e.summonT <= 0) {
|
||||
e.summonT = e.elite ? 3 : 4;
|
||||
spawnBroodMinis(e, 2, 0.35);
|
||||
spawnBroodMinis(e, e.elite ? irand(4, 6) : 2, 0.35);
|
||||
e.attackT = 0.5; e.actionT = 0;
|
||||
}
|
||||
} else if (t.ranged) {
|
||||
|
||||
@@ -167,8 +167,6 @@ function drawHUD(ctx) {
|
||||
ctx.fillText('KILLS ' + String(G.kills).padStart(3, '0'), W - 18, H - 67);
|
||||
ctx.fillStyle = '#f0e5d7'; ctx.font = 'bold 11px monospace';
|
||||
ctx.fillText('SCORE ' + String(G.score).padStart(6, '0'), W - 18, H - 46);
|
||||
ctx.fillStyle = '#8f7770'; ctx.font = '8px monospace';
|
||||
ctx.fillText('×' + (G.pressure || 1).toFixed(2), W - 168, H - 46);
|
||||
ctx.textAlign = 'left';
|
||||
const dialTxt = ' D' + (G.pressureDial > 0 ? '+' : '') + G.pressureDial;
|
||||
ctx.fillStyle = G.pressure > 1 ? '#d6aa39' : '#69b8bd'; ctx.font = 'bold 8px monospace';
|
||||
|
||||
+24
@@ -246,6 +246,11 @@ function update(dt) {
|
||||
updateParticles(dt);
|
||||
drawToastsUpdate(dt);
|
||||
break;
|
||||
case 'bossload':
|
||||
updateParticles(dt);
|
||||
if (G.bossLoadT > 0) G.bossLoadT -= dt;
|
||||
if (G.bossLoadT <= 0 && Sprites.warm(G.bossLoadSheet)) G.mode = 'play';
|
||||
break;
|
||||
case 'levelup':
|
||||
updateLevelup(dt);
|
||||
updateParticles(dt);
|
||||
@@ -328,6 +333,7 @@ function draw() {
|
||||
ctx.fillRect(0, 0, W, H);
|
||||
|
||||
if (G.mode === 'menu') { drawMenu(ctx); return; }
|
||||
if (G.mode === 'bossload') { drawBossLoad(ctx); return; }
|
||||
|
||||
updateCamera();
|
||||
|
||||
@@ -378,6 +384,24 @@ function draw() {
|
||||
if (G.devMode) { if (G.debugPin && G.mode !== 'debug') drawDebugPin(ctx); }
|
||||
}
|
||||
|
||||
function drawBossLoad(ctx) {
|
||||
ctx.fillStyle = '#0a0506';
|
||||
ctx.fillRect(0, 0, W, H);
|
||||
ctx.textAlign = 'center';
|
||||
const name = G.boss && G.boss.name ? G.boss.name : 'FRESH MEAT';
|
||||
ctx.fillStyle = '#d9c9bc'; ctx.font = 'bold 28px monospace';
|
||||
ctx.fillText(name, W / 2, H / 2 - 6);
|
||||
ctx.fillStyle = '#8f1f2e'; ctx.font = 'bold 11px monospace';
|
||||
ctx.fillText('FRESH MEAT APPROACHES', W / 2, H / 2 + 16);
|
||||
const pr = Math.min(1, Math.max(0, G.bossLoadT / BOSS_LOAD_MIN));
|
||||
const tier = Math.floor((1 - pr) * 5) % 3;
|
||||
ctx.fillStyle = '#3a1a1e';
|
||||
for (let i = 0; i < 3; i++) ctx.fillRect(W / 2 - 22 + i * 14, H / 2 + 30, 8, 8);
|
||||
ctx.fillStyle = '#d7a934';
|
||||
ctx.fillRect(W / 2 - 22 + tier * 14, H / 2 + 30, 8, 8);
|
||||
ctx.textAlign = 'left';
|
||||
}
|
||||
|
||||
function drawMenu(ctx) {
|
||||
const t = performance.now() / 1000;
|
||||
const bg = ctx.createRadialGradient && ctx.createRadialGradient(W / 2, H * 0.4, 30, W / 2, H * 0.45, 590);
|
||||
|
||||
@@ -104,6 +104,14 @@ function spawnShockwave(x, y, radius, color, alpha, important) {
|
||||
}, important);
|
||||
}
|
||||
|
||||
function spawnDashBurst(x, y, ang) {
|
||||
addParticle({ type: 'bloodball', x, y, vx: 0, vy: 0, life: 0.18, t: 0, r: 10, maxR: 56 }, true);
|
||||
spawnShockwave(x, y, 52, '#8b1020', 0.75);
|
||||
spawnBlood(x, y, ang, 16, true);
|
||||
spawnGibs(x, y, 7, false);
|
||||
}
|
||||
|
||||
|
||||
function spawnSweepFx(x, y, ang, reach, arc) {
|
||||
addParticle({ type: 'sweep', x, y, ang, arc, r: 20, maxR: reach, life: 0.18, t: 0 }, true);
|
||||
}
|
||||
@@ -249,6 +257,15 @@ function drawParticles(ctx) {
|
||||
ctx.beginPath(); ctx.ellipse(p.x, p.y, radius, radius * 0.72, 0, 0, TAU); ctx.stroke();
|
||||
ctx.globalAlpha = k * 0.18;
|
||||
ctx.fillStyle = p.color; ctx.beginPath(); ctx.ellipse(p.x, p.y, radius * 0.86, radius * 0.58, 0, 0, TAU); ctx.fill();
|
||||
} else if (p.type === 'bloodball') {
|
||||
const progress = 1 - k;
|
||||
const radius = lerp(p.r, p.maxR, progress);
|
||||
ctx.globalAlpha = k * 0.82;
|
||||
ctx.fillStyle = '#6a0b14';
|
||||
ctx.beginPath(); ctx.ellipse(p.x, p.y, radius, radius * 0.72, 0, 0, TAU); ctx.fill();
|
||||
ctx.globalAlpha = k * 0.55;
|
||||
ctx.fillStyle = '#b41828';
|
||||
ctx.beginPath(); ctx.ellipse(p.x, p.y, radius * 0.55, radius * 0.55 * 0.72, 0, 0, TAU); ctx.fill();
|
||||
} else if (p.type === 'beam') {
|
||||
ctx.globalAlpha = k;
|
||||
ctx.strokeStyle = '#d9f6ff'; ctx.lineWidth = 13 * k + 3;
|
||||
|
||||
+3
-4
@@ -53,7 +53,7 @@ function updatePickups(dt) {
|
||||
}
|
||||
|
||||
// gems & small pickups fly to the player inside magnet radius
|
||||
if ((k.type === 'gem' || k.type === 'ammo' || (k.type === 'heart' && p.hp < p.stats.maxHp)) && d < magR) {
|
||||
if ((k.type === 'gem' || k.type === 'ammo' || (k.type === 'heart' && (p.hp < p.stats.maxHp || (p.stats.overShield > 0 && p.shieldHp < (p.stats.shieldPerk || 0) + p.stats.overShield)))) && d < magR) {
|
||||
const a = angleTo(k.x, k.y, p.x, p.y);
|
||||
const sp = lerp(320, 60, d / magR) * p.stats.magnetPull;
|
||||
k.x += Math.cos(a) * sp * dt; k.y += Math.sin(a) * sp * dt;
|
||||
@@ -73,9 +73,8 @@ function collectPickup(k) {
|
||||
Sfx.gem();
|
||||
break;
|
||||
case 'heart': {
|
||||
// At full HP hearts stay on the floor for later; Glutton's Gut heals +1
|
||||
// extra per tier below that.
|
||||
if (p.hp >= p.stats.maxHp) return false;
|
||||
// At full HP hearts stay unless Second Stomach has unused overflow-shield room.
|
||||
if (p.hp >= p.stats.maxHp && !(p.stats.overShield > 0 && p.shieldHp < (p.stats.shieldPerk || 0) + p.stats.overShield)) return false;
|
||||
const healAmt = 2 + (p.stats.gluttonGut || 0);
|
||||
healPlayer(healAmt); spawnText(p.x, p.y, '+' + healAmt, '#d92038');
|
||||
Sfx.heart();
|
||||
|
||||
+11
-6
@@ -87,11 +87,16 @@ function updatePlayer(dt) {
|
||||
const firing = held ? (w.id === 'bonepopper' ? 0.95 : 0.85) : 1;
|
||||
if (keyPressed('shift') && p.dashSlowT <= 0) {
|
||||
const dashD = 0.45 * (178 * st.speedMul * firing) * DASH_SLOW_T;
|
||||
p.x += (mx / len) * dashD;
|
||||
p.y += (my / len) * dashD;
|
||||
const sx = p.x, sy = p.y;
|
||||
const stepD = dashD / 8;
|
||||
for (let i = 0; i < 8; i++) {
|
||||
p.x += (mx / len) * stepD;
|
||||
p.y += (my / len) * stepD;
|
||||
const pos = resolveSolids(p.x, p.y, p.r);
|
||||
p.x = pos.x; p.y = pos.y;
|
||||
}
|
||||
p.dashSlowT = DASH_SLOW_T;
|
||||
spawnSmoke(p.x, p.y, Math.atan2(-my, -mx), 6, '#9b8d84');
|
||||
spawnShockwave(p.x, p.y, 26, '#d8c9a8', 0.35);
|
||||
spawnDashBurst(sx, sy, Math.atan2(my, mx));
|
||||
Sfx.duck();
|
||||
}
|
||||
const spd = 178 * st.speedMul * firing * (p.dashSlowT > 0 ? 0.5 : 1);
|
||||
@@ -107,8 +112,8 @@ function updatePlayer(dt) {
|
||||
p.moveBlend = lerp(p.moveBlend, mx || my ? 1 : 0, clamp(dt * 12, 0, 1));
|
||||
p.recoil = Math.max(0, p.recoil - dt * 7);
|
||||
p.muzzleT = Math.max(0, p.muzzleT - dt);
|
||||
p.x = clamp(p.x, G.arena.x0 + p.r, G.arena.x1 - p.r);
|
||||
p.y = clamp(p.y, G.arena.y0 + p.r, G.arena.y1 - p.r);
|
||||
const pos = resolveSolids(p.x, p.y, p.r);
|
||||
p.x = pos.x; p.y = pos.y;
|
||||
|
||||
// aim
|
||||
p.aim = angleTo(p.x, p.y, mxW(), myW());
|
||||
|
||||
+66
-3
@@ -2,6 +2,9 @@
|
||||
|
||||
const DIRS = { n: [0, -1], s: [0, 1], e: [1, 0], w: [-1, 0] };
|
||||
const OPP = { n: 's', s: 'n', e: 'w', w: 'e' };
|
||||
const OBSTACLE_COUNTS = { grand_hall: 3, deep_hall: 3, meat_hall: 5 };
|
||||
const OBSTACLE_R = 42;
|
||||
|
||||
const ROOM_SHAPES = {
|
||||
hall: { x0: 48, y0: 48, x1: 912, y1: 592 }, // unchanged — start & boss rooms
|
||||
wide_hall: { x0: 48, y0: 176, x1: 912, y1: 464 }, // h 224 -> 288 ("a little wider"; cy stays 320, min dim 288 < 300 keeps censer/broodsac excluded)
|
||||
@@ -64,16 +67,67 @@ function genFloor(floor) {
|
||||
for (const [dir, [dx, dy]] of Object.entries(DIRS)) {
|
||||
r.doors[dir] = !!G.rooms[(r.gx + dx) + ',' + (r.gy + dy)];
|
||||
}
|
||||
placeRoomObstacles(r);
|
||||
}
|
||||
}
|
||||
|
||||
function makeRoom(gx, gy, type) {
|
||||
return { gx, gy, type, shape: 'hall', theme: 'abattoir', doors: {}, cleared: type === 'start',
|
||||
visited: false, decals: [], wavesLeft: 0, spawnT: 0, bossSpawned: false, pickups: [] };
|
||||
visited: false, decals: [], obstacles: [], wavesLeft: 0, spawnT: 0, bossSpawned: false, pickups: [] };
|
||||
}
|
||||
|
||||
function roomKey(x, y) { return x + ',' + y; }
|
||||
|
||||
function nearRoomDoor(room, x, y) {
|
||||
const a = roomBounds(room);
|
||||
const M = Math.min(130, Math.min(a.w, a.h) * 0.32);
|
||||
if (room.doors.n && Math.abs(x - a.cx) < DOOR_HALF + 30 && y < a.y0 + M) return true;
|
||||
if (room.doors.s && Math.abs(x - a.cx) < DOOR_HALF + 30 && y > a.y1 - M) return true;
|
||||
if (room.doors.e && Math.abs(y - a.cy) < DOOR_HALF + 30 && x > a.x1 - M) return true;
|
||||
if (room.doors.w && Math.abs(y - a.cy) < DOOR_HALF + 30 && x < a.x0 + M) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function placeRoomObstacles(room) {
|
||||
room.obstacles = [];
|
||||
const count = OBSTACLE_COUNTS[room.shape];
|
||||
if (!count) return;
|
||||
const a = roomBounds(room);
|
||||
for (let tries = 0; tries < 80 && room.obstacles.length < count; tries++) {
|
||||
const x = rand(a.x0 + 80, a.x1 - 80);
|
||||
const y = rand(a.y0 + 80, a.y1 - 80);
|
||||
if (nearRoomDoor(room, x, y)) continue;
|
||||
if (dist(x, y, a.cx, a.cy) < 110) continue;
|
||||
if (room.obstacles.some(o => dist(x, y, o.x, o.y) < OBSTACLE_R * 2 + 24)) continue;
|
||||
room.obstacles.push({ x, y, r: OBSTACLE_R, kind: 'bloodpool' });
|
||||
}
|
||||
}
|
||||
|
||||
function resolveSolids(x, y, r) {
|
||||
const obstacles = G.cur && G.cur.obstacles;
|
||||
if (obstacles && obstacles.length) {
|
||||
for (let pass = 0; pass < 2; pass++) {
|
||||
for (const o of obstacles) {
|
||||
const d = dist(x, y, o.x, o.y);
|
||||
if (d < r + o.r) {
|
||||
if (d > 0.01) {
|
||||
const n = (r + o.r) / d;
|
||||
x = o.x + (x - o.x) * n;
|
||||
y = o.y + (y - o.y) * n;
|
||||
} else {
|
||||
x = o.x + r + o.r;
|
||||
y = o.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
x = clamp(x, G.arena.x0 + r, G.arena.x1 - r);
|
||||
y = clamp(y, G.arena.y0 + r, G.arena.y1 - r);
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
|
||||
function wavesFor(floor) {
|
||||
const base = 3 + Math.ceil(floor * 1.4);
|
||||
const waves = [base];
|
||||
@@ -110,8 +164,9 @@ function enterRoom(gx, gy) {
|
||||
// spawn protection: brief invincibility walking into a fresh room
|
||||
if (G.player) {
|
||||
G.player.invT = Math.max(G.player.invT, 1.0);
|
||||
G.player.x = clamp(G.player.x, a.x0 + G.player.r, a.x1 - G.player.r);
|
||||
G.player.y = clamp(G.player.y, a.y0 + G.player.r, a.y1 - G.player.r);
|
||||
const pos = resolveSolids(G.player.x, G.player.y, G.player.r);
|
||||
G.player.x = pos.x;
|
||||
G.player.y = pos.y;
|
||||
}
|
||||
// Iron Lung: re-arm the once-per-room hit block
|
||||
if (G.player && G.player.stats.ironLung > 0) G.player.ironLungReady = true;
|
||||
@@ -132,6 +187,10 @@ function enterRoom(gx, gy) {
|
||||
// boss fights are a pure ammo drain, so stock the room on the way in
|
||||
spawnPickup('ammo', a.cx, a.cy + 140);
|
||||
Music.playBoss(boss.bossKind);
|
||||
G.mode = 'bossload';
|
||||
G.bossLoadSheet = boss.sprite + '_sheet';
|
||||
G.bossLoadT = BOSS_LOAD_MIN;
|
||||
Sprites.warm(G.bossLoadSheet);
|
||||
} else if (room.type === 'item') {
|
||||
spawnItemPedestal(a.cx - 45, a.cy, null, 'room');
|
||||
// item rooms sometimes also stock a weapon
|
||||
@@ -420,6 +479,10 @@ function drawRoom(ctx) {
|
||||
for (const d of r.decals) {
|
||||
Sprites.draw(ctx, d.img, d.x, d.y, d.rot, 48 * d.s, false, 0.55);
|
||||
}
|
||||
for (const o of r.obstacles) {
|
||||
Sprites.draw(ctx, 'decal_blood1', o.x, o.y, 0, o.r * 2.4, false, 0.92);
|
||||
Sprites.draw(ctx, 'decal_blood3', o.x, o.y, 0.7, o.r * 1.7, false, 0.75);
|
||||
}
|
||||
// hazards
|
||||
for (const h of G.hazards) {
|
||||
const k = 1 - h.t / h.life;
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ const SfxBank = {
|
||||
if (this.buffers.has(name) || this.pending.has(name) || this.failed.has(name)) return;
|
||||
const file = this.FILES[name];
|
||||
if (!file || !this.ctx || typeof fetch !== 'function') return;
|
||||
const job = fetch('/assets/sfx/' + encodeURIComponent(file) + '?v=58')
|
||||
const job = fetch('/assets/sfx/' + encodeURIComponent(file) + '?v=60')
|
||||
.then(r => { if (!r.ok) throw new Error('HTTP ' + r.status); return r.arrayBuffer(); })
|
||||
.then(bytes => this.ctx.decodeAudioData(bytes))
|
||||
.then(buffer => this.buffers.set(name, this.trim(buffer)))
|
||||
|
||||
+19
-2
@@ -88,15 +88,32 @@ const Sprites = {
|
||||
const finish = () => { if (--pending === 0) G.imagesLoaded = true; };
|
||||
img.onload = () => { this.imgs[name] = img; if (typeof img.decode === 'function') img.decode().then(finish, finish); else finish(); };
|
||||
img.onerror = () => {
|
||||
if (hd && !img._sdRetry) { img._sdRetry = true; img.src = 'assets/' + name + '.png?v=58'; return; }
|
||||
if (hd && !img._sdRetry) { img._sdRetry = true; img.src = 'assets/' + name + '.png?v=60'; return; }
|
||||
this.imgs[name] = null;
|
||||
finish();
|
||||
};
|
||||
img.src = hd ? 'assets/hd/' + name + '.webp?v=58' : 'assets/' + name + '.png?v=58';
|
||||
img.src = hd ? 'assets/hd/' + name + '.webp?v=60' : 'assets/' + name + '.png?v=60';
|
||||
}
|
||||
},
|
||||
|
||||
get(name) { return this.imgs[name] || null; },
|
||||
|
||||
forceUpload(img) {
|
||||
if (typeof document === 'undefined' || !document.createElement) return;
|
||||
if (!document.createElement('canvas').getContext) return;
|
||||
if (!this._warmCtx) {
|
||||
const c = document.createElement('canvas');
|
||||
c.width = 1; c.height = 1;
|
||||
this._warmCtx = c.getContext('2d');
|
||||
}
|
||||
if (this._warmCtx) this._warmCtx.drawImage(img, 0, 0, 1, 1);
|
||||
},
|
||||
|
||||
warm(name) {
|
||||
if (this.imgs[name]) { this.forceUpload(this.imgs[name]); return true; }
|
||||
return this.imgs[name] !== undefined;
|
||||
},
|
||||
|
||||
// Compact player-only strip: eight forward-facing stride frames.
|
||||
// Runtime rotation is smooth; distance-driven phase keeps contacts from skating.
|
||||
legs(ctx, x, y, facing, phase, targetW) {
|
||||
|
||||
@@ -51,6 +51,8 @@ const G = {
|
||||
hudAlpha: 1,
|
||||
hdRemaster: false,
|
||||
imagesLoaded: false,
|
||||
bossLoadT: 0,
|
||||
bossLoadSheet: null,
|
||||
roomLayer: null,
|
||||
roomLayerKey: '',
|
||||
atmosphereLayer: null,
|
||||
@@ -72,6 +74,7 @@ const PRESSURE_GAIN = PRESSURE_UNIT; // retained: dial 0 == 1 point
|
||||
const PRESSURE_DROP_BASE = 3; // dial 0 == 0.03 relief base
|
||||
const PRESSURE_RELIEF_MUL = 0.5; // global brake: all pressure drops (hit relief + passive decay) are halved
|
||||
const DEATH_LOCK = 3;
|
||||
const BOSS_LOAD_MIN = 1.0;
|
||||
const PRESSURE_DIAL_MIN = -10, PRESSURE_DIAL_MAX = 10;
|
||||
|
||||
function hdScale() { return G.hdRemaster ? 4 : 1; }
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ const WEAPONS = {
|
||||
trapqueen: { id: 'trapqueen', name: 'Trap Queen', held: 58, torsoW: 124, torsoFwd: 21, muzzle: 73, tier: 2, ammo: 26, refill: 13, interval: 0.55, dmg: 10, spd: 999, behavior: 'lob_trap', sprite: 'bullet_saw', sfx: 'lob', punch: 0.65, desc: 'Bear traps. For bears. And worse' },
|
||||
tenderizer: { id: 'tenderizer', name: 'The Tenderizer', held: 66, torsoW: 132, torsoFwd: 23, muzzle: 78, tier: 3, ammo: 10, refill: 5, interval: 0.58, dmg: 60, spd: 0, behavior: 'slam', sprite: 'bullet_bone', sfx: 'heavy', punch: 1.00, desc: 'A room-shaking close-range meat paste' },
|
||||
redhand: { id: 'redhand', name: 'Red Right Hand', held: 68, torsoW: 134, torsoFwd: 24, muzzle: 80, tier: 2, ammo: 150, refill: 72, drain: 18, interval: 0.10, dmg: 7, spd: 0, behavior: 'saw', sprite: 'bullet_saw', sfx: 'saw', punch: 0.38, desc: 'A chainsaw that liquefies anything in reach' },
|
||||
spinaltap: { id: 'spinaltap', name: 'Spinal Tap', held: 68, torsoW: 136, torsoFwd: 24, muzzle: 81, tier: 3, ammo: 7, refill: 4, interval: 0.30, dmg: 95, spd: 0, chargeTime: 0.85, behavior: 'beam', sprite: 'bullet_bone', sfx: 'beam', punch: 1.00, desc: 'Charge it. Delete a line of meat' },
|
||||
spinaltap: { id: 'spinaltap', name: 'Spinal Tap', held: 68, torsoW: 136, torsoFwd: 24, muzzle: 81, tier: 3, ammo: 7, refill: 4, interval: 0.30, dmg: 190, spd: 0, chargeTime: 0.85, behavior: 'beam', sprite: 'bullet_bone', sfx: 'beam', punch: 1.00, desc: 'Charge it. Delete a line of meat' },
|
||||
swarmjar: { id: 'swarmjar', name: 'Swarm Jar', held: 62, torsoW: 124, torsoFwd: 21, muzzle: 73, tier: 3, ammo: 12, refill: 6, interval: 0.80, dmg: 9, spd: 999, behavior: 'lob_swarm', sprite: 'bullet_gore', sfx: 'lob', punch: 0.70, desc: 'A jar of friends. They are hungry' },
|
||||
};
|
||||
|
||||
@@ -215,7 +215,7 @@ function fireBeam(p, def, charge) {
|
||||
p.actionT = 0;
|
||||
addShake(8);
|
||||
Sfx.shoot(def);
|
||||
p.weapon.ammo -= 1 / st.ammoEff;
|
||||
if (!(p.marrowDraughtT > 0)) p.weapon.ammo -= 1 / st.ammoEff;
|
||||
}
|
||||
|
||||
// damage every enemy in a radius (slams, explosions)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "meatslicer",
|
||||
"productName": "MeatSlicer",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.5",
|
||||
"private": true,
|
||||
"description": "A Butcher's Descent - clear, harvest, descend.",
|
||||
"main": "desktop/main.js",
|
||||
|
||||
+83
-4
@@ -64,7 +64,7 @@ for (const f of files) {
|
||||
}
|
||||
// const/let top-level bindings live in the context's lexical scope, not on the
|
||||
// global object — expose the ones the harness pokes at directly.
|
||||
vm.runInContext('Object.assign(this, { G, Input, WEAPONS, Music, Sfx, SfxBank, W, H, WALL, ITEMS, ACTIVES, PERKS, ENEMY_TYPES, BOSS_DEFS, SPRITE_MANIFEST, Sprites, ACTOR_ANIMS, PRESSURE_UNIT, PRESSURE_MIN, PRESSURE_MAX, PRESSURE_DIAL_MIN, PRESSURE_DIAL_MAX, PRESSURE_DROP_BASE, PRESSURE_RELIEF_MUL, ROOM_SHAPES, ROOM_THEMES, HELP_PAGES, HELP_RENDERERS, SPAWN_WARN, ENTRY_WARN, ENTRY_BUFFER, STUN_UNIT, stunChance, separateEntryWave, defaultPlayerStats, applyPressureDelta, debugRebuildStats, debugRefillAmmo, debugEnabled, DEBUG_PAGES, updateCamera, mxW, myW, angleTo, genFloor, roomBounds, WEAPON_DROP_LOCKOUT, CAM_EDGE_PEEK })', sandbox);
|
||||
vm.runInContext('Object.assign(this, { G, Input, WEAPONS, Music, Sfx, SfxBank, W, H, WALL, ITEMS, ACTIVES, PERKS, ENEMY_TYPES, BOSS_DEFS, SPRITE_MANIFEST, Sprites, ACTOR_ANIMS, PRESSURE_UNIT, PRESSURE_MIN, PRESSURE_MAX, PRESSURE_DIAL_MIN, PRESSURE_DIAL_MAX, PRESSURE_DROP_BASE, PRESSURE_RELIEF_MUL, ROOM_SHAPES, ROOM_THEMES, HELP_PAGES, HELP_RENDERERS, SPAWN_WARN, ENTRY_WARN, ENTRY_BUFFER, STUN_UNIT, stunChance, separateEntryWave, defaultPlayerStats, applyPressureDelta, debugRebuildStats, debugRefillAmmo, debugEnabled, DEBUG_PAGES, updateCamera, mxW, myW, angleTo, genFloor, roomBounds, WEAPON_DROP_LOCKOUT, CAM_EDGE_PEEK, placeRoomObstacles, resolveSolids, spawnDashBurst })', sandbox);
|
||||
|
||||
let simTime = 0;
|
||||
const ctx = sandbox;
|
||||
@@ -84,6 +84,8 @@ function fire(ev, key) {
|
||||
function press(key) { fire('keydown', key); }
|
||||
function release(key) { fire('keyup', key); }
|
||||
function tap(key) { press(key); step(1, 16); release(key); }
|
||||
function drainBossLoad() { let g = 0; while (ctx.G.mode === 'bossload' && g++ < 150) step(1, 16); }
|
||||
|
||||
|
||||
let failures = 0;
|
||||
function check(name, cond) {
|
||||
@@ -216,7 +218,7 @@ check('HD loader loads all images (fallbacks)', ctx.G.imagesLoaded === true);
|
||||
let hdFallbackOk = 0;
|
||||
for (const name of ctx.SPRITE_MANIFEST) {
|
||||
const urls = attemptedUrls[name];
|
||||
const ok = urls && urls.length === 2 && urls[0] === 'assets/hd/' + name + '.webp?v=58' && urls[1] === 'assets/' + name + '.png?v=58';
|
||||
const ok = urls && urls.length === 2 && urls[0] === 'assets/hd/' + name + '.webp?v=60' && urls[1] === 'assets/' + name + '.png?v=60';
|
||||
if (ok) hdFallbackOk++;
|
||||
}
|
||||
check('HD loader tries WebP then PNG per sprite', hdFallbackOk === ctx.SPRITE_MANIFEST.length);
|
||||
@@ -241,7 +243,7 @@ check('SD loader loads all images', ctx.G.imagesLoaded === true);
|
||||
let sdUrlOk = 0;
|
||||
for (const name of ctx.SPRITE_MANIFEST) {
|
||||
const urls = attemptedUrls[name];
|
||||
const ok = urls && urls.length === 1 && urls[0] === 'assets/' + name + '.png?v=58';
|
||||
const ok = urls && urls.length === 1 && urls[0] === 'assets/' + name + '.png?v=60';
|
||||
if (ok) sdUrlOk++;
|
||||
}
|
||||
check('SD loader requests one PNG per sprite', sdUrlOk === ctx.SPRITE_MANIFEST.length);
|
||||
@@ -1127,6 +1129,7 @@ console.log('== generic ammo drops ==');
|
||||
ctx.WEAPONS.repeater.refill > ctx.WEAPONS.spinaltap.refill * 10);
|
||||
check('stream weapons are time-denominated (drain, not per-shot)',
|
||||
ctx.WEAPONS.bile.drain > 0 && ctx.WEAPONS.cauterizer.drain > 0 && ctx.WEAPONS.redhand.drain > 0);
|
||||
check('Spinal Tap base damage is 190', ctx.WEAPONS.spinaltap.dmg === 190);
|
||||
|
||||
const repeaterCap = ctx.WEAPONS.repeater.ammo * 1.5;
|
||||
p.weapon = { id: 'repeater', ammo: repeaterCap - 1 };
|
||||
@@ -1197,6 +1200,28 @@ console.log('== hearts stay on the floor at full HP ==');
|
||||
ctx.startRun(); step(3, 16);
|
||||
}
|
||||
|
||||
console.log('== Second Stomach hearts fill overflow shields ==');
|
||||
{
|
||||
ctx.startRun(); step(3, 16);
|
||||
const p = ctx.G.player;
|
||||
ctx.giveItem('secondstomach');
|
||||
p.hp = p.stats.maxHp;
|
||||
p.shieldHp = 0;
|
||||
const cap = (p.stats.shieldPerk || 0) + p.stats.overShield;
|
||||
ctx.G.pickups.length = 0;
|
||||
ctx.G.enemies.length = 0;
|
||||
ctx.spawnPickup('heart', p.x, p.y);
|
||||
step(2, 16);
|
||||
check('Second Stomach collects heart at full HP', ctx.G.pickups.length === 0);
|
||||
check('heart overflow fills shields', p.hp === p.stats.maxHp && p.shieldHp === Math.min(cap, 2));
|
||||
p.hp = p.stats.maxHp;
|
||||
p.shieldHp = cap;
|
||||
ctx.spawnPickup('heart', p.x, p.y);
|
||||
step(2, 16);
|
||||
check('heart stays when Second Stomach shields are full', ctx.G.pickups.length === 1);
|
||||
ctx.startRun(); step(3, 16);
|
||||
}
|
||||
|
||||
console.log('== dash: burst, slow, cooldown ==');
|
||||
{
|
||||
ctx.startRun(); step(3, 16);
|
||||
@@ -1254,6 +1279,47 @@ console.log('== dash: burst, slow, cooldown ==');
|
||||
ctx.startRun(); step(3, 16);
|
||||
}
|
||||
|
||||
console.log('== large-room blood pools and dash gore ==');
|
||||
{
|
||||
ctx.startRun(); step(3, 16);
|
||||
const hall = ctx.makeRoom(0, 0, 'combat'); hall.shape = 'hall'; hall.doors = {};
|
||||
ctx.placeRoomObstacles(hall);
|
||||
check('small rooms get no obstacles', hall.obstacles.length === 0);
|
||||
|
||||
const meat = ctx.makeRoom(1, 0, 'combat'); meat.shape = 'meat_hall';
|
||||
meat.doors = { e: true, w: true, n: false, s: false };
|
||||
ctx.placeRoomObstacles(meat);
|
||||
check('meat_hall places five pools', meat.obstacles.length === 5);
|
||||
const mb = ctx.roomBounds(meat);
|
||||
check('pools stay off center and doors', meat.obstacles.every(o =>
|
||||
Math.hypot(o.x - mb.cx, o.y - mb.cy) >= 110));
|
||||
|
||||
ctx.G.cur = meat; ctx.setArenaForRoom(meat);
|
||||
const o = meat.obstacles[0];
|
||||
const pushed = ctx.resolveSolids(o.x, o.y, 20);
|
||||
check('resolveSolids pushes out of a pool', Math.hypot(pushed.x - o.x, pushed.y - o.y) >= o.r + 20 - 0.05);
|
||||
|
||||
const p = ctx.G.player;
|
||||
p.x = o.x - (o.r + p.r + 8); p.y = o.y; p.dashSlowT = 0;
|
||||
ctx.G.parts.length = 0;
|
||||
ctx.Input.keys.d = true;
|
||||
press('shift'); step(1, 16); release('shift');
|
||||
check('dash does not enter the pool', Math.hypot(p.x - o.x, p.y - o.y) >= o.r + p.r - 0.05);
|
||||
check('dash emits a bloodball', ctx.G.parts.some(pt => pt.type === 'bloodball'));
|
||||
ctx.Input.keys.d = false;
|
||||
|
||||
ctx.G.bullets.length = 0;
|
||||
ctx.G.bullets.push({
|
||||
x: o.x - 80, y: o.y, vx: 400, vy: 0, r: 5, dmg: 1,
|
||||
pierce: 0, bounce: 0, bounces: 0, life: 1, t: 0, behavior: 'bullet',
|
||||
sprite: 'bullet_bone', homing: 0, hit: null, dragTarget: null,
|
||||
});
|
||||
ctx.updateBullets(0.3);
|
||||
check('projectiles pass through pools', ctx.G.bullets.length === 1 && ctx.G.bullets[0].x > o.x);
|
||||
|
||||
ctx.startRun(); step(3, 16);
|
||||
}
|
||||
|
||||
console.log('== debug refill tops up holstered specials ==');
|
||||
{
|
||||
ctx.startRun(); step(3, 16);
|
||||
@@ -1297,6 +1363,13 @@ console.log('== muzzle origins match projectile origins ==');
|
||||
const beamParts = ctx.G.parts.filter(pt => pt.type === 'beam');
|
||||
const newest = beamParts[beamParts.length - 1];
|
||||
check('beam particle starts at spinaltap muzzle (81px)', newest && Math.abs(newest.x - (p.x + 81)) < 0.01 && Math.abs(newest.y - (p.y)) < 0.01);
|
||||
p.weapon = { id: 'spinaltap', ammo: 7 };
|
||||
p.marrowDraughtT = 5;
|
||||
ctx.fireBeam(p, ctx.WEAPONS.spinaltap, 1);
|
||||
check('Marrow Draught fireBeam spends no ammo', p.weapon.ammo === 7);
|
||||
p.marrowDraughtT = 0;
|
||||
ctx.fireBeam(p, ctx.WEAPONS.spinaltap, 1);
|
||||
check('fireBeam spends ammo without Marrow Draught', p.weapon.ammo === 6);
|
||||
ctx.G.bullets.length = 0;
|
||||
ctx.startRun(); step(3, 16);
|
||||
}
|
||||
@@ -1875,7 +1948,12 @@ check('floor 2', ctx.G.floor === 2);
|
||||
const bossRoom = Object.values(ctx.G.rooms).find(r => r.type === 'boss');
|
||||
check('boss room exists', !!bossRoom);
|
||||
ctx.enterRoom(bossRoom.gx, bossRoom.gy);
|
||||
step(10, 16);
|
||||
step(1, 16);
|
||||
check('boss room opens a loading screen', ctx.G.mode === 'bossload');
|
||||
drainBossLoad();
|
||||
check('boss loading screen resolves to play', ctx.G.mode === 'play');
|
||||
check('boss sheet warm helper exists', typeof ctx.Sprites.warm === 'function');
|
||||
check('elite summoner count uses 4-6', (() => { const e = ctx.makeEnemy('broodsac', 400, 300, 3, true); return e.elite === true; })());
|
||||
check('boss spawned', !!ctx.G.boss);
|
||||
check('boss hp is finite', ctx.G.boss && isFinite(ctx.G.boss.hp));
|
||||
check('boss music playing', ctx.Music.current && ctx.Music.current.name.includes('Boss'));
|
||||
@@ -2184,6 +2262,7 @@ ctx.nextFloor(); step(5, 16);
|
||||
check('override survives floor change', ctx.Music.current.name === ctx.Music.PLAYLIST[1]);
|
||||
const jbr = Object.values(ctx.G.rooms).find(r => r.type === 'boss');
|
||||
ctx.enterRoom(jbr.gx, jbr.gy); step(5, 16);
|
||||
drainBossLoad();
|
||||
check('boss track interrupts override', ctx.Music.current.name.includes('Boss'));
|
||||
ctx.Music.cycle(1); // cycling during a boss must not cut the boss track
|
||||
check('boss track not interrupted', ctx.Music.current.name.includes('Boss'));
|
||||
|
||||
@@ -390,6 +390,12 @@ def reference_payload(name: str) -> list[dict]:
|
||||
if not REFERENCE.exists():
|
||||
raise SystemExit(f"Missing style reference: {REFERENCE}")
|
||||
references = [{"type": "image_url", "image_url": {"url": data_url(REFERENCE)}}]
|
||||
if name.startswith(("w_", "wt_", "pt_")):
|
||||
mid = name[3:] if name.startswith(("wt_", "pt_")) else name[2:]
|
||||
prefix = "wt_" if name.startswith(("wt_", "pt_")) else "w_"
|
||||
model = RAW / "guides" / "models" / f"{prefix}{mid}.png"
|
||||
if model.exists():
|
||||
references.append({"type": "image_url", "image_url": {"url": data_url(model)}})
|
||||
guide = shape_guide(name)
|
||||
if guide:
|
||||
references.append({"type": "image_url", "image_url": {"url": data_url(guide)}})
|
||||
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render Meshy weapon GLBs to 2D magenta-backed stills via Blender."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
BLENDER_SCRIPT = Path(__file__).resolve().parent / "render_model_refs_blender.py"
|
||||
IN_DIR = ROOT / "assets" / "raw" / "models"
|
||||
OUT_DIR = ROOT / "assets" / "raw" / "guides" / "models"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
blender = shutil.which("blender")
|
||||
if not blender:
|
||||
print("blender: missing binary; skipping model reference renders")
|
||||
return 0
|
||||
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
cmd = [
|
||||
blender,
|
||||
"--background",
|
||||
"--python",
|
||||
str(BLENDER_SCRIPT),
|
||||
"--",
|
||||
"--in",
|
||||
str(IN_DIR),
|
||||
"--out",
|
||||
str(OUT_DIR),
|
||||
]
|
||||
print(" ".join(cmd))
|
||||
return subprocess.call(cmd)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+141
@@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Blender 5.2: orthographic stills of each weapon_<id>.glb."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import math
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import bpy
|
||||
from mathutils import Vector
|
||||
|
||||
|
||||
MAGENTA = (1.0, 0.0, 1.0, 1.0)
|
||||
|
||||
|
||||
def parse_args(argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--in", dest="in_dir", required=True)
|
||||
parser.add_argument("--out", dest="out_dir", required=True)
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
def reset_scene():
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
scene = bpy.context.scene
|
||||
scene.render.engine = "BLENDER_EEVEE"
|
||||
scene.render.resolution_x = 1024
|
||||
scene.render.resolution_y = 1024
|
||||
scene.render.film_transparent = False
|
||||
scene.render.image_settings.file_format = "PNG"
|
||||
scene.render.image_settings.color_mode = "RGBA"
|
||||
world = bpy.data.worlds.new("Magenta")
|
||||
scene.world = world
|
||||
world.use_nodes = True
|
||||
bg = world.node_tree.nodes.get("Background")
|
||||
if bg:
|
||||
bg.inputs[0].default_value = MAGENTA
|
||||
bg.inputs[1].default_value = 1.0
|
||||
light_data = bpy.data.lights.new("Sun", "SUN")
|
||||
light_data.energy = 5.0
|
||||
light = bpy.data.objects.new("Sun", light_data)
|
||||
scene.collection.objects.link(light)
|
||||
light.location = (-1.0, -1.0, 2.0)
|
||||
light.rotation_euler = (math.atan2(math.hypot(1, 1), 2), 0.0, math.atan2(-1, -1))
|
||||
cam_data = bpy.data.cameras.new("Cam")
|
||||
cam_data.type = "ORTHO"
|
||||
cam_data.ortho_scale = 2.4
|
||||
cam = bpy.data.objects.new("Cam", cam_data)
|
||||
scene.collection.objects.link(cam)
|
||||
scene.camera = cam
|
||||
return scene, cam
|
||||
|
||||
|
||||
def import_weapon(path: Path):
|
||||
before = set(bpy.data.objects)
|
||||
bpy.ops.import_scene.gltf(filepath=str(path))
|
||||
imported = [obj for obj in bpy.data.objects if obj not in before]
|
||||
meshes = [obj for obj in imported if obj.type == "MESH"]
|
||||
if not meshes:
|
||||
return None
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
for obj in meshes:
|
||||
obj.select_set(True)
|
||||
bpy.context.view_layer.objects.active = meshes[0]
|
||||
if len(meshes) > 1:
|
||||
bpy.ops.object.join()
|
||||
joined = bpy.context.view_layer.objects.active
|
||||
return joined
|
||||
|
||||
|
||||
def normalize_weapon(obj):
|
||||
bpy.context.view_layer.update()
|
||||
bbox = [obj.matrix_world @ Vector(corner) for corner in obj.bound_box]
|
||||
min_c = Vector((min(v.x for v in bbox), min(v.y for v in bbox), min(v.z for v in bbox)))
|
||||
max_c = Vector((max(v.x for v in bbox), max(v.y for v in bbox), max(v.z for v in bbox)))
|
||||
size = max_c - min_c
|
||||
longest = max(size.x, size.y, size.z, 1e-6)
|
||||
scale = 2.0 / longest
|
||||
obj.scale *= scale
|
||||
bpy.context.view_layer.update()
|
||||
bbox = [obj.matrix_world @ Vector(corner) for corner in obj.bound_box]
|
||||
center = sum(bbox, Vector()) / 8.0
|
||||
obj.location -= center
|
||||
bpy.context.view_layer.update()
|
||||
bbox = [obj.matrix_world @ Vector(corner) for corner in obj.bound_box]
|
||||
min_c = Vector((min(v.x for v in bbox), min(v.y for v in bbox), min(v.z for v in bbox)))
|
||||
max_c = Vector((max(v.x for v in bbox), max(v.y for v in bbox), max(v.z for v in bbox)))
|
||||
size = max_c - min_c
|
||||
axis = max(((size.x, "x"), (size.y, "y"), (size.z, "z")))[1]
|
||||
if axis == "y":
|
||||
obj.rotation_euler[2] += -math.pi / 2
|
||||
elif axis == "z":
|
||||
obj.rotation_euler[1] += math.pi / 2
|
||||
bpy.context.view_layer.update()
|
||||
bbox = [obj.matrix_world @ Vector(corner) for corner in obj.bound_box]
|
||||
center = sum(bbox, Vector()) / 8.0
|
||||
obj.location -= center
|
||||
bpy.context.view_layer.update()
|
||||
|
||||
|
||||
def aim_camera(cam, location):
|
||||
cam.location = location
|
||||
direction = Vector((0.0, 0.0, 0.0)) - Vector(location)
|
||||
cam.rotation_euler = direction.to_track_quat("-Z", "Y").to_euler()
|
||||
|
||||
|
||||
def render_to(scene, path: Path):
|
||||
scene.render.filepath = str(path)
|
||||
bpy.ops.render.render(write_still=True)
|
||||
|
||||
|
||||
def main(argv):
|
||||
args = parse_args(argv)
|
||||
in_dir = Path(args.in_dir)
|
||||
out_dir = Path(args.out_dir)
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
glbs = sorted(in_dir.glob("weapon_*.glb"))
|
||||
for glb in glbs:
|
||||
wid = glb.stem[len("weapon_") :]
|
||||
scene, cam = reset_scene()
|
||||
obj = import_weapon(glb)
|
||||
if obj is None:
|
||||
print(f"skip {glb.name}: no mesh")
|
||||
continue
|
||||
normalize_weapon(obj)
|
||||
aim_camera(cam, (0.0, 0.0, 4.0))
|
||||
render_to(scene, out_dir / f"wt_{wid}.png")
|
||||
aim_camera(cam, (0.0, -3.2, 1.4))
|
||||
render_to(scene, out_dir / f"w_{wid}.png")
|
||||
print(f"rendered {wid}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
argv = sys.argv
|
||||
if "--" in argv:
|
||||
argv = argv[argv.index("--") + 1 :]
|
||||
else:
|
||||
argv = []
|
||||
main(argv)
|
||||
Reference in new issue
Block a user