trying to add dash
This commit is contained in:
38
web/game.js
38
web/game.js
@@ -11,10 +11,12 @@ 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;
|
||||
let shotSpeed = 9;
|
||||
let shotSpeed = 12;
|
||||
let projectile;
|
||||
let projSize = 5;
|
||||
let shot = false;
|
||||
@@ -98,15 +100,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 (movingX == true) {
|
||||
playerPosX += 100;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,22 +231,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));
|
||||
}
|
||||
@@ -249,7 +269,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