friction
@@ -24,6 +24,9 @@ class ParticleEmitter
24
24
animationSpeed = 0;
25
25
startFrame = 0;
26
26
27
friction = null;
28
angularFriction = 0;
29
27
30
constructor(position, sprite, emissionRate, emissionAngle,
28
31
startRotation, startVelocity, startAngularVelocity, acceleration,
29
32
angularAcceleration, startSize, endSize, lifetimeMin,
@@ -40,10 +43,10 @@ class ParticleEmitter
40
43
this.emissionAngle = emissionAngle;
41
44
42
45
this.startRotation = startRotation;
43
this.startVelocity = startVelocity;
44
this.startAngularVelocity = startAngularVelocity;
45
this.acceleration = acceleration;
46
this.angularAcceleration = angularAcceleration;
46
this.startVelocity = startVelocity * 10;
47
this.startAngularVelocity = startAngularVelocity * 10;
48
this.acceleration = acceleration.stretch(10);
49
this.angularAcceleration = angularAcceleration * 10;
47
50
this.startSize = startSize;
48
51
this.endSize = endSize;
49
52
this.lifetimeMin = lifetimeMin;
@@ -52,6 +55,8 @@ class ParticleEmitter
52
55
this.fadeOut = fadeOut;
53
56
this.startFrame = startFrame;
54
57
this.animationSpeed = animationSpeed;
58
59
this.friction = new vector(0,0);
55
60
}
56
61
57
62
start()
@@ -76,7 +81,8 @@ class ParticleEmitter
76
81
velocity.x, velocity.y, this.startAngularVelocity, this.acceleration.x,
77
82
this.acceleration.y, this.angularAcceleration, this.sprite, this.startSize.x,
78
83
this.startSize.y, this.endSize.x, this.endSize.y, this.lifetimeMin,
79
this.lifetimeMax, this.fadeIn, this.fadeOut, this.startFrame, this.animationSpeed)
84
this.lifetimeMax, this.fadeIn, this.fadeOut, this.startFrame, this.animationSpeed,
85
this.friction, this.angularFriction)
80
86
}
81
87
}
82
88
@@ -150,6 +156,8 @@ class Particle
150
156
fadeOutTime = 0;
151
157
lifeTime = 0;
152
158
lifeTimeStart = 0;
159
friction = null;
160
angularfriction = 0;
153
161
154
162
constructor()
155
163
{
@@ -160,7 +168,7 @@ class Particle
160
168
this.endSize = new vector(0,0)
161
169
}
162
170
163
emit(parent, x, y, r, vx, vy, va, ax, ay, ar, spr, ssx, ssy, esx, esy, lmin, lmax, fi = 0, fo = 0, sf = 0, as = 0)
171
emit(parent, x, y, r, vx, vy, va, ax, ay, ar, spr, ssx, ssy, esx, esy, lmin, lmax, fi = 0, fo = 0, sf = 0, as = 0, fric, anfric)
164
172
{
165
173
this.parent = parent;
166
174
this.position.x = x;
@@ -185,17 +193,24 @@ class Particle
185
193
this.animationSpeed = as;
186
194
this.animTimer = as;
187
195
this.subImage = sf;
196
this.friction = fric;
197
this.angularFriction = anfric;
188
198
}
189
199
190
200
update(deltaTime)
191
201
{
192
this.position.x += this.velocity.x;
193
this.position.y += this.velocity.y;
194
this.velocity.x += this.acceleration.x;
195
this.velocity.y += this.acceleration.y;
196
197
this.rotation += this.angularVelocity;
198
this.angularVelocity += this.angularAcceleration;
202
this.position.x += this.velocity.x * deltaTime;
203
this.position.y += this.velocity.y * deltaTime;
204
this.velocity.x += this.acceleration.x * deltaTime;
205
this.velocity.y += this.acceleration.y * deltaTime;
206
207
this.velocity.x += this.friction.x * deltaTime * -Math.sign(this.velocity.x * 10);
208
this.velocity.y += this.friction.y * deltaTime * -Math.sign(this.velocity.y * 10);
209
210
this.rotation += this.angularVelocity * deltaTime;
211
this.angularVelocity += this.angularAcceleration * deltaTime;
212
213
this.angularVelocity += this.angularFriction * deltaTime * -Math.sign(this.angularVelocity * 10);
199
214
200
215
this.lifeTime -= deltaTime;
201
216
@@ -24,6 +24,9 @@ class ParticleEmitter24
animationSpeed = 0;24
animationSpeed = 0;25
startFrame = 0;25
startFrame = 0;26
26
27
friction = null;28
angularFriction = 0;29
27
constructor(position, sprite, emissionRate, emissionAngle,30
constructor(position, sprite, emissionRate, emissionAngle,28
startRotation, startVelocity, startAngularVelocity, acceleration, 31
startRotation, startVelocity, startAngularVelocity, acceleration, 29
angularAcceleration, startSize, endSize, lifetimeMin, 32
angularAcceleration, startSize, endSize, lifetimeMin, @@ -40,10 +43,10 @@ class ParticleEmitter40
this.emissionAngle = emissionAngle;43
this.emissionAngle = emissionAngle;41
44
42
this.startRotation = startRotation;45
this.startRotation = startRotation;43
this.startVelocity = startVelocity;46
this.startVelocity = startVelocity * 10;44
this.startAngularVelocity = startAngularVelocity;47
this.startAngularVelocity = startAngularVelocity * 10;45
this.acceleration = acceleration;48
this.acceleration = acceleration.stretch(10);46
this.angularAcceleration = angularAcceleration;49
this.angularAcceleration = angularAcceleration * 10;47
this.startSize = startSize;50
this.startSize = startSize;48
this.endSize = endSize;51
this.endSize = endSize;49
this.lifetimeMin = lifetimeMin;52
this.lifetimeMin = lifetimeMin;@@ -52,6 +55,8 @@ class ParticleEmitter52
this.fadeOut = fadeOut;55
this.fadeOut = fadeOut;53
this.startFrame = startFrame;56
this.startFrame = startFrame;54
this.animationSpeed = animationSpeed;57
this.animationSpeed = animationSpeed;58
59
this.friction = new vector(0,0);55
}60
}56
61
57
start()62
start()@@ -76,7 +81,8 @@ class ParticleEmitter76
velocity.x, velocity.y, this.startAngularVelocity, this.acceleration.x, 81
velocity.x, velocity.y, this.startAngularVelocity, this.acceleration.x, 77
this.acceleration.y, this.angularAcceleration, this.sprite, this.startSize.x, 82
this.acceleration.y, this.angularAcceleration, this.sprite, this.startSize.x, 78
this.startSize.y, this.endSize.x, this.endSize.y, this.lifetimeMin, 83
this.startSize.y, this.endSize.x, this.endSize.y, this.lifetimeMin, 79
this.lifetimeMax, this.fadeIn, this.fadeOut, this.startFrame, this.animationSpeed)84
this.lifetimeMax, this.fadeIn, this.fadeOut, this.startFrame, this.animationSpeed, 85
this.friction, this.angularFriction)80
}86
}81
}87
}82
88
@@ -150,6 +156,8 @@ class Particle150
fadeOutTime = 0;156
fadeOutTime = 0;151
lifeTime = 0;157
lifeTime = 0;152
lifeTimeStart = 0;158
lifeTimeStart = 0;159
friction = null;160
angularfriction = 0;153
161
154
constructor()162
constructor()155
{163
{@@ -160,7 +168,7 @@ class Particle160
this.endSize = new vector(0,0)168
this.endSize = new vector(0,0)161
}169
}162
170
163
emit(parent, x, y, r, vx, vy, va, ax, ay, ar, spr, ssx, ssy, esx, esy, lmin, lmax, fi = 0, fo = 0, sf = 0, as = 0)171
emit(parent, x, y, r, vx, vy, va, ax, ay, ar, spr, ssx, ssy, esx, esy, lmin, lmax, fi = 0, fo = 0, sf = 0, as = 0, fric, anfric)164
{172
{165
this.parent = parent;173
this.parent = parent;166
this.position.x = x;174
this.position.x = x;@@ -185,17 +193,24 @@ class Particle185
this.animationSpeed = as;193
this.animationSpeed = as;186
this.animTimer = as;194
this.animTimer = as;187
this.subImage = sf;195
this.subImage = sf;196
this.friction = fric;197
this.angularFriction = anfric;188
}198
}189
199
190
update(deltaTime)200
update(deltaTime)191
{201
{192
this.position.x += this.velocity.x;202
this.position.x += this.velocity.x * deltaTime;193
this.position.y += this.velocity.y;203
this.position.y += this.velocity.y * deltaTime;194
this.velocity.x += this.acceleration.x;204
this.velocity.x += this.acceleration.x * deltaTime;195
this.velocity.y += this.acceleration.y;205
this.velocity.y += this.acceleration.y * deltaTime;196
206
197
this.rotation += this.angularVelocity;207
this.velocity.x += this.friction.x * deltaTime * -Math.sign(this.velocity.x * 10);198
this.angularVelocity += this.angularAcceleration;208
this.velocity.y += this.friction.y * deltaTime * -Math.sign(this.velocity.y * 10);209
210
this.rotation += this.angularVelocity * deltaTime;211
this.angularVelocity += this.angularAcceleration * deltaTime;212
213
this.angularVelocity += this.angularFriction * deltaTime * -Math.sign(this.angularVelocity * 10);199
214
200
this.lifeTime -= deltaTime;215
this.lifeTime -= deltaTime;201
216