chore: initial commit
This commit is contained in:
47
src/scenes/BootScene.ts
Normal file
47
src/scenes/BootScene.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import Phaser from 'phaser';
|
||||
|
||||
/**
|
||||
* BootScene — loads all assets before the game starts.
|
||||
* Uses atlas loaded from public/atlas.json (Phaser hash format, converted from Napoletane atlas).
|
||||
*
|
||||
* [trueref /local/phaser] — this.load.atlas() loads a texture atlas where frames are
|
||||
* referenced by name (e.g. 'bastoni_7') using the Phaser hash format JSON.
|
||||
*/
|
||||
export class BootScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
super({ key: 'BootScene' });
|
||||
}
|
||||
|
||||
preload(): void {
|
||||
const W = this.scale.width;
|
||||
const H = this.scale.height;
|
||||
|
||||
// Loading bar
|
||||
const bar = this.add.rectangle(W / 2, H / 2, 400, 20, 0x4caf50);
|
||||
const barBg = this.add.rectangle(W / 2, H / 2, 402, 22, 0x1a5c2a);
|
||||
barBg.setDepth(0);
|
||||
bar.setDepth(1);
|
||||
bar.setOrigin(0.5);
|
||||
bar.scaleX = 0;
|
||||
|
||||
const label = this.add.text(W / 2, H / 2 - 40, 'Caricamento...', {
|
||||
fontFamily: 'serif',
|
||||
fontSize: '24px',
|
||||
color: '#ffffff',
|
||||
}).setOrigin(0.5);
|
||||
|
||||
this.load.on('progress', (value: number) => {
|
||||
bar.scaleX = value;
|
||||
});
|
||||
|
||||
// Load card atlas (Phaser hash format converted from Napoletane atlas)
|
||||
this.load.atlas('cards', 'atlas.png', 'atlas.json');
|
||||
|
||||
// Load card back separately
|
||||
this.load.image('retro', 'retro.png');
|
||||
}
|
||||
|
||||
create(): void {
|
||||
this.scene.start('MenuScene');
|
||||
}
|
||||
}
|
||||
1331
src/scenes/GameScene.ts
Normal file
1331
src/scenes/GameScene.ts
Normal file
File diff suppressed because it is too large
Load Diff
71
src/scenes/MenuScene.ts
Normal file
71
src/scenes/MenuScene.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import Phaser from 'phaser';
|
||||
|
||||
export class MenuScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
super({ key: 'MenuScene' });
|
||||
}
|
||||
|
||||
create(): void {
|
||||
const W = this.scale.width;
|
||||
const H = this.scale.height;
|
||||
|
||||
// Background felt
|
||||
this.add.rectangle(0, 0, W, H, 0x1a5c2a).setOrigin(0);
|
||||
|
||||
// Title
|
||||
this.add.text(W / 2, H * 0.2, 'Scopone Scientifico', {
|
||||
fontFamily: 'Georgia, serif',
|
||||
fontSize: '52px',
|
||||
color: '#ffd700',
|
||||
stroke: '#000000',
|
||||
strokeThickness: 4,
|
||||
}).setOrigin(0.5);
|
||||
|
||||
this.add.text(W / 2, H * 0.32, '2 vs 2 · Tu + Compagno vs 2 AI', {
|
||||
fontFamily: 'serif',
|
||||
fontSize: '22px',
|
||||
color: '#ccffcc',
|
||||
}).setOrigin(0.5);
|
||||
|
||||
// Rules summary
|
||||
const rules = [
|
||||
'40 carte Napoletane · 10 a testa',
|
||||
'Cattura per valore o somma',
|
||||
'Punteggio: Carte · Denari · Settebello · Primiera · Scope',
|
||||
'Prima squadra a 11 punti vince',
|
||||
];
|
||||
rules.forEach((line, i) => {
|
||||
this.add.text(W / 2, H * 0.44 + i * 28, line, {
|
||||
fontFamily: 'serif',
|
||||
fontSize: '18px',
|
||||
color: '#ffffff',
|
||||
}).setOrigin(0.5);
|
||||
});
|
||||
|
||||
// Start button
|
||||
const btn = this.add.rectangle(W / 2, H * 0.72, 220, 60, 0xffd700, 1)
|
||||
.setInteractive({ useHandCursor: true });
|
||||
const btnText = this.add.text(W / 2, H * 0.72, 'INIZIA PARTITA', {
|
||||
fontFamily: 'Georgia, serif',
|
||||
fontSize: '22px',
|
||||
color: '#1a5c2a',
|
||||
}).setOrigin(0.5);
|
||||
|
||||
btn.on('pointerover', () => btn.setFillStyle(0xffec6e));
|
||||
btn.on('pointerout', () => btn.setFillStyle(0xffd700));
|
||||
btn.on('pointerdown', () => {
|
||||
this.cameras.main.fadeOut(300, 0, 30, 0);
|
||||
this.cameras.main.once('camerafadeoutcomplete', () => {
|
||||
this.scene.start('GameScene');
|
||||
});
|
||||
});
|
||||
|
||||
// Show some face-down cards decoratively
|
||||
const positions = [
|
||||
[W * 0.1, H * 0.5], [W * 0.15, H * 0.52], [W * 0.9, H * 0.5], [W * 0.85, H * 0.52],
|
||||
];
|
||||
for (const [x, y] of positions) {
|
||||
this.add.image(x, y, 'retro').setScale(0.08).setAngle(Phaser.Math.Between(-15, 15));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user