cleaned up code and added documentation

This commit is contained in:
Sam
2023-12-12 21:45:19 +01:00
parent fbe19ba35e
commit a0c916cafe

View File

@@ -75,8 +75,8 @@ function score() {
}
function gameOver() {
if (lives == 0) {
//game over screen
isDead = true;
push();
fill(255, 0, 0);
@@ -91,6 +91,7 @@ function gameOver() {
pop();
if (key == ' ') {
//reset all the variables so the game can be played again
lives = 1;
time = 0;
bounceX = bossPosX;
@@ -105,19 +106,15 @@ function gameOver() {
isDead = false;
}
}
}
function movementCheck() {
//check if the player has moved
if (playerPosX != initialPlayerPosX || playerPosY != initialPlayerPosY) {
hasMoved = true;
}
}
function keyDown() {
}
async function keyPressed() {
if (!isDead) {
if (keyIsDown(LEFT_ARROW) && playerPosX > 0 + radius) {
@@ -157,10 +154,9 @@ function wait(waitTime) {
}
async function Movementloop() {
//get info from controller and use it to move the player
window.addEventListener('booleanArrayUpdated', function (event) {
// event.detail contains the booleanArray
let booleanArray = event.detail;
// Use booleanArray here...
if (booleanArray[1]) {
playerPosX += playerSpeed;