betered dash + wait function

This commit is contained in:
Mees Roelofsz
2023-12-05 15:46:51 +01:00
parent c9aee31889
commit a0b69ecb76

View File

@@ -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