This commit is contained in:
2026-05-15 20:35:41 +02:00
parent 1346dba937
commit 1b427c8679
12 changed files with 77 additions and 17 deletions

View File

@@ -1,14 +1,14 @@
import Phaser from "phaser";
export class Exit extends Phaser.GameObjects.Rectangle {
export class Exit extends Phaser.GameObjects.Image {
static readonly TEXTURE_KEY = "exit";
static readonly WIDTH = 40;
static readonly HEIGHT = 80;
static readonly COLOR = 0xffd700;
declare body: Phaser.Physics.Arcade.StaticBody;
constructor(scene: Phaser.Scene, x: number, y: number) {
super(scene, x, y, Exit.WIDTH, Exit.HEIGHT, Exit.COLOR);
super(scene, x, y, Exit.TEXTURE_KEY);
scene.add.existing(this);
scene.physics.add.existing(this, true);
}

View File

@@ -1,7 +1,7 @@
import Phaser from "phaser";
import { Platform } from "./Platform";
export class ObstaclePlatformDisappearing extends Phaser.GameObjects.Rectangle {
export class ObstaclePlatformDisappearing extends Phaser.GameObjects.TileSprite {
static readonly TRIGGER_DISTANCE = 110;
static readonly FADE_MS = 200;
@@ -10,7 +10,7 @@ export class ObstaclePlatformDisappearing extends Phaser.GameObjects.Rectangle {
private vanished = false;
constructor(scene: Phaser.Scene, x: number, y: number, width: number, height: number) {
super(scene, x, y, width, height, Platform.COLOR);
super(scene, x, y, width, height, Platform.TEXTURE_KEY);
scene.add.existing(this);
scene.physics.add.existing(this, true);
}

View File

@@ -1,14 +1,14 @@
import Phaser from "phaser";
export class ObstacleSpikeNormal extends Phaser.GameObjects.Rectangle {
export class ObstacleSpikeNormal extends Phaser.GameObjects.Image {
static readonly TEXTURE_KEY = "spike-normal";
static readonly WIDTH = 40;
static readonly HEIGHT = 20;
static readonly COLOR = 0xff3333;
declare body: Phaser.Physics.Arcade.StaticBody;
constructor(scene: Phaser.Scene, x: number, y: number) {
super(scene, x, y, ObstacleSpikeNormal.WIDTH, ObstacleSpikeNormal.HEIGHT, ObstacleSpikeNormal.COLOR);
super(scene, x, y, ObstacleSpikeNormal.TEXTURE_KEY);
scene.add.existing(this);
scene.physics.add.existing(this, true);
}

View File

@@ -1,9 +1,9 @@
import Phaser from "phaser";
export class ObstacleSpikeTricky extends Phaser.GameObjects.Rectangle {
export class ObstacleSpikeTricky extends Phaser.GameObjects.Image {
static readonly TEXTURE_KEY = "spike-tricky";
static readonly WIDTH = 40;
static readonly HEIGHT = 20;
static readonly COLOR = 0xff8800;
static readonly TRIGGER_DISTANCE = 55;
static readonly DISPLACEMENT = 100;
@@ -12,7 +12,7 @@ export class ObstacleSpikeTricky extends Phaser.GameObjects.Rectangle {
private moved = false;
constructor(scene: Phaser.Scene, x: number, y: number) {
super(scene, x, y, ObstacleSpikeTricky.WIDTH, ObstacleSpikeTricky.HEIGHT, ObstacleSpikeTricky.COLOR);
super(scene, x, y, ObstacleSpikeTricky.TEXTURE_KEY);
scene.add.existing(this);
scene.physics.add.existing(this, true);
}

View File

@@ -1,12 +1,12 @@
import Phaser from "phaser";
export class Platform extends Phaser.GameObjects.Rectangle {
static readonly COLOR = 0x4a7c3a;
export class Platform extends Phaser.GameObjects.TileSprite {
static readonly TEXTURE_KEY = "platform";
declare body: Phaser.Physics.Arcade.StaticBody;
constructor(scene: Phaser.Scene, x: number, y: number, width: number, height: number) {
super(scene, x, y, width, height, Platform.COLOR);
super(scene, x, y, width, height, Platform.TEXTURE_KEY);
scene.add.existing(this);
scene.physics.add.existing(this, true);
}

View File

@@ -1,8 +1,8 @@
import Phaser from "phaser";
export class Player extends Phaser.GameObjects.Rectangle {
export class Player extends Phaser.GameObjects.Image {
static readonly TEXTURE_KEY = "player";
static readonly SIZE = 32;
static readonly COLOR = 0xff4444;
static readonly MOVE_SPEED = 250;
static readonly JUMP_VELOCITY = 480;
@@ -15,7 +15,7 @@ export class Player extends Phaser.GameObjects.Rectangle {
private keySpace: Phaser.Input.Keyboard.Key;
constructor(scene: Phaser.Scene, x: number, y: number) {
super(scene, x, y, Player.SIZE, Player.SIZE, Player.COLOR);
super(scene, x, y, Player.TEXTURE_KEY);
scene.add.existing(this);
scene.physics.add.existing(this);
this.body.setCollideWorldBounds(true);