From 4e98b8db9ef04e5b1b635f03f1154d1f50949d8a Mon Sep 17 00:00:00 2001 From: Mees Roelofsz Date: Tue, 5 Dec 2023 14:37:19 +0100 Subject: [PATCH 1/4] changed screen size --- web/game.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/game.js b/web/game.js index 8939190..2878d95 100644 --- a/web/game.js +++ b/web/game.js @@ -1,7 +1,7 @@ //--------------------Game-------------------- // Game variables -const width = 1000; -const height = 600; +const width = 1260; +const height = 620; // Player variables const playerSize = 10; @@ -12,7 +12,7 @@ let playerSpeed = 4; let booleanArray = window.booleanArray; let lives = 1; -let bossPosX = 500; +let bossPosX = width / 2; let bossPosY = 100; let shotSpeed = 9; let projectile; @@ -73,7 +73,7 @@ function life() { fill(255, 0, 0); textSize(40); textAlign(CENTER); - text("Game Over", 500, 300); + text("Game Over", width/2, height/2); if (key == ' ') { lives = 1; time = 0; @@ -172,8 +172,8 @@ function draw() { circle(x4, y4, 50); circle(x5, y5, 50); } else { - x2 = bossPosX; - y2 = bossPosY; + x2 = width / 2; + y2 = 100; } bullets.forEach(myBullet => { From 24c18521bb983062472b401e9a8a92bb243871e5 Mon Sep 17 00:00:00 2001 From: Mees Roelofsz Date: Tue, 5 Dec 2023 15:27:21 +0100 Subject: [PATCH 2/4] trying to add dash --- web/game.js | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/web/game.js b/web/game.js index 2878d95..4e9fc3d 100644 --- a/web/game.js +++ b/web/game.js @@ -11,10 +11,12 @@ let playerPosY = 300; let playerSpeed = 4; let booleanArray = window.booleanArray; let lives = 1; +let movingX = false; +let movingY = false; let bossPosX = width / 2; let bossPosY = 100; -let shotSpeed = 9; +let shotSpeed = 12; let projectile; let projSize = 5; let shot = false; @@ -98,15 +100,33 @@ function movementCheck() { function keyPressed() { if (keyIsDown(LEFT_ARROW) && playerPosX > 0 + radius) { playerPosX -= playerSpeed; + movingX = true; + } else { + movingX = false; } if (keyIsDown(RIGHT_ARROW) && playerPosX < width - radius) { playerPosX += playerSpeed; + movingX = true; + } else { + movingX = false; } if (keyIsDown(UP_ARROW) && playerPosY > 0 + radius) { playerPosY -= playerSpeed; + movingY = true; + } else { + movingY = false; } if (keyIsDown(DOWN_ARROW) && playerPosY < height - radius) { playerPosY += playerSpeed; + movingY = true; + } else { + movingY = false; + } + if (key == ' ' && shot == false && lives != 0) { + if (movingX == true) { + playerPosX += 100; + + } } } @@ -211,22 +231,22 @@ function spawnRandomBullet() { bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); } if (nextAttack == 2) { - shotPosX = random(0, 1000); - shotPosY = 600; + shotPosX = random(0, width); + shotPosY = height; bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); } if (nextAttack == 3) { - shotPosX = 10; - shotPosY = random(0, 600); + shotPosX = 0; + shotPosY = random(0, height); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); } if (nextAttack == 4) { - shotPosX = 1000; - shotPosY = random(0, 600); + shotPosX = width; + shotPosY = random(0, height); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); } if (nextAttack == 5) { - shotPosX = random(0, 1000); + shotPosX = random(0, width); shotPosY = 0; bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); } @@ -249,7 +269,7 @@ function spawnRandomBullet() { bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); } if (!(patern == 2)) { - bossPosX = 500; + bossPosX = width / 2; bossPosY = 100; } if (patern == 3) { From c9aee3188983102a982fc24dba64059fc3078d29 Mon Sep 17 00:00:00 2001 From: Mees Roelofsz Date: Tue, 5 Dec 2023 15:27:33 +0100 Subject: [PATCH 3/4] trying to add dash --- web/game.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/web/game.js b/web/game.js index 4e9fc3d..ceb0b54 100644 --- a/web/game.js +++ b/web/game.js @@ -123,10 +123,7 @@ function keyPressed() { movingY = false; } if (key == ' ' && shot == false && lives != 0) { - if (movingX == true) { - playerPosX += 100; - - } + } } From a0b69ecb7676e3505e2043a516e418a4de4502cf Mon Sep 17 00:00:00 2001 From: Mees Roelofsz Date: Tue, 5 Dec 2023 15:46:51 +0100 Subject: [PATCH 4/4] betered dash + wait function --- web/game.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/web/game.js b/web/game.js index ceb0b54..ceef14d 100644 --- a/web/game.js +++ b/web/game.js @@ -11,8 +11,6 @@ let playerPosY = 300; let playerSpeed = 4; let booleanArray = window.booleanArray; let lives = 1; -let movingX = false; -let movingY = false; let bossPosX = width / 2; let bossPosY = 100; @@ -100,33 +98,33 @@ function movementCheck() { function keyPressed() { if (keyIsDown(LEFT_ARROW) && playerPosX > 0 + radius) { playerPosX -= playerSpeed; - movingX = true; - } else { - movingX = false; } if (keyIsDown(RIGHT_ARROW) && playerPosX < width - radius) { playerPosX += playerSpeed; - movingX = true; - } else { - movingX = false; } if (keyIsDown(UP_ARROW) && playerPosY > 0 + radius) { playerPosY -= playerSpeed; - movingY = true; - } else { - movingY = false; } if (keyIsDown(DOWN_ARROW) && playerPosY < height - radius) { playerPosY += playerSpeed; - movingY = true; - } else { - movingY = false; } - if (key == ' ' && shot == false && lives != 0) { - + if (key == 'e') { + // adding a quick movement button that moves you further in the direction your already moving + playerSpeed += 2; + wait(2); + } else { + playerSpeed = 4; } } +function wait(waitTime){ + startTime = time; + if (startTime + waitTime > time){ + return true; + } +} + + async function Movementloop() { window.addEventListener('booleanArrayUpdated', function (event) { // event.detail contains the booleanArray