Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions environment/frontend_server/templates/demo/main_script.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
25 changes: 14 additions & 11 deletions environment/frontend_server/templates/home/main_script.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down