From 46fcb86b28ecaf58cb06e97a2737c579ae9c2889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Sat, 18 Apr 2020 17:16:39 +0200 Subject: [PATCH 1/5] Computing movement amount from framerate Depending on the amount of power a computer has, the framerate will not be the same. Hence, the amount of movement of a user should be constant on each frame. If a frame was slow to print, the movement should be higher to keep a constant speed. This PR takes the framerate into account when moving the players. --- front/src/Phaser/Game/GameScene.ts | 8 ++++++-- front/src/Phaser/Player/Player.ts | 17 +++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index a08c8fd2..337d7651 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -182,8 +182,12 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ }); } - update() : void { - this.CurrentPlayer.moveUser(); + /** + * @param time + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(time: number, delta: number) : void { + this.CurrentPlayer.moveUser(delta); } /** diff --git a/front/src/Phaser/Player/Player.ts b/front/src/Phaser/Player/Player.ts index 4cd1a6aa..e99fa42a 100644 --- a/front/src/Phaser/Player/Player.ts +++ b/front/src/Phaser/Player/Player.ts @@ -9,7 +9,7 @@ export interface CurrentGamerInterface extends PlayableCaracter{ userId : string; PlayerValue : string; initAnimation() : void; - moveUser() : void; + moveUser(delta: number) : void; say(text : string) : void; } @@ -57,31 +57,32 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G }) } - moveUser(): void { + moveUser(delta: number): void { //if user client on shift, camera and player speed let haveMove = false; let direction = null; let activeEvents = this.userInputManager.getEventListForGameTick(); - let speedMultiplier = activeEvents.get(UserInputEvent.SpeedUp) ? 500 : 100; + let speedMultiplier = activeEvents.get(UserInputEvent.SpeedUp) ? 25 : 9; + let moveAmount = speedMultiplier * delta; if (activeEvents.get(UserInputEvent.MoveUp)) { - this.move(0, -speedMultiplier); + this.move(0, -moveAmount); haveMove = true; direction = PlayerAnimationNames.WalkUp; } if (activeEvents.get(UserInputEvent.MoveLeft)) { - this.move(-speedMultiplier, 0); + this.move(-moveAmount, 0); haveMove = true; direction = PlayerAnimationNames.WalkLeft; } if (activeEvents.get(UserInputEvent.MoveDown)) { - this.move(0, speedMultiplier); + this.move(0, moveAmount); haveMove = true; direction = PlayerAnimationNames.WalkDown; } if (activeEvents.get(UserInputEvent.MoveRight)) { - this.move(speedMultiplier, 0); + this.move(moveAmount, 0); haveMove = true; direction = PlayerAnimationNames.WalkRight; } @@ -103,4 +104,4 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G this.setX(MessageUserPosition.position.x); this.setY(MessageUserPosition.position.y); } -} \ No newline at end of file +} From a567cd2e119b20132885f288f8544fb0a53db21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 22 Apr 2020 12:31:17 +0200 Subject: [PATCH 2/5] Adapting deeployer to new format --- deeployer.libsonnet | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 4e44db34..7927dd5a 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -6,7 +6,9 @@ "containers": { "back": { "image": "thecodingmachine/workadventure-back:"+tag, - "host": "api."+namespace+".workadventure.test.thecodingmachine.com", + "host": { + "url": "api."+namespace+".workadventure.test.thecodingmachine.com" + }, "ports": [8080], "env": { "SECRET_KEY": "tempSecretKeyNeedsToChange" @@ -14,7 +16,9 @@ }, "front": { "image": "thecodingmachine/workadventure-front:"+tag, - "host": namespace+".workadventure.test.thecodingmachine.com", + "host": { + "url": namespace+".workadventure.test.thecodingmachine.com" + }, "ports": [80], "env": { "API_URL": "http://api."+namespace+".workadventure.test.thecodingmachine.com" From 312940761cd1111366afd26ce966aa480dd1557d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 22 Apr 2020 19:16:04 +0200 Subject: [PATCH 3/5] Enabling HTTPS in test deployment --- deeployer.libsonnet | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 7927dd5a..105f9025 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -7,7 +7,8 @@ "back": { "image": "thecodingmachine/workadventure-back:"+tag, "host": { - "url": "api."+namespace+".workadventure.test.thecodingmachine.com" + "url": "api."+namespace+".workadventure.test.thecodingmachine.com", + "https": "enable" }, "ports": [8080], "env": { @@ -17,12 +18,18 @@ "front": { "image": "thecodingmachine/workadventure-front:"+tag, "host": { - "url": namespace+".workadventure.test.thecodingmachine.com" + "url": namespace+".workadventure.test.thecodingmachine.com", + "https": "enable" }, "ports": [80], "env": { "API_URL": "http://api."+namespace+".workadventure.test.thecodingmachine.com" } } + }, + "config": { + "https": { + "mail": "d.negrier@thecodingmachine.com" + } } } From 321254bc2cd5f8ceed7f083d0e21dca3c89e55ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 22 Apr 2020 23:27:30 +0200 Subject: [PATCH 4/5] Fixing API link to HTTPS --- deeployer.libsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 105f9025..84ea3eca 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -23,7 +23,7 @@ }, "ports": [80], "env": { - "API_URL": "http://api."+namespace+".workadventure.test.thecodingmachine.com" + "API_URL": "https://api."+namespace+".workadventure.test.thecodingmachine.com" } } }, From 6a349e3ef71e12b11abc86ea8823d95b00f39854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 22 Apr 2020 23:34:56 +0200 Subject: [PATCH 5/5] Switching tests on https too --- .github/workflows/build-and-deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 6f6ebe8a..88bd4543 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -81,17 +81,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - msg: Environment deployed at http://${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com + msg: Environment deployed at https://${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com check_for_duplicate_msg: true - name: Run Cypress tests uses: cypress-io/github-action@v1 env: - CYPRESS_BASE_URL: http://${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com + CYPRESS_BASE_URL: https://${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com with: env: host=${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com,port=80 spec: cypress/integration/spec.js - wait-on: http://${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com + wait-on: https://${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com working-directory: e2e - name: "Upload the screenshot on test failure"