diff --git a/superpowers/src/phaser/config.ts b/superpowers/src/phaser/config.ts new file mode 100644 index 0000000..92cc920 --- /dev/null +++ b/superpowers/src/phaser/config.ts @@ -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, + }, + }; +} diff --git a/superpowers/src/phaser/scenes/GameScene.ts b/superpowers/src/phaser/scenes/GameScene.ts new file mode 100644 index 0000000..327593e --- /dev/null +++ b/superpowers/src/phaser/scenes/GameScene.ts @@ -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); + } +} diff --git a/superpowers/src/phaser/scenes/PreloadScene.ts b/superpowers/src/phaser/scenes/PreloadScene.ts new file mode 100644 index 0000000..a8f4bd7 --- /dev/null +++ b/superpowers/src/phaser/scenes/PreloadScene.ts @@ -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"); + } +}