From 7f401b3e9468f7c6659b1e14f537164ed7dab273 Mon Sep 17 00:00:00 2001 From: Admin Date: Thu, 17 Sep 2026 10:04:40 +0000 Subject: [PATCH] Fix Arcade Physics player controls --- src/game-v2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game-v2.js b/src/game-v2.js index d17f27c..2d89cac 100644 --- a/src/game-v2.js +++ b/src/game-v2.js @@ -42,7 +42,7 @@ class GameScene extends Phaser.Scene { this.drawWorld(); this.createTextures(); - this.player = this.physics.add.image(1200, 1550, 'player-ship'); + this.player = this.physics.add.sprite(1200, 1550, 'player-ship'); this.player.setDepth(6).setCollideWorldBounds(true); this.player.body.setAllowGravity(false); this.player.body.setSize(42, 56, true); @@ -81,7 +81,7 @@ class GameScene extends Phaser.Scene { this.hud = this.add.text(18, 42, '', { fontFamily: 'monospace', fontSize: '14px', - color: '#e8f2ff', + color: '#e8f2f7', backgroundColor: '#071018cc', padding: { x: 12, y: 10 }, lineSpacing: 4, @@ -195,6 +195,8 @@ class GameScene extends Phaser.Scene { } updatePlayer(dt, deltaMs) { + if (!this.player?.body) return; + if (this.cursors.up.isDown) this.playerSpeed += PLAYER_ACCELERATION * dt; if (this.cursors.down.isDown) this.playerSpeed -= PLAYER_BRAKE * dt; if (this.keys.stop.isDown) this.playerSpeed *= Math.pow(0.025, dt);