Skip to content

Commit 72f0ef0

Browse files
committed
Retwerkin stuff
1 parent 27b3187 commit 72f0ef0

5 files changed

Lines changed: 30 additions & 19 deletions

File tree

website/source/javascripts/app/Engine.Particle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Engine.Particle.prototype = {
162162
},
163163

164164
kill: function(engine){
165-
engine._deferred.push(this);
165+
engine._deferredParticles.push(this);
166166
return this;
167167
},
168168

website/source/javascripts/app/Engine.Shape.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ Engine.Shape = function(x, y, width, height, points, polygons){
4040

4141
Engine.Shape.prototype = {
4242

43+
selfDestruct: function(time){
44+
this.destruct = time;
45+
return this;
46+
},
47+
4348
update: function(engine){
4449
var p;
4550

@@ -52,6 +57,8 @@ Engine.Shape.prototype = {
5257
this.polygons[p].update(engine);
5358
// this.polygons[p].draw(this.context, scale);
5459
}
60+
61+
return this;
5562
},
5663

5764
draw: function(ctx, scale){
@@ -63,6 +70,7 @@ Engine.Shape.prototype = {
6370
this.polygons[p].draw(ctx, scale);
6471
}
6572
ctx.restore();
73+
return this;
6674
}
6775

6876
};

website/source/javascripts/app/Engine.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* jshint unused: false */
22
/* global console */
3-
(function(Base, Vector, Circle){
3+
(function(Base, Vector, Logo){
44

55
var sqrt, pow, Engine;
66

@@ -23,15 +23,11 @@ Engine = Base.extend({
2323
scale: window.devicePixelRatio || 1,
2424
// scale:1,
2525

26+
shapes : [],
2627
particles : [],
27-
_deferred : [],
2828

29-
// points : [],
30-
// polygons : [],
31-
shapes: [],
32-
33-
speed: 1,
34-
accel: 0.08,
29+
_deferredParticles: [],
30+
_deferredShapes: [],
3531

3632
constructor: function(canvas, bg){
3733
var image, el;
@@ -96,8 +92,8 @@ Engine = Base.extend({
9692
(this.height / 2 - 180),
9793
360,
9894
360,
99-
Circle.Points,
100-
Circle.Polygons
95+
Logo.Points,
96+
Logo.Polygons
10197
);
10298
},
10399

@@ -123,7 +119,6 @@ Engine = Base.extend({
123119
this.now = Date.now() / 1000;
124120

125121
tick = Math.min(this.now - this.last, 0.017);
126-
this.tick = this.speed * tick;
127122

128123
this.renderStarfield(this.now);
129124
this.tick = tick;
@@ -139,7 +134,7 @@ Engine = Base.extend({
139134

140135
renderTessellation: function(){
141136
var scale = this.scale,
142-
p;
137+
p, index;
143138

144139
for (p = 0; p < this.shapes.length; p++) {
145140
this.shapes[p].update(this);
@@ -148,6 +143,14 @@ Engine = Base.extend({
148143

149144
this.logo.update(this);
150145
this.logo.draw(this.context, scale);
146+
147+
// Remove destroyed shapes
148+
for (p = 0; p < this._deferredShapes.length; p++) {
149+
index = this.shapes.indexOf(this._deferredShapes.pop());
150+
if (index >= 0) {
151+
this.shapes.splice(index, 1);
152+
}
153+
}
151154
},
152155

153156
generateParticles: function(num, fixed){
@@ -180,9 +183,9 @@ Engine = Base.extend({
180183
.draw(this.context, scale);
181184
}
182185

183-
// Remove destroyed entities
184-
for (p = 0; p < this._deferred.length; p++) {
185-
index = this.particles.indexOf(this._deferred.pop());
186+
// Remove destroyed particles
187+
for (p = 0; p < this._deferredParticles.length; p++) {
188+
index = this.particles.indexOf(this._deferredParticles.pop());
186189
if (index >= 0) {
187190
this.particles.splice(index, 1);
188191
}
@@ -215,4 +218,4 @@ Engine.clone = function(ref) {
215218

216219
window.Engine = Engine;
217220

218-
})(window.Base, window.Vector, window.Circle);
221+
})(window.Base, window.Vector, window.Logo);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// jshint unused:false
2-
var Circle = {
2+
var Logo = {
33
"Points": [
44
{
55
"id": "point-0",

website/source/layouts/_footer.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<script type="text/javascript" src="/javascripts/lib/Base.js"></script>
2626
<script type="text/javascript" src="/javascripts/lib/String.substitute.js"></script>
2727
<script type="text/javascript" src="/javascripts/lib/Vector.js"></script>
28-
<script type="text/javascript" src="/javascripts/app/Circle.js"></script>
28+
<script type="text/javascript" src="/javascripts/app/Logo.js"></script>
2929
<script type="text/javascript" src="/javascripts/app/Engine.js"></script>
3030
<script type="text/javascript" src="/javascripts/app/Engine.Particle.js"></script>
3131
<script type="text/javascript" src="/javascripts/app/Engine.Particle.Fixed.js"></script>

0 commit comments

Comments
 (0)