Browse Source

Fix typo, remove old implementations

main
Luke Murphy 4 years ago
parent
commit
415eab0b7b
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 51
      voicegardens/static/voicegardens.js

51
voicegardens/static/voicegardens.js

@ -154,35 +154,22 @@ class GeneratedShape {
this.colour = this.chooseColour(); this.colour = this.chooseColour();
this.curveTightness = -5; this.curveTightness = -5;
this.xDelta = 0.0;
this.yDelta = 0.0;
this.xSpeed = 0.0;
this.ySpeed = 0.0;
this.springing = 0.0009;
this.damping = 0.98;
} }
collide(shapes) { collide(shapes) {
/** /**
* Detect if the shape collides with another shape. * Detect if the shape collides with another shape.
**/ **/
if (shapes.length === 1) { // TODO: implement once again
return false;
}
for (var shape of shapes) {
if (this === shape) {
continue;
}
var collision = collideCircleCircle(
this.x,
this.y,
this.w,
shape.x,
shape.y,
shape.w
);
if (collision === true) {
return true;
}
}
return false; return false;
} }
@ -190,12 +177,8 @@ class GeneratedShape {
/** /**
* Play a sound after a collision is detected. * Play a sound after a collision is detected.
**/ **/
var notes = ["G2", "C3", "G3"]; // TODO: implement once again
var duration = 0.8; return;
var time = 0;
var velocity = 0.5;
var index = floor(random(0, notes.length));
this.synth.play(notes[index], velocity, time, duration);
} }
move() { move() {
@ -249,7 +232,9 @@ class GeneratedShape {
} }
calculatePoints() { calculatePoints() {
/* Calculate the points of the shape */ /**
* Calculate the vectors of the shape.
**/
for (var i = 0; i < numberOfEdges; i++) { for (var i = 0; i < numberOfEdges; i++) {
var pointX = cos(angle * i) * radius + random(-77, 77); var pointX = cos(angle * i) * radius + random(-77, 77);
var pointY = sin(angle * i) * radius + random(-77, 77); var pointY = sin(angle * i) * radius + random(-77, 77);
@ -258,8 +243,10 @@ class GeneratedShape {
} }
} }
/*function for drawing the shape on the screen*/
createShape() { createShape() {
/**
* Draw curved vectors of the shape.
**/
curveTightness(this.curveTightness); curveTightness(this.curveTightness);
beginShape(); beginShape();
@ -300,7 +287,7 @@ function draw() {
* The p5.js draw loop. * The p5.js draw loop.
**/ **/
background("#69D2E7"); background("#69D2E7");
translate(centerX, centerX); translate(centerX, centerY);
blendMode(BLEND); blendMode(BLEND);
smooth(); smooth();
noStroke(); noStroke();

Loading…
Cancel
Save