refact round
This commit is contained in:
@@ -7,26 +7,69 @@ import {
|
||||
ObstacleSpikeTricky,
|
||||
} from "../entities/obstacles";
|
||||
|
||||
interface SpriteAsset {
|
||||
key: string;
|
||||
path: string;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
const SPRITE_ASSETS: SpriteAsset[] = [
|
||||
{ key: Player.TEXTURE_KEY, path: "/sprites/player.svg", width: Player.SIZE, height: Player.SIZE },
|
||||
{ key: Exit.TEXTURE_KEY, path: "/sprites/exit.svg", width: Exit.WIDTH, height: Exit.HEIGHT },
|
||||
{ key: Platform.TEXTURE_KEY, path: "/sprites/platform.svg", width: 40, height: 40 },
|
||||
{
|
||||
key: ObstacleSpikeNormal.TEXTURE_KEY,
|
||||
path: "/sprites/spike-normal.svg",
|
||||
width: ObstacleSpikeNormal.WIDTH,
|
||||
height: ObstacleSpikeNormal.HEIGHT,
|
||||
},
|
||||
{
|
||||
key: ObstacleSpikeTricky.TEXTURE_KEY,
|
||||
path: "/sprites/spike-tricky.svg",
|
||||
width: ObstacleSpikeTricky.WIDTH,
|
||||
height: ObstacleSpikeTricky.HEIGHT,
|
||||
},
|
||||
];
|
||||
|
||||
const TITLE_STYLE: Phaser.Types.GameObjects.Text.TextStyle = {
|
||||
fontFamily: "Arial Black, Arial",
|
||||
fontSize: "78px",
|
||||
color: "#ffd700",
|
||||
fontStyle: "bold",
|
||||
stroke: "#7a5500",
|
||||
strokeThickness: 6,
|
||||
};
|
||||
|
||||
const SUBTITLE_STYLE: Phaser.Types.GameObjects.Text.TextStyle = {
|
||||
fontFamily: "Arial",
|
||||
fontSize: "18px",
|
||||
color: "#aaaaaa",
|
||||
fontStyle: "italic",
|
||||
};
|
||||
|
||||
const PROMPT_STYLE: Phaser.Types.GameObjects.Text.TextStyle = {
|
||||
fontFamily: "Arial",
|
||||
fontSize: "26px",
|
||||
color: "#ffffff",
|
||||
fontStyle: "bold",
|
||||
};
|
||||
|
||||
const HINT_STYLE: Phaser.Types.GameObjects.Text.TextStyle = {
|
||||
fontFamily: "Arial",
|
||||
fontSize: "14px",
|
||||
color: "#888888",
|
||||
};
|
||||
|
||||
export class BootScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
super({ key: "BootScene" });
|
||||
}
|
||||
|
||||
preload(): void {
|
||||
this.load.svg(Player.TEXTURE_KEY, "/sprites/player.svg", { width: 32, height: 32 });
|
||||
this.load.svg(Exit.TEXTURE_KEY, "/sprites/exit.svg", {
|
||||
width: Exit.WIDTH,
|
||||
height: Exit.HEIGHT,
|
||||
});
|
||||
this.load.svg(Platform.TEXTURE_KEY, "/sprites/platform.svg", { width: 40, height: 40 });
|
||||
this.load.svg(ObstacleSpikeNormal.TEXTURE_KEY, "/sprites/spike-normal.svg", {
|
||||
width: ObstacleSpikeNormal.WIDTH,
|
||||
height: ObstacleSpikeNormal.HEIGHT,
|
||||
});
|
||||
this.load.svg(ObstacleSpikeTricky.TEXTURE_KEY, "/sprites/spike-tricky.svg", {
|
||||
width: ObstacleSpikeTricky.WIDTH,
|
||||
height: ObstacleSpikeTricky.HEIGHT,
|
||||
});
|
||||
for (const asset of SPRITE_ASSETS) {
|
||||
this.load.svg(asset.key, asset.path, { width: asset.width, height: asset.height });
|
||||
}
|
||||
}
|
||||
|
||||
create(): void {
|
||||
@@ -38,48 +81,16 @@ export class BootScene extends Phaser.Scene {
|
||||
|
||||
this.add.tileSprite(cx, h - 20, w, 40, Platform.TEXTURE_KEY);
|
||||
|
||||
this.add
|
||||
.text(cx, 130, "TRICKSTER", {
|
||||
fontFamily: "Arial Black, Arial",
|
||||
fontSize: "78px",
|
||||
color: "#ffd700",
|
||||
fontStyle: "bold",
|
||||
stroke: "#7a5500",
|
||||
strokeThickness: 6,
|
||||
})
|
||||
.setOrigin(0.5);
|
||||
|
||||
this.add
|
||||
.text(cx, 200, "TILES", {
|
||||
fontFamily: "Arial Black, Arial",
|
||||
fontSize: "78px",
|
||||
color: "#ffd700",
|
||||
fontStyle: "bold",
|
||||
stroke: "#7a5500",
|
||||
strokeThickness: 6,
|
||||
})
|
||||
.setOrigin(0.5);
|
||||
|
||||
this.add
|
||||
.text(cx, 270, "a pixel-art platformer", {
|
||||
fontFamily: "Arial",
|
||||
fontSize: "18px",
|
||||
color: "#aaaaaa",
|
||||
fontStyle: "italic",
|
||||
})
|
||||
.setOrigin(0.5);
|
||||
this.add.text(cx, 130, "TRICKSTER", TITLE_STYLE).setOrigin(0.5);
|
||||
this.add.text(cx, 200, "TILES", TITLE_STYLE).setOrigin(0.5);
|
||||
this.add.text(cx, 270, "a pixel-art platformer", SUBTITLE_STYLE).setOrigin(0.5);
|
||||
|
||||
this.add.image(cx - 80, 360, Player.TEXTURE_KEY);
|
||||
this.add.image(cx, 374, ObstacleSpikeNormal.TEXTURE_KEY);
|
||||
this.add.image(cx + 80, 374, ObstacleSpikeTricky.TEXTURE_KEY);
|
||||
|
||||
const startText = this.add
|
||||
.text(cx, 450, "PRESS SPACE TO START", {
|
||||
fontFamily: "Arial",
|
||||
fontSize: "26px",
|
||||
color: "#ffffff",
|
||||
fontStyle: "bold",
|
||||
})
|
||||
.text(cx, 450, "PRESS SPACE TO START", PROMPT_STYLE)
|
||||
.setOrigin(0.5);
|
||||
|
||||
this.tweens.add({
|
||||
@@ -91,11 +102,7 @@ export class BootScene extends Phaser.Scene {
|
||||
});
|
||||
|
||||
this.add
|
||||
.text(cx, 510, "← → / A D to move SPACE / ↑ / W to jump", {
|
||||
fontFamily: "Arial",
|
||||
fontSize: "14px",
|
||||
color: "#888888",
|
||||
})
|
||||
.text(cx, 510, "← → / A D to move SPACE / ↑ / W to jump", HINT_STYLE)
|
||||
.setOrigin(0.5);
|
||||
|
||||
const start = () => this.scene.start("GameScene");
|
||||
|
||||
Reference in New Issue
Block a user