Files
retro-asteroids/bullet.js
2025-06-25 22:14:38 -05:00

24 lines
435 B
JavaScript

class Bullet {
constructor(pos, angle) {
this.pos = pos.copy();
this.vel = p5.Vector.fromAngle(angle);
this.vel.mult(10);
this.r = 4;
}
update() {
this.pos.add(this.vel);
}
show() {
push();
fill(255);
noStroke();
ellipse(this.pos.x, this.pos.y, this.r * 2);
pop();
}
offscreen() {
return (this.pos.x < 0 || this.pos.x > width || this.pos.y < 0 || this.pos.y > height);
}
}