Retwerkin stuff
This commit is contained in:
parent
27b3187ce9
commit
72f0ef0e8e
|
@ -162,7 +162,7 @@ Engine.Particle.prototype = {
|
|||
},
|
||||
|
||||
kill: function(engine){
|
||||
engine._deferred.push(this);
|
||||
engine._deferredParticles.push(this);
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
@ -40,6 +40,11 @@ Engine.Shape = function(x, y, width, height, points, polygons){
|
|||
|
||||
Engine.Shape.prototype = {
|
||||
|
||||
selfDestruct: function(time){
|
||||
this.destruct = time;
|
||||
return this;
|
||||
},
|
||||
|
||||
update: function(engine){
|
||||
var p;
|
||||
|
||||
|
@ -52,6 +57,8 @@ Engine.Shape.prototype = {
|
|||
this.polygons[p].update(engine);
|
||||
// this.polygons[p].draw(this.context, scale);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
draw: function(ctx, scale){
|
||||
|
@ -63,6 +70,7 @@ Engine.Shape.prototype = {
|
|||
this.polygons[p].draw(ctx, scale);
|
||||
}
|
||||
ctx.restore();
|
||||
return this;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* jshint unused: false */
|
||||
/* global console */
|
||||
(function(Base, Vector, Circle){
|
||||
(function(Base, Vector, Logo){
|
||||
|
||||
var sqrt, pow, Engine;
|
||||
|
||||
|
@ -23,15 +23,11 @@ Engine = Base.extend({
|
|||
scale: window.devicePixelRatio || 1,
|
||||
// scale:1,
|
||||
|
||||
shapes : [],
|
||||
particles : [],
|
||||
_deferred : [],
|
||||
|
||||
// points : [],
|
||||
// polygons : [],
|
||||
shapes: [],
|
||||
|
||||
speed: 1,
|
||||
accel: 0.08,
|
||||
_deferredParticles: [],
|
||||
_deferredShapes: [],
|
||||
|
||||
constructor: function(canvas, bg){
|
||||
var image, el;
|
||||
|
@ -96,8 +92,8 @@ Engine = Base.extend({
|
|||
(this.height / 2 - 180),
|
||||
360,
|
||||
360,
|
||||
Circle.Points,
|
||||
Circle.Polygons
|
||||
Logo.Points,
|
||||
Logo.Polygons
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -123,7 +119,6 @@ Engine = Base.extend({
|
|||
this.now = Date.now() / 1000;
|
||||
|
||||
tick = Math.min(this.now - this.last, 0.017);
|
||||
this.tick = this.speed * tick;
|
||||
|
||||
this.renderStarfield(this.now);
|
||||
this.tick = tick;
|
||||
|
@ -139,7 +134,7 @@ Engine = Base.extend({
|
|||
|
||||
renderTessellation: function(){
|
||||
var scale = this.scale,
|
||||
p;
|
||||
p, index;
|
||||
|
||||
for (p = 0; p < this.shapes.length; p++) {
|
||||
this.shapes[p].update(this);
|
||||
|
@ -148,6 +143,14 @@ Engine = Base.extend({
|
|||
|
||||
this.logo.update(this);
|
||||
this.logo.draw(this.context, scale);
|
||||
|
||||
// Remove destroyed shapes
|
||||
for (p = 0; p < this._deferredShapes.length; p++) {
|
||||
index = this.shapes.indexOf(this._deferredShapes.pop());
|
||||
if (index >= 0) {
|
||||
this.shapes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
generateParticles: function(num, fixed){
|
||||
|
@ -180,9 +183,9 @@ Engine = Base.extend({
|
|||
.draw(this.context, scale);
|
||||
}
|
||||
|
||||
// Remove destroyed entities
|
||||
for (p = 0; p < this._deferred.length; p++) {
|
||||
index = this.particles.indexOf(this._deferred.pop());
|
||||
// Remove destroyed particles
|
||||
for (p = 0; p < this._deferredParticles.length; p++) {
|
||||
index = this.particles.indexOf(this._deferredParticles.pop());
|
||||
if (index >= 0) {
|
||||
this.particles.splice(index, 1);
|
||||
}
|
||||
|
@ -215,4 +218,4 @@ Engine.clone = function(ref) {
|
|||
|
||||
window.Engine = Engine;
|
||||
|
||||
})(window.Base, window.Vector, window.Circle);
|
||||
})(window.Base, window.Vector, window.Logo);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// jshint unused:false
|
||||
var Circle = {
|
||||
var Logo = {
|
||||
"Points": [
|
||||
{
|
||||
"id": "point-0",
|
|
@ -25,7 +25,7 @@
|
|||
<script type="text/javascript" src="/javascripts/lib/Base.js"></script>
|
||||
<script type="text/javascript" src="/javascripts/lib/String.substitute.js"></script>
|
||||
<script type="text/javascript" src="/javascripts/lib/Vector.js"></script>
|
||||
<script type="text/javascript" src="/javascripts/app/Circle.js"></script>
|
||||
<script type="text/javascript" src="/javascripts/app/Logo.js"></script>
|
||||
<script type="text/javascript" src="/javascripts/app/Engine.js"></script>
|
||||
<script type="text/javascript" src="/javascripts/app/Engine.Particle.js"></script>
|
||||
<script type="text/javascript" src="/javascripts/app/Engine.Particle.Fixed.js"></script>
|
||||
|
|
Loading…
Reference in New Issue