betered dash + wait function
This commit is contained in:
26
web/game.js
26
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;
|
||||
}
|
||||
if (key == 'e') {
|
||||
// adding a quick movement button that moves you further in the direction your already moving
|
||||
playerSpeed += 2;
|
||||
wait(2);
|
||||
} else {
|
||||
movingY = false;
|
||||
playerSpeed = 4;
|
||||
}
|
||||
}
|
||||
if (key == ' ' && shot == false && lives != 0) {
|
||||
|
||||
function wait(waitTime){
|
||||
startTime = time;
|
||||
if (startTime + waitTime > time){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function Movementloop() {
|
||||
window.addEventListener('booleanArrayUpdated', function (event) {
|
||||
// event.detail contains the booleanArray
|
||||
|
Reference in New Issue
Block a user