Working through my Simon Game project, how am I able to get the program to randomly press buttons once I hit “Start”? Basically I want to be able to see the buttons being pressed in sequence instead of just hearing the sounds.
I did it with setTimeout and adding a CSS class that is brighter that gets removed after ‘ms’ milliseconds, that creates a flashing effect. If you use setTimeout, you have to do it recursively though, since you can’t loop that function.
$("yourname").addClass(anim);
let audio = new Audio(sounds[color]);
audio.play();
time_id = setTimeout(function() {
$(yourname).removeClass(anim);
audio.pause();
}, ms);`