From 77272afdc961ca58474e128aa917944d42e8ffff Mon Sep 17 00:00:00 2001 From: Mees Roelofsz Date: Thu, 30 Nov 2023 22:26:39 +0100 Subject: [PATCH] added bulletcircle (laggy) --- web/game.js | 6 +++--- web/js/basicbullet.js | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/web/game.js b/web/game.js index c9b784b..43ebea2 100644 --- a/web/game.js +++ b/web/game.js @@ -235,9 +235,9 @@ function spawnRandomBullet(){ shotPosY = 100; angle = 0; // changing the angle of the bullets - for (let i = 0; i < 140; i++) { - bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, angle, shotPosX, shotPosY, hasMoved)); - angle += 360 / 50; + for (let i = 0; i < 86; i++) { + bullets.push(new bullet(0, 100, radius, shotSpeed, shotPosX, shotPosY, hasMoved, angle)); + angle -= 360 / 3; } } diff --git a/web/js/basicbullet.js b/web/js/basicbullet.js index 3754c0a..7674703 100644 --- a/web/js/basicbullet.js +++ b/web/js/basicbullet.js @@ -1,5 +1,6 @@ class bullet { - constructor(targetx, targety, radius, speed, shotPosX, shotPosY, hasMoved) { // Add hasMoved parameter + constructor(targetx, targety, radius, speed, shotPosX, shotPosY, hasMoved, angle) { // Add hasMoved parameter + this.angle = radians(angle); this.targetx = targetx; this.targety = targety; this.x = shotPosX; @@ -18,6 +19,8 @@ class bullet { this.projectile = createVector(this.x, this.y); this.direction = createVector(this.targetx - this.projectile.x, this.targety - this.projectile.y); this.direction.normalize(); + + this.direction.rotate(this.angle); } draw() {