Merge branch 'main' of https://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-2/cuujooceevii61
This commit is contained in:
55
web/game.js
55
web/game.js
@@ -20,7 +20,9 @@ let playerSpeed = 4;
|
|||||||
let lives = 1;
|
let lives = 1;
|
||||||
let isDead = false;
|
let isDead = false;
|
||||||
let bossPosX = width / 2;
|
let bossPosX = width / 2;
|
||||||
let bossPosY = 100;
|
let bossPosY = height / 6;
|
||||||
|
let bossVelX = 5;
|
||||||
|
let bossVelY = 5;
|
||||||
let shotSpeed = 12;
|
let shotSpeed = 12;
|
||||||
let shotSpeedAdj;
|
let shotSpeedAdj;
|
||||||
let projectile;
|
let projectile;
|
||||||
@@ -87,8 +89,6 @@ function score() {
|
|||||||
function reset() {
|
function reset() {
|
||||||
lives = 1;
|
lives = 1;
|
||||||
time = 0;
|
time = 0;
|
||||||
bounceX = bossPosX;
|
|
||||||
bounceY = bossPosY;
|
|
||||||
initialPlayerPosX = playerPosX;
|
initialPlayerPosX = playerPosX;
|
||||||
initialPlayerPosY = playerPosY;
|
initialPlayerPosY = playerPosY;
|
||||||
hasMoved = false;
|
hasMoved = false;
|
||||||
@@ -113,12 +113,12 @@ function gameOver() {
|
|||||||
fill(255, 0, 0);
|
fill(255, 0, 0);
|
||||||
textSize(40);
|
textSize(40);
|
||||||
textAlign(CENTER);
|
textAlign(CENTER);
|
||||||
text("Game Over", width / 2, height / 2 - height/6);
|
text("Game Over", width / 2, height / 2 - height / 6);
|
||||||
|
|
||||||
fill(255, 255, 255)
|
fill(255, 255, 255)
|
||||||
textSize(18);
|
textSize(18);
|
||||||
textAlign(CENTER);
|
textAlign(CENTER);
|
||||||
text("Score: " + int(time), width / 2, height / 2 - height/8);
|
text("Score: " + int(time), width / 2, height / 2 - height / 8);
|
||||||
|
|
||||||
textSize(32);
|
textSize(32);
|
||||||
textAlign(CENTER, CENTER);
|
textAlign(CENTER, CENTER);
|
||||||
@@ -126,9 +126,9 @@ function gameOver() {
|
|||||||
text(letters[currentIndex[1]], width / 2, height / 2);
|
text(letters[currentIndex[1]], width / 2, height / 2);
|
||||||
text(letters[currentIndex[2]], width / 2 + 30, height / 2);
|
text(letters[currentIndex[2]], width / 2 + 30, height / 2);
|
||||||
|
|
||||||
text("Restart", width / 2, height / 2 + height/12);
|
text("Restart", width / 2, height / 2 + height / 12);
|
||||||
|
|
||||||
text("Main Menu", width / 2, height / 2 + height/6);
|
text("Main Menu", width / 2, height / 2 + height / 6);
|
||||||
pop();
|
pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -395,7 +395,7 @@ function draw() {
|
|||||||
stroke(205, 205, 205)
|
stroke(205, 205, 205)
|
||||||
strokeWeight(2)
|
strokeWeight(2)
|
||||||
fill(0, 0, 0, 0)
|
fill(0, 0, 0, 0)
|
||||||
rect(width / 2, height / 2 + height/12, 110, 40)
|
rect(width / 2, height / 2 + height / 12, 110, 40)
|
||||||
pop()
|
pop()
|
||||||
}
|
}
|
||||||
if (buttonSelectDead == 2) {
|
if (buttonSelectDead == 2) {
|
||||||
@@ -403,7 +403,7 @@ function draw() {
|
|||||||
stroke(205, 205, 205)
|
stroke(205, 205, 205)
|
||||||
strokeWeight(2)
|
strokeWeight(2)
|
||||||
fill(0, 0, 0, 0)
|
fill(0, 0, 0, 0)
|
||||||
rect(width / 2, height / 2 + height/6, 160, 40)
|
rect(width / 2, height / 2 + height / 6, 160, 40)
|
||||||
pop()
|
pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,7 +451,7 @@ function phase() {
|
|||||||
switch (true) {
|
switch (true) {
|
||||||
case (time < 20):
|
case (time < 20):
|
||||||
phases[0] = true;
|
phases[0] = true;
|
||||||
paternArray = [1];
|
paternArray = [5];
|
||||||
shotSpeedAdj = 2;
|
shotSpeedAdj = 2;
|
||||||
push();
|
push();
|
||||||
fill(255, 0, 255);
|
fill(255, 0, 255);
|
||||||
@@ -461,7 +461,7 @@ function phase() {
|
|||||||
pop();
|
pop();
|
||||||
break;
|
break;
|
||||||
case (time < 60):
|
case (time < 60):
|
||||||
shotSpeedAdj = 5;
|
shotSpeedAdj = 3;
|
||||||
paternArray = [5];
|
paternArray = [5];
|
||||||
phases[0] = false;
|
phases[0] = false;
|
||||||
phases[1] = true;
|
phases[1] = true;
|
||||||
@@ -559,10 +559,6 @@ function spawnRandomBullet() {
|
|||||||
}
|
}
|
||||||
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
|
||||||
}
|
}
|
||||||
if (!(patern == 2)) {
|
|
||||||
bossPosX = width / 2;
|
|
||||||
bossPosY = 100;
|
|
||||||
}
|
|
||||||
if (patern == 3) {
|
if (patern == 3) {
|
||||||
shotPosX = bossPosX;
|
shotPosX = bossPosX;
|
||||||
shotPosY = bossPosY;
|
shotPosY = bossPosY;
|
||||||
@@ -629,6 +625,28 @@ function spawnRandomBullet() {
|
|||||||
bulletAmount = 5;
|
bulletAmount = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// function bouncing() {
|
||||||
|
// // Update position
|
||||||
|
// bossPosX += bossVelX;
|
||||||
|
// bossPosY += bossVelY;
|
||||||
|
// // Check for bounce
|
||||||
|
// if (bossPosX > width - 25) {
|
||||||
|
// bossVelX = random([-4,-5,-6])
|
||||||
|
// }
|
||||||
|
// if (bossPosX < 25) {
|
||||||
|
// bossVelX = random([4,5,6])
|
||||||
|
// }
|
||||||
|
// if (bossPosY > height - 25) {
|
||||||
|
// bossVelY = random([-4,-5,-6])
|
||||||
|
// }
|
||||||
|
// if (bossPosY < 25) {
|
||||||
|
// bossVelY = random([4,5,6])
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Draw the boss
|
||||||
|
// circle(bossPosX, bossPosY, 50);
|
||||||
|
// }
|
||||||
|
|
||||||
function game() {
|
function game() {
|
||||||
if (!(lives == 0)) {
|
if (!(lives == 0)) {
|
||||||
// draw player
|
// draw player
|
||||||
@@ -637,11 +655,12 @@ function game() {
|
|||||||
fill(0, 255, 255)
|
fill(0, 255, 255)
|
||||||
circle(constrain(playerPosX, 0 + radius, width - radius), constrain(playerPosY, 0 + radius, height - radius), playerSize);
|
circle(constrain(playerPosX, 0 + radius, width - radius), constrain(playerPosY, 0 + radius, height - radius), playerSize);
|
||||||
pop();
|
pop();
|
||||||
movementCheck()
|
movementCheck();
|
||||||
// draw boss
|
//bouncing();
|
||||||
|
|
||||||
push();
|
push();
|
||||||
fill(255, 165, 0)
|
fill(255, 165, 0)
|
||||||
circle(x2, y2, 50);
|
|
||||||
pop();
|
pop();
|
||||||
if (hasMoved == true) {
|
if (hasMoved == true) {
|
||||||
push();
|
push();
|
||||||
|
Reference in New Issue
Block a user