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:
45
web/game.js
45
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,9 +12,9 @@ let playerSpeed = 4;
|
||||
let booleanArray = window.booleanArray;
|
||||
let lives = 1;
|
||||
|
||||
let bossPosX = 500;
|
||||
let bossPosX = width / 2;
|
||||
let bossPosY = 100;
|
||||
let shotSpeed = 9;
|
||||
let shotSpeed = 12;
|
||||
let projectile;
|
||||
let projSize = 5;
|
||||
let shot = false;
|
||||
@@ -75,7 +75,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;
|
||||
@@ -110,8 +110,23 @@ function keyPressed() {
|
||||
if (keyIsDown(DOWN_ARROW) && playerPosY < height - radius) {
|
||||
playerPosY += playerSpeed;
|
||||
}
|
||||
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
|
||||
@@ -174,8 +189,8 @@ function draw() {
|
||||
circle(x4, y4, 50);
|
||||
circle(x5, y5, 50);
|
||||
} else {
|
||||
x2 = bossPosX;
|
||||
y2 = bossPosY;
|
||||
x2 = width / 2;
|
||||
y2 = 100;
|
||||
}
|
||||
|
||||
bullets.forEach(myBullet => {
|
||||
@@ -213,22 +228,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));
|
||||
}
|
||||
@@ -251,7 +266,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) {
|
||||
|
Reference in New Issue
Block a user