Updated webdev

This commit is contained in:
sam
2023-11-28 13:18:36 +01:00
parent e47ec307b7
commit 8a8353b645
3 changed files with 61 additions and 1 deletions

View File

@@ -70,7 +70,9 @@ async function disconnect() {
let Playerposx = 500;
let Playerposy = 300;
let bullets = [];
let myBullet = new bullet();
let playerSpeed = 5;
async function Movementloop() {
@@ -83,6 +85,20 @@ if (booleanArray[2]) {
if (booleanArray[0]) {
Playerposy -= 2;}
}
function keyPressed() {
if (keyIsDown(LEFT_ARROW) && playerPosX > 0 + radius) {
playerPosX -= playerSpeed;
}
if (keyIsDown(RIGHT_ARROW) && playerPosX < width - radius) {
playerPosX += playerSpeed;
}
if (keyIsDown(UP_ARROW) && playerPosY > 0 + radius) {
playerPosY -= playerSpeed;
}
if (keyIsDown(DOWN_ARROW) && playerPosY < height - radius) {
playerPosY += playerSpeed;
}
}
// the function setup() is called once when the page is loaded