From ee7f0317750131e458d5614f2e7b9f7cd46230c2 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 28 Nov 2023 16:00:01 +0100 Subject: [PATCH] put bullet direction into update --- webdev/basicbullet.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/webdev/basicbullet.js b/webdev/basicbullet.js index 08f4c9d..217d76d 100644 --- a/webdev/basicbullet.js +++ b/webdev/basicbullet.js @@ -24,7 +24,6 @@ class bullet { this.direction = createVector(this.targetX - this.projectile.x, this.targetY - this.projectile.y); this.direction.normalize(); - this.projectile.add(p5.Vector.mult(this.direction, this.speed)); } @@ -32,11 +31,14 @@ class bullet { draw() { //push en pop zorgen er voor dat de code tussen push en pop een eigen canvas heeft. Dus dat er meerdere projectielen tegelijk kunnen zijn. + push(); fill(0, 255, 0); circle(500, 500, this.radius); + pop(); // Set the initial position of the projectile to the player's position + this.projectile.add(p5.Vector.mult(this.direction, this.speed)); if (dist(this.projectile.x, this.projectile.y, this.directionX, this.directionY) <= this.radius) { @@ -50,5 +52,10 @@ class bullet { } + // // Move the projectile towards the movable circle + update() { + this.projectile.add(p5.Vector.mult(this.direction, this.speed)); + } + } \ No newline at end of file