SpaceRace: Full-width TV field, death line scrolling, camera following leader, jump fix, path never fully blocked, player color on controller

This commit is contained in:
2026-06-24 16:41:37 +02:00
commit 5e2ab43ca3
46 changed files with 6581 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
import Phaser from 'phaser';
import { Ship as ShipType } from '@spacerace/shared';
export class ShipSprite extends Phaser.GameObjects.Container {
private shipData: ShipType;
private label: Phaser.GameObjects.Text;
constructor(
scene: Phaser.Scene,
x: number,
y: number,
ship: ShipType,
color: number,
) {
super(scene, x, y);
this.shipData = ship;
const angles: Record<string, number> = { N: 0, E: 90, S: 180, W: 270 };
const baseAngle = angles[ship.direction] || 0;
// Ship body
const body = scene.add.rectangle(0, 0, 40, 36, color);
body.setStrokeStyle(2, 0xffffff);
// Direction indicator (small triangle)
const indicator = scene.add.triangle(0, -22, 0, 8, 5, 0, 10, 8, 0xffffff);
this.add([body, indicator]);
this.setAngle(baseAngle);
// Player name label
this.label = scene.add.text(0, 28, ship.playerName || ship.playerId.substring(0, 6), {
fontSize: '11px',
color: '#ffffff',
fontFamily: 'monospace',
backgroundColor: '#00000088',
padding: { x: 2, y: 1 },
}).setOrigin(0.5);
this.add(this.label);
scene.add.existing(this);
this.setDepth(10);
}
updateState(ship: ShipType): void {
this.shipData = ship;
if (!ship.alive) {
this.setAlpha(0.3);
}
}
}