Added Characters and Backgrounds to Puzzle Mode on Tetris Attack

This commit is contained in:
Brian Fertig 2026-07-27 19:31:51 -06:00
parent 7de6b71776
commit 1ad2942241
1 changed files with 38 additions and 0 deletions

View File

@ -182,6 +182,10 @@ export default class TetrisAttackGame extends Phaser.Scene {
const p = this.puzzles[puzzleIndex] ?? this.puzzles[0]; const p = this.puzzles[puzzleIndex] ?? this.puzzles[0];
this.currentPuzzle = p; this.currentPuzzle = p;
this.state = newGame({ mode: 'puzzle', puzzle: { grid: p.grid, maxMoves: p.maxMoves }, rng }); this.state = newGame({ mode: 'puzzle', puzzle: { grid: p.grid, maxMoves: p.maxMoves }, rng });
const { round, bgKey } = this.getPuzzleHeroInfo(puzzleIndex);
this.currentRound = round;
this._puzzleBgKey = bgKey;
this.ensureRoundAssets(round);
} else if (mode === 'stageclear') { } else if (mode === 'stageclear') {
this.currentRound = round; this.currentRound = round;
this.stageNumber = stageNumber; this.stageNumber = stageNumber;
@ -211,6 +215,7 @@ export default class TetrisAttackGame extends Phaser.Scene {
if (mode === 'stageclear') this.setStageBackground(round.characterId, stageNumber); if (mode === 'stageclear') this.setStageBackground(round.characterId, stageNumber);
else if (mode === 'endless') this.setEndlessHeroBackground(0); else if (mode === 'endless') this.setEndlessHeroBackground(0);
else if (mode === 'puzzle') this.setPuzzleBackground();
else this.setStageBackground(null); else this.setStageBackground(null);
this.buildHUD(); this.buildHUD();
this.playing = true; this.playing = true;
@ -301,6 +306,9 @@ export default class TetrisAttackGame extends Phaser.Scene {
const idx = (this.state.level - 1) % this.endlessHeroOrder.length; const idx = (this.state.level - 1) % this.endlessHeroOrder.length;
this.setEndlessHeroBackground(idx); this.setEndlessHeroBackground(idx);
} }
if (this.mode === 'puzzle') {
this.setPuzzleBackground();
}
// an intro cutscene waiting on this friend's art can dress itself now // an intro cutscene waiting on this friend's art can dress itself now
this.onBackgroundsLoaded?.(); this.onBackgroundsLoaded?.();
}); });
@ -362,6 +370,25 @@ export default class TetrisAttackGame extends Phaser.Scene {
this.hostPortrait.setPose('happy', 1500); this.hostPortrait.setPose('happy', 1500);
} }
// ── Puzzle-mode hero mapping ────────────────────────────────────────────────
// 24 puzzles / 6 heroes = 4 puzzles per hero, in Stage Clear order.
// Beth puzzles 03 → backgrounds r1r4
// Jerry puzzles 47 → backgrounds r1r4
// etc.
getPuzzleHeroInfo(puzzleIndex) {
const heroIndex = Math.floor(puzzleIndex / 4);
const stageNumber = (puzzleIndex % 4) + 1;
const round = this.rounds[heroIndex] ?? this.rounds[0];
return { round, bgKey: `tetrisattack-bg-${round.characterId}-r${stageNumber}`, stageNumber, spriteIndex: heroIndex };
}
setPuzzleBackground() {
const key = this._puzzleBgKey;
if (!key || !this.textures.exists(key)) return;
if (this.heroBg) { this.heroBg.destroy(); this.heroBg = null; }
this.heroBg = this.add.image(GAME_WIDTH / 2, GAME_HEIGHT / 2, key).setDepth(D.bg + 2);
}
// ── Character voice ─────────────────────────────────────────────────────── // ── Character voice ───────────────────────────────────────────────────────
// The friend reacts out loud to big clears and to how the round ends. Only // The friend reacts out loud to big clears and to how the round ends. Only
// one line is ever in the air: a newer request replaces a pending one, and a // one line is ever in the air: a newer request replaces a pending one, and a
@ -889,6 +916,17 @@ export default class TetrisAttackGame extends Phaser.Scene {
}).setOrigin(0.5); }).setOrigin(0.5);
this.hudLayer.add(this._heroNameLabel); this.hudLayer.add(this._heroNameLabel);
} }
} else if (this.mode === 'puzzle') {
const round = this.currentRound;
if (round) {
this.hudLayer.add(this.add.text(GAME_WIDTH - 260, 138, 'PUZZLE', {
fontFamily: FONT, fontSize: '24px', color: '#9fb0c8',
}).setOrigin(0.5));
this.hostPortrait = createHostPortrait(this, GAME_WIDTH - 260, 360, round, this.rounds.indexOf(round));
this.hudLayer.add(this.add.text(GAME_WIDTH - 260, 560, round.name.toUpperCase(), {
fontFamily: FONT, fontSize: '34px', color: '#ffe66e',
}).setOrigin(0.5));
}
} }
const controls = ['◀ ▲ ▼ ▶ move', 'SPACE / Z swap']; const controls = ['◀ ▲ ▼ ▶ move', 'SPACE / Z swap'];