From 0b731d54080560fffce37ea0cce650f3908d7ae3 Mon Sep 17 00:00:00 2001 From: Mohana Misra Date: Thu, 27 Jun 2024 11:16:46 +0530 Subject: [PATCH] attempt to resolve white space issue --- src/components/Scoreboard.jsx | 4 ++-- src/pages/Game.jsx | 16 +++++++++++++--- src/pages/GameOver.jsx | 1 - src/pages/Pages.css | 6 ++++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/components/Scoreboard.jsx b/src/components/Scoreboard.jsx index 8c9ed06..60540b7 100644 --- a/src/components/Scoreboard.jsx +++ b/src/components/Scoreboard.jsx @@ -21,8 +21,8 @@ export default class Scoreboard { p.image(this.boardImage, 0, 0, this.w, this.h); p.fill("rgb(255, 255, 255)"); p.textSize(40); - if(p.windowWidth < 350) - p.textSize(28); + if(p.windowWidth < 400) + p.textSize(30); p.textStyle(p.BOLD); p.textFont('Pixelify Sans Variable'); p.text(`Hits: ${score}`, this.x + 10, this.y + 10, this.w, this.h); diff --git a/src/pages/Game.jsx b/src/pages/Game.jsx index 5e67a95..3dc2878 100644 --- a/src/pages/Game.jsx +++ b/src/pages/Game.jsx @@ -50,8 +50,6 @@ function Game() { monsterImages.push(await p.loadImage(zombie)); monsterImages.push(await p.loadImage(goblin)); monsterImages.push(await p.loadImage(vampire)); - score = 0; - timer = 42; } p.setup = function() { @@ -178,7 +176,19 @@ function Game() { // } } } - + (function() + { + if( window.localStorage ) + { + if( !localStorage.getItem('firstLoad') ) + { + localStorage['firstLoad'] = true; + window.location.reload(); + } + else + localStorage.removeItem('firstLoad'); + } + })(); useEffect(() => { const p5Instance = new p5(sketch, p5Container.current); diff --git a/src/pages/GameOver.jsx b/src/pages/GameOver.jsx index 895ebd6..140bc79 100644 --- a/src/pages/GameOver.jsx +++ b/src/pages/GameOver.jsx @@ -8,7 +8,6 @@ const GameOver = () => { const handlePlayGame = () => { navigate("/game"); - window.location.reload(); } return ( diff --git a/src/pages/Pages.css b/src/pages/Pages.css index a0b0c96..efb45a0 100644 --- a/src/pages/Pages.css +++ b/src/pages/Pages.css @@ -94,6 +94,12 @@ } } +/*GAME PAGE STYLING*/ + +.container { + overflow: hidden; +} + /*GAME OVER PAGE STYLING*/ .game-over-container {