Slightly better random generation.

Not sure this is right though.

Thinking of going the puller route in this.  I think a catchy tag line
is in order too.
This commit is contained in:
Amadeus Demarzi 2014-07-25 00:22:27 -07:00
parent 23228f9bde
commit 8f327af3c1
1 changed files with 37 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* jshint unused: false */
/* jshint unused:false */
/* global console */
(function(
Base,
@ -147,8 +147,7 @@ Engine = Base.extend({
},
renderTessellation: function(){
var scale = this.scale,
p, index, rando, halfWidth, halfHeight, shape, shapeTemplate;
var scale = this.scale, p, index;
for (p = 0; p < this.shapes.length; p++) {
this.shapes[p].update(this);
@ -168,25 +167,44 @@ Engine = Base.extend({
// 1 Per second? Maybe?
if (Engine.getRandomFloat(0,100) < 1.6666) {
halfWidth = this.width / 2;
halfHeight = this.height / 2;
shapeTemplate = Shapes[Engine.getRandomInt(0, Shapes.length - 1)];
shape = new Engine.Shape(
Engine.getRandomInt(-halfWidth, halfWidth),
Engine.getRandomInt(-halfHeight, halfHeight),
50,
50,
shapeTemplate.points,
shapeTemplate.polygons,
true
);
shape.selfDestruct(10);
// shape.noStroke = true;
// shape.noHueShift = true;
this.shapes.push(shape);
this.generateRandomShape();
}
},
generateRandomShape: function(){
var p, index, rando, halfWidth, halfHeight, iter,
shape, shapeTemplate, columns, rows, modWidth, row, column,
xOffset, yOffset;
iter = 140;
rows = this.height / iter - 1;
modWidth = this.width % iter;
columns = (this.width - modWidth) / iter - 1;
row = Engine.getRandomInt(0, rows);
column = Engine.getRandomInt(0, columns);
halfWidth = this.width / 2;
halfHeight = this.height / 2;
shapeTemplate = Shapes[Engine.getRandomInt(0, Shapes.length - 1)];
xOffset = Engine.getRandomInt(-50, 50);
yOffset = Engine.getRandomInt(-50, 50);
shape = new Engine.Shape(
(iter / 2) + (column * iter) - (modWidth / 2) - halfWidth + xOffset - 25,
(iter / 2) + (row * iter) - halfHeight + yOffset - 25,
50,
50,
shapeTemplate.points,
shapeTemplate.polygons,
true
);
shape.selfDestruct(10);
this.shapes.push(shape);
},
generateParticles: function(num, fixed){
var p;