summaryrefslogtreecommitdiffstats
path: root/attractors1/particle.js
blob: 89f17a619939a8bb09c3e8de36113553c70f24c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// -------------------------- Particl -------------------------- //

( function() {

function Particle( x, y ) {
  this.x = x;
  this.y = y;
  this.velocity = 0;
  this.accel = 0;
}

var friction = 0.1;


Particle.prototype.update = function() {
  this.velocity += this.accel;
  this.velocity *= ( 1 - friction );
  this.x += this.velocity;
  this.accel = 0;
};

Particle.prototype.applyForce = function( force ) {
  this.accel += force;
};

window.Particle = Particle;

})();