diff --git a/README.md b/README.md index 9754990..82d8404 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,10 @@ and run: npm install ``` -### Start the container +### Start the container (in the project root) ```shell docker compose up --build ``` + +You can then access the website on `localhost:8080` diff --git a/docker-compose.yml b/docker-compose.yml index 96250c1..2672685 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,33 +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 - +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 diff --git a/frontend/public/game.js b/frontend/public/game.js index eaecfb2..3b51b91 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 = false; +var ready = true; function preload(){ font = loadFont(FONT_PATH); @@ -67,12 +67,6 @@ 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(){ @@ -161,15 +155,13 @@ function collisionCheck(o){ function die(){ if(localStorage.getItem("frontend-ready") == "false") return; - + ready = false; hasDied = true; playTime = Date.now() - startTime; exportToLocalStorage(); setTimeout(function(){ - if(localStorage.getItem("frontend-ready") == "true"){ - return ready = true; - } + return ready = true; }, 1000); } @@ -216,20 +208,19 @@ function checkRaspberryScore(){ } function resetScore(){ - if(!hasDied) + if(!hasDied || localStorage.getItem("frontend-ready") == "false") 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 ec3a1ce..3be8534 100644 --- a/frontend/src/components/Login.vue +++ b/frontend/src/components/Login.vue @@ -39,7 +39,6 @@ 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 04d93cc..53b902e 100644 --- a/frontend/src/model/Rest.ts +++ b/frontend/src/model/Rest.ts @@ -1,3 +1,3 @@ export class Rest { - static readonly URL = 'http://139.144.178.216:3000'; + static readonly URL = 'http://localhost:3000'; } \ No newline at end of file