Really cool game
This commit is contained in:
24
bullet.js
Normal file
24
bullet.js
Normal file
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user