From 995e8c4dab68722a85685b6bc9942fc4e22bf0d9 Mon Sep 17 00:00:00 2001 From: dhain Date: Tue, 31 Jan 2023 10:30:01 +0100 Subject: [PATCH 1/5] Game only playing when logged in --- frontend/public/game.js | 21 +++++++++++++++------ frontend/src/components/Login.vue | 1 + frontend/src/model/Rest.ts | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/frontend/public/game.js b/frontend/public/game.js index 3b51b91..eaecfb2 100644 --- a/frontend/public/game.js +++ b/frontend/public/game.js @@ -43,7 +43,7 @@ var score = 0; var paused; var hasAlreadyScored = false; var hasDied = true; -var ready = true; +var ready = false; function preload(){ font = loadFont(FONT_PATH); @@ -67,6 +67,12 @@ function setup(){ window.dispatchEvent(event); originalSetItem.apply(this, arguments); }; + window.addEventListener("itemInserted", e => { + if(e.key === "frontend-ready"){ + ready = e.value === "true"; + score = 0; + } + }) } function setupObstacleConsts(){ @@ -155,13 +161,15 @@ function collisionCheck(o){ function die(){ if(localStorage.getItem("frontend-ready") == "false") return; - + ready = false; hasDied = true; playTime = Date.now() - startTime; exportToLocalStorage(); setTimeout(function(){ - return ready = true; + if(localStorage.getItem("frontend-ready") == "true"){ + return ready = true; + } }, 1000); } @@ -208,19 +216,20 @@ function checkRaspberryScore(){ } function resetScore(){ - if(!hasDied || localStorage.getItem("frontend-ready") == "false") + if(!hasDied) return; hasDied = false; score = 0; hasAlreadyScored = false; startTime = Date.now(); - exportToLocalStorage(); } function keyPressed(){ - if(!ready) + if(!ready){ return; + } + if(BOOST_KEYS.includes(key.toLowerCase())){ resetScore(); raspberry.boost(); diff --git a/frontend/src/components/Login.vue b/frontend/src/components/Login.vue index 3be8534..ec3a1ce 100644 --- a/frontend/src/components/Login.vue +++ b/frontend/src/components/Login.vue @@ -39,6 +39,7 @@ export default { if (user) { this.$emit('userChange', user); + localStorage.setItem("frontend-ready", "true"); } }, } diff --git a/frontend/src/model/Rest.ts b/frontend/src/model/Rest.ts index 53b902e..04d93cc 100644 --- a/frontend/src/model/Rest.ts +++ b/frontend/src/model/Rest.ts @@ -1,3 +1,3 @@ export class Rest { - static readonly URL = 'http://localhost:3000'; + static readonly URL = 'http://139.144.178.216:3000'; } \ No newline at end of file From 7e2ac3f4883af444d4218dd855803d38341dc255 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Wed, 1 Feb 2023 19:00:46 +0100 Subject: [PATCH 2/5] Merge --- docker-compose.yml | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 96250c1..e69de29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,33 +0,0 @@ -version: '3.1' - -services: - db: - build: backend/db - container_name: postgres-db - environment: - POSTGRES_DB: ${POSTGRES_DB} - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - ports: - - "${POSTGRES_PORT}:5432" - volumes: - - ./backend/pgdata:/var/lib/postgresql/data - - api: - build: backend/api - depends_on: - - db - container_name: express-api - ports: - - "${EXPRESS_PORT}:3000" - - vue: - build: frontend - container_name: frontend - ports: - - "${FRONTEND_PORT}:8080" - - - volumes: - - ./frontend:/app - From 28a3c48cdba98c88cab5c6485198b6bcd0753b9f Mon Sep 17 00:00:00 2001 From: Stefan Prechtl <56696799+s-prechtl@users.noreply.github.com> Date: Sun, 5 Feb 2023 22:48:26 +0100 Subject: [PATCH 3/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9754990..762950e 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,5 @@ npm install ```shell docker compose up --build ``` + +You can then access the website on `localhost:8080` From adc971f587945925097d3ec78b0ab64ab6ea28b0 Mon Sep 17 00:00:00 2001 From: David Hain <57726396+d-hain@users.noreply.github.com> Date: Tue, 7 Feb 2023 09:10:31 +0100 Subject: [PATCH 4/5] Update docker-compose.yml --- docker-compose.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index e69de29..2672685 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: '3.1' + +services: + db: + build: backend/db + container_name: postgres-db + environment: + POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + ports: + - "${POSTGRES_PORT}:5432" + volumes: + - ./backend/pgdata:/var/lib/postgresql/data + + api: + build: backend/api + depends_on: + - db + container_name: express-api + ports: + - "${EXPRESS_PORT}:3000" + + vue: + build: frontend + container_name: frontend + ports: + - "${FRONTEND_PORT}:8080" + + + volumes: + - ./frontend:/app From c1a32c1a30012450f15b3e9129cd840f7e9e6f82 Mon Sep 17 00:00:00 2001 From: David Hain <57726396+d-hain@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:41:37 +0100 Subject: [PATCH 5/5] fix: README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 762950e..82d8404 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ and run: npm install ``` -### Start the container +### Start the container (in the project root) ```shell docker compose up --build