Skip to content

Commit

Permalink
Particle spawn position behind plane
Browse files Browse the repository at this point in the history
  • Loading branch information
thombach committed Jun 18, 2022
1 parent 8be9386 commit 0d74913
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contrails.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class Plane {
this.speed = params.planes.speed;
this.size = params.planes.size;
this.angle = angle;
let oppositeAngle = ((angle + 180) % 360) * TO_RADIANS;
this.contrailPos = { x: this.size/2 * Math.cos(oppositeAngle), y: this.size/2 * Math.sin(oppositeAngle)};
this.contrail = [];
}

Expand Down Expand Up @@ -110,7 +112,7 @@ class Plane {
this.draw();

if (this.contrail.length < maxParticleNum) {
this.contrail.push(new Particle({...this.pos}));
this.contrail.push(new Particle({ x: this.pos.x + this.contrailPos.x, y: this.pos.y + this.contrailPos.y}));
}
this.contrail.forEach((particle, index) => {
particle.update();
Expand Down

0 comments on commit 0d74913

Please sign in to comment.