diff --git a/webdev/game.js b/webdev/game.js index 6b06c1e..9881609 100644 --- a/webdev/game.js +++ b/webdev/game.js @@ -69,11 +69,11 @@ async function disconnect() { //--------------------Game-------------------- let playerPosX = 500; -let Playerposy = 300; +let playerPosY = 300; let bullets = []; -let myBullet = new bullet(); let playerSpeed = 5; -let radius = 2; +let radius = 20; +let myBullet = new bullet(); async function Movementloop() { @@ -82,9 +82,9 @@ if (booleanArray[1]) { if (booleanArray[3]) { playerPosX -= 2;} if (booleanArray[2]) { - Playerposy += 2;} + playerPosY += 2;} if (booleanArray[0]) { - Playerposy -= 2;} + playerPosY -= 2;} } function keyPressed() { if (keyIsDown(LEFT_ARROW) && playerPosX > 0 + radius) { @@ -117,7 +117,7 @@ function draw(){ background(0,0,0,10); // draw a circle at the mouse position - circle(playerPosX, Playerposy, 50); + circle(playerPosX, playerPosY, radius); } //test //test2 \ No newline at end of file diff --git a/webdev/js/basicbullet.js b/webdev/js/basicbullet.js index e747d8f..df80929 100644 --- a/webdev/js/basicbullet.js +++ b/webdev/js/basicbullet.js @@ -9,9 +9,9 @@ class bullet { this.speed = speed; // Set the initial position of the projectile to the player's position - let projectile = createVector(shotPosX, shotPosY); - x = directionX; - y = directionY; + let projectile = createVector(this.x, this.y); + this.x = directionX; + this.y = directionY; // Calculate the initial direction direction = createVector(targetX - projectile.x, targetY - projectile.y); @@ -27,7 +27,7 @@ draw() { fill(255, 0, 0); circle(500, 500, 5); projectile.add(p5.Vector.mult(direction, shotSpeed)); - if (dist(projectile.x, projectile.y, directionX, directionY) <= radius) { + if (dist(projectile.x, projectile.y, directionX, directionY) <= this.radius) { hit = true; } else if (projectile.x < 0 - 10 || projectile.x > width + 10 || projectile.y < 0 - 10 || projectile.y > height + 10) {