|
@ -175,6 +175,9 @@ class GeneratedShape { |
|
|
* Initialise the new shape. |
|
|
* Initialise the new shape. |
|
|
**/ |
|
|
**/ |
|
|
|
|
|
|
|
|
|
|
|
// mouse hover awareness for sound playing
|
|
|
|
|
|
this.hover = false; |
|
|
|
|
|
|
|
|
// The opacity of the shape. This controls whether we can see the shape or
|
|
|
// The opacity of the shape. This controls whether we can see the shape or
|
|
|
// not (transparency). It starts at zero as we want to fade the shapes in
|
|
|
// not (transparency). It starts at zero as we want to fade the shapes in
|
|
|
// when they enter the environment
|
|
|
// when they enter the environment
|
|
@ -466,6 +469,7 @@ function draw() { |
|
|
|
|
|
|
|
|
// generate a new shape after a sound recording
|
|
|
// generate a new shape after a sound recording
|
|
|
if (newSoundJustRecorded === true) { |
|
|
if (newSoundJustRecorded === true) { |
|
|
|
|
|
// build a new copy of the recording to store on the shape object
|
|
|
let soundBlob = recording.getBlob(); |
|
|
let soundBlob = recording.getBlob(); |
|
|
let recordedSound = new p5.SoundFile(new p5.File(soundBlob)); |
|
|
let recordedSound = new p5.SoundFile(new p5.File(soundBlob)); |
|
|
let newShape = new GeneratedShape(recordedSound); |
|
|
let newShape = new GeneratedShape(recordedSound); |
|
@ -478,6 +482,21 @@ function draw() { |
|
|
for (let i = 0; i < shapes.length; i++) { |
|
|
for (let i = 0; i < shapes.length; i++) { |
|
|
let shape = shapes[i]; |
|
|
let shape = shapes[i]; |
|
|
|
|
|
|
|
|
|
|
|
// if hovering over the shape, play the recorded sound
|
|
|
|
|
|
let hovering = collidePointPoly( |
|
|
|
|
|
mouseX - screenX, |
|
|
|
|
|
mouseY - screenY, |
|
|
|
|
|
shape.vectors |
|
|
|
|
|
); |
|
|
|
|
|
if (hovering === true) { |
|
|
|
|
|
if (shape.hover === false) { |
|
|
|
|
|
shape.sound(); |
|
|
|
|
|
shape.hover = true; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
shape.hover = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// randomly move the shapes
|
|
|
// randomly move the shapes
|
|
|
if (positionTick) { |
|
|
if (positionTick) { |
|
|
shape.destX = random(windowWidth); |
|
|
shape.destX = random(windowWidth); |
|
|