Use four-frame rotating player airship

This commit is contained in:
Admin 2026-09-19 03:47:59 +00:00
parent 69e67b50e9
commit fcba9c74ab
2 changed files with 21 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import Phaser from 'phaser';
import './style.css';
import airshipSheetUrl from './assets/airships.svg?url';
import playerAirshipUrl from './assets/player-airship-4frame.png?url';
import explosionSheetUrl from './assets/explosions.svg?url';
import cannonballUrl from './assets/cannonball.png?url';
import { airshipLog, registerDebugSnapshot } from './diagnostics.js';
@ -77,6 +78,10 @@ class GameScene extends Phaser.Scene {
frameWidth: 64,
frameHeight: 64,
});
this.load.spritesheet('player-airship', playerAirshipUrl, {
frameWidth: 128,
frameHeight: 256,
});
this.load.spritesheet('explosions', explosionSheetUrl, {
frameWidth: 64,
frameHeight: 64,
@ -89,10 +94,10 @@ class GameScene extends Phaser.Scene {
this.drawWorld();
this.createAnimations();
this.player = this.physics.add.sprite(1200, 1550, 'airships', 0);
this.player.setDepth(6).setCollideWorldBounds(true).setDisplaySize(74, 74);
this.player = this.physics.add.sprite(1200, 1550, 'player-airship', 0);
this.player.setDepth(6).setCollideWorldBounds(true).setDisplaySize(66, 126);
this.player.body.setAllowGravity(false);
this.player.body.setSize(42, 56, true);
this.player.body.setCircle(44, 20, 84);
this.player.play('player-idle');
this.pirates = this.physics.add.group();
@ -253,7 +258,7 @@ class GameScene extends Phaser.Scene {
if (!this.anims.exists('player-idle')) {
this.anims.create({
key: 'player-idle',
frames: this.anims.generateFrameNumbers('airships', { start: 0, end: 3 }),
frames: this.anims.generateFrameNumbers('player-airship', { start: 0, end: 3 }),
frameRate: 5,
repeat: -1,
});

View File

@ -194,6 +194,18 @@ test('player and pirate broadsides use the cannonball image asset', async () =>
assert.doesNotMatch(source, /generateTexture\('pirate-shot'/);
});
test('player uses the four-frame north-facing airship sheet with a compact circular body', async () => {
const source = await read('src/game-v4.js');
assert.match(source, /import playerAirshipUrl from '.\/assets\/player-airship-4frame\.png\?url'/);
assert.match(source, /this\.load\.spritesheet\('player-airship', playerAirshipUrl, \{[\s\S]*?frameWidth: 128,[\s\S]*?frameHeight: 256/);
assert.match(source, /this\.physics\.add\.sprite\(1200, 1550, 'player-airship', 0\)/);
assert.match(source, /setDisplaySize\(66, 126\)/);
assert.match(source, /this\.player\.body\.setCircle\(44, 20, 84\)/);
assert.match(source, /generateFrameNumbers\('player-airship', \{ start: 0, end: 3 \}\)/);
assert.doesNotMatch(source, /this\.player\.body\.setSize\(42, 56, true\)/);
});
test('mobile HUD skips hidden Phaser rendering and throttles DOM state publishing', async () => {
const source = await read('src/game-v4.js');