|
|
@ -202,6 +202,11 @@ class GeneratedShape { |
|
|
|
this.xs = []; |
|
|
|
this.ys = []; |
|
|
|
|
|
|
|
// vector listing of the above xs, ys so that we can pass these lists to
|
|
|
|
// the collidePolyPoly function for collision detection which expects
|
|
|
|
// vector objects, not plain x, y coordinates as in xs, ys.
|
|
|
|
this.vectors = []; |
|
|
|
|
|
|
|
// ???
|
|
|
|
this.angles = []; |
|
|
|
|
|
|
@ -243,8 +248,9 @@ class GeneratedShape { |
|
|
|
for (let i = 0; i < this.edges; i++) { |
|
|
|
this.startXs[i] = 0; |
|
|
|
this.startYs[i] = 0; |
|
|
|
this.ys[i] = 0; |
|
|
|
this.xs[i] = 0; |
|
|
|
this.ys[i] = 0; |
|
|
|
this.vectors[i] = createVector(this.xs[i], this.ys[i]); |
|
|
|
this.angles[i] = 0; |
|
|
|
|
|
|
|
// this directly influences the shape of the size alongside the
|
|
|
@ -262,7 +268,30 @@ class GeneratedShape { |
|
|
|
/** |
|
|
|
* Detect if the shape collides with another shape. |
|
|
|
**/ |
|
|
|
return false; // TODO: implement once again
|
|
|
|
if (shapes.length === 1) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
for (let i = 0; i < shapes.length; i++) { |
|
|
|
let shape = shapes[i]; |
|
|
|
|
|
|
|
if (this === shape) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
// don't detect if one shape is fully inside another
|
|
|
|
let interiorCollision = false; |
|
|
|
|
|
|
|
var collision = collidePolyPoly( |
|
|
|
this.vectors, |
|
|
|
shape.vectors, |
|
|
|
interiorCollision |
|
|
|
); |
|
|
|
|
|
|
|
if (collision === true) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sound() { |
|
|
@ -367,6 +396,7 @@ class GeneratedShape { |
|
|
|
this.startXs[i] + sin(radians(this.angles[i])) * (this.accelX * 2); |
|
|
|
this.ys[i] = |
|
|
|
this.startYs[i] + sin(radians(this.angles[i])) * (this.accelY * 2); |
|
|
|
this.vectors[i] = createVector(this.xs[i], this.ys[i]); |
|
|
|
this.angles[i] += this.frequencies[i]; |
|
|
|
} |
|
|
|
} |
|
|
|