Sam
2023-11-30 22:38:27 +01:00
2 changed files with 9 additions and 4 deletions

View File

@@ -240,10 +240,12 @@ function spawnRandomBullet(){
shotPosY = 100; shotPosY = 100;
angle = 0; angle = 0;
// changing the angle of the bullets // changing the angle of the bullets
for (let i = 0; i < 140; i++) { for (let i = 0; i < 86; i++) {
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, angle, shotPosX, shotPosY, hasMoved)); bullets.push(new bullet(0, 100, radius, shotSpeed, shotPosX, shotPosY, hasMoved, angle));
angle += 360 / 50; angle -= 360 / 3;
} bulletsspliced = bullets.splice(i);
}
} }
} }

View File

@@ -1,5 +1,6 @@
class bullet { 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.targetx = targetx;
this.targety = targety; this.targety = targety;
this.x = shotPosX; this.x = shotPosX;
@@ -18,6 +19,8 @@ class bullet {
this.projectile = createVector(this.x, this.y); this.projectile = createVector(this.x, this.y);
this.direction = createVector(this.targetx - this.projectile.x, this.targety - this.projectile.y); this.direction = createVector(this.targetx - this.projectile.x, this.targety - this.projectile.y);
this.direction.normalize(); this.direction.normalize();
this.direction.rotate(this.angle);
} }
draw() { draw() {