From 3a9674ff461f9e29b6abcbd73a0408551a4ef7d1 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 28 Nov 2023 14:45:14 +0100 Subject: [PATCH] test if class works --- webdev/{js => }/basicbullet.js | 8 +++++--- webdev/game.js | 4 ++-- webdev/index.html | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) rename webdev/{js => }/basicbullet.js (86%) diff --git a/webdev/js/basicbullet.js b/webdev/basicbullet.js similarity index 86% rename from webdev/js/basicbullet.js rename to webdev/basicbullet.js index df80929..5ab7750 100644 --- a/webdev/js/basicbullet.js +++ b/webdev/basicbullet.js @@ -3,8 +3,10 @@ class bullet { constructor(targetx, targety, radius, speed) { //"This" moet gebruikt worden om de variabelen aan te maken in de class en het zorgt er voor dat de variabelen niet alleen in de constructor gebruikt kunnen worden, //maar ook in de rest van de class - this.x = targetx; - this.y = targety; + this.targetx = targetx; + this.targety = targety; + this.x = 500; + this.y = 100; this.radius = radius; this.speed = speed; @@ -14,7 +16,7 @@ class bullet { this.y = directionY; // Calculate the initial direction - direction = createVector(targetX - projectile.x, targetY - projectile.y); + direction = createVector(this.targetX - projectile.x, this.targetY - projectile.y); direction.normalize(); } diff --git a/webdev/game.js b/webdev/game.js index 9881609..26681db 100644 --- a/webdev/game.js +++ b/webdev/game.js @@ -73,8 +73,7 @@ let playerPosY = 300; let bullets = []; let playerSpeed = 5; let radius = 20; -let myBullet = new bullet(); - +let myBullet = new bullet(); async function Movementloop() { if (booleanArray[1]) { @@ -109,6 +108,7 @@ function setup(){ frameRate(244); // disable the outline of shapes noStroke(); + myBullet(playerPosX, playerPosY, radius, 5); } // the function draw() is called every frame diff --git a/webdev/index.html b/webdev/index.html index c2f686e..2f3bd0a 100644 --- a/webdev/index.html +++ b/webdev/index.html @@ -9,7 +9,7 @@ - +