feat: add Phaser config factory, PreloadScene, and GameScene stub

This commit is contained in:
2026-04-07 21:04:25 +07:00
parent 35b5325125
commit c2acad828c
3 changed files with 53 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import Phaser from "phaser";
import { PreloadScene } from "./scenes/PreloadScene";
import { GameScene } from "./scenes/GameScene";
export function createPhaserConfig(
parent: HTMLElement,
width: number,
height: number
): Phaser.Types.Core.GameConfig {
return {
type: Phaser.AUTO,
parent,
width,
height,
backgroundColor: "#16213e",
scene: [PreloadScene, GameScene],
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
};
}
@@ -0,0 +1,16 @@
import Phaser from "phaser";
export class GameScene extends Phaser.Scene {
constructor() {
super({ key: "GameScene" });
}
create(): void {
this.add
.text(this.cameras.main.centerX, this.cameras.main.centerY, "Game Loading...", {
fontSize: "24px",
color: "#ffffff",
})
.setOrigin(0.5);
}
}
@@ -0,0 +1,15 @@
import Phaser from "phaser";
export class PreloadScene extends Phaser.Scene {
constructor() {
super({ key: "PreloadScene" });
}
preload(): void {
// No assets to load — emoji are rendered as text
}
create(): void {
this.scene.start("GameScene");
}
}