diff --git a/environment/frontend_server/templates/demo/main_script.html b/environment/frontend_server/templates/demo/main_script.html index 703c8e6b6b..aff4efdb66 100644 --- a/environment/frontend_server/templates/demo/main_script.html +++ b/environment/frontend_server/templates/demo/main_script.html @@ -354,17 +354,19 @@ const camera_speed = 400; // Stop any previous movement from the last frame player.body.setVelocity(0); - if (cursors.left.isDown) { - player.body.setVelocityX(-camera_speed); - } - if (cursors.right.isDown) { - player.body.setVelocityX(camera_speed); - } - if (cursors.up.isDown) { - player.body.setVelocityY(-camera_speed); - } - if (cursors.down.isDown) { - player.body.setVelocityY(camera_speed); + const speed_boost = cursors.shift.isDown ? 2 : 1; + + if (cursors.left.isDown || keys.left.isDown) { + player.body.setVelocityX(-camera_speed * speed_boost); + } + if (cursors.right.isDown || keys.right.isDown) { + player.body.setVelocityX(camera_speed * speed_boost); + } + if (cursors.up.isDown || keys.up.isDown) { + player.body.setVelocityY(-camera_speed * speed_boost); + } + if (cursors.down.isDown || keys.down.isDown) { + player.body.setVelocityY(camera_speed * speed_boost); } diff --git a/environment/frontend_server/templates/home/main_script.html b/environment/frontend_server/templates/home/main_script.html index 19c1dcf9f0..fcb90958e8 100644 --- a/environment/frontend_server/templates/home/main_script.html +++ b/environment/frontend_server/templates/home/main_script.html @@ -275,6 +275,7 @@ camera.startFollow(player); camera.setBounds(0, 0, map.widthInPixels, map.heightInPixels); cursors = this.input.keyboard.createCursorKeys(); + keys = this.input.keyboard.addKeys({up:'W',left: 'A', down: 'S', right: 'D'}); // *** SET UP PERSONAS *** // We start by creating the game sprite objects. @@ -352,17 +353,19 @@ const camera_speed = 400; // Stop any previous movement from the last frame player.body.setVelocity(0); - if (cursors.left.isDown) { - player.body.setVelocityX(-camera_speed); - } - if (cursors.right.isDown) { - player.body.setVelocityX(camera_speed); - } - if (cursors.up.isDown) { - player.body.setVelocityY(-camera_speed); - } - if (cursors.down.isDown) { - player.body.setVelocityY(camera_speed); + const speed_boost = cursors.shift.isDown ? 2 : 1; + + if (cursors.left.isDown || keys.left.isDown) { + player.body.setVelocityX(-camera_speed * speed_boost); + } + if (cursors.right.isDown || keys.right.isDown) { + player.body.setVelocityX(camera_speed * speed_boost); + } + if (cursors.up.isDown || keys.up.isDown) { + player.body.setVelocityY(-camera_speed * speed_boost); + } + if (cursors.down.isDown || keys.down.isDown) { + player.body.setVelocityY(camera_speed * speed_boost); } // console.log("phase: " + phase + ", step: " + step);