Rig up some funky sounds

This commit is contained in:
Luke Murphy 2019-12-19 18:55:32 +07:00
parent f95393a46e
commit 87bc40a52b
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -122,6 +122,8 @@ class GeneratedShape {
this.xDirection = 1;
this.yDirection = 1;
this.synth = new p5.MonoSynth();
}
collide(shapes) {
@ -158,7 +160,12 @@ class GeneratedShape {
/**
* Play a sound after a collision is detected.
**/
return; // TODO: placeholder for now ...
var notes = ["G2", "C3", "G3"];
var duration = 0.8;
var time = 0;
var velocity = 0.5;
var index = random(0, notes.length + 1);
this.synth.play(notes[index], velocity, time, duration);
}
move() {