Use four-frame rotating player airship
This commit is contained in:
parent
69e67b50e9
commit
fcba9c74ab
@ -1,6 +1,7 @@
|
|||||||
import Phaser from 'phaser';
|
import Phaser from 'phaser';
|
||||||
import './style.css';
|
import './style.css';
|
||||||
import airshipSheetUrl from './assets/airships.svg?url';
|
import airshipSheetUrl from './assets/airships.svg?url';
|
||||||
|
import playerAirshipUrl from './assets/player-airship-4frame.png?url';
|
||||||
import explosionSheetUrl from './assets/explosions.svg?url';
|
import explosionSheetUrl from './assets/explosions.svg?url';
|
||||||
import cannonballUrl from './assets/cannonball.png?url';
|
import cannonballUrl from './assets/cannonball.png?url';
|
||||||
import { airshipLog, registerDebugSnapshot } from './diagnostics.js';
|
import { airshipLog, registerDebugSnapshot } from './diagnostics.js';
|
||||||
@ -77,6 +78,10 @@ class GameScene extends Phaser.Scene {
|
|||||||
frameWidth: 64,
|
frameWidth: 64,
|
||||||
frameHeight: 64,
|
frameHeight: 64,
|
||||||
});
|
});
|
||||||
|
this.load.spritesheet('player-airship', playerAirshipUrl, {
|
||||||
|
frameWidth: 128,
|
||||||
|
frameHeight: 256,
|
||||||
|
});
|
||||||
this.load.spritesheet('explosions', explosionSheetUrl, {
|
this.load.spritesheet('explosions', explosionSheetUrl, {
|
||||||
frameWidth: 64,
|
frameWidth: 64,
|
||||||
frameHeight: 64,
|
frameHeight: 64,
|
||||||
@ -89,10 +94,10 @@ class GameScene extends Phaser.Scene {
|
|||||||
this.drawWorld();
|
this.drawWorld();
|
||||||
this.createAnimations();
|
this.createAnimations();
|
||||||
|
|
||||||
this.player = this.physics.add.sprite(1200, 1550, 'airships', 0);
|
this.player = this.physics.add.sprite(1200, 1550, 'player-airship', 0);
|
||||||
this.player.setDepth(6).setCollideWorldBounds(true).setDisplaySize(74, 74);
|
this.player.setDepth(6).setCollideWorldBounds(true).setDisplaySize(66, 126);
|
||||||
this.player.body.setAllowGravity(false);
|
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.player.play('player-idle');
|
||||||
|
|
||||||
this.pirates = this.physics.add.group();
|
this.pirates = this.physics.add.group();
|
||||||
@ -253,7 +258,7 @@ class GameScene extends Phaser.Scene {
|
|||||||
if (!this.anims.exists('player-idle')) {
|
if (!this.anims.exists('player-idle')) {
|
||||||
this.anims.create({
|
this.anims.create({
|
||||||
key: 'player-idle',
|
key: 'player-idle',
|
||||||
frames: this.anims.generateFrameNumbers('airships', { start: 0, end: 3 }),
|
frames: this.anims.generateFrameNumbers('player-airship', { start: 0, end: 3 }),
|
||||||
frameRate: 5,
|
frameRate: 5,
|
||||||
repeat: -1,
|
repeat: -1,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -194,6 +194,18 @@ test('player and pirate broadsides use the cannonball image asset', async () =>
|
|||||||
assert.doesNotMatch(source, /generateTexture\('pirate-shot'/);
|
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 () => {
|
test('mobile HUD skips hidden Phaser rendering and throttles DOM state publishing', async () => {
|
||||||
const source = await read('src/game-v4.js');
|
const source = await read('src/game-v4.js');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user