Hi everyone,
I am trying to write code so that my four squares will change colour after different lengths of time with music in the background.
Currently, I have created the four squares but they change colour on click and not by themselves.
How can I make the code work so that they change on click and also by themselves.
I’m trying to create a kind of dance mat where as a square colour changes, the player must then step on the corresponding square. (I will be using an arduino)
This is what I have so far:
import ddf.minim.*;
AudioPlayer player;
Minim minim;//audio context
void setup()
{
size (640, 640);
minim = new Minim(this);
player = minim.loadFile("Documents/Processing/Music/Missy Elliott - Lose Control (feat. Ciara & Fat Man Scoop) (Edited Album Version).mp3", 2048);
player.play();
}
void draw()
{
square(80, 80, 220);
square(80, 320, 220);
square(320, 80, 220);
square(320, 320, 220);
if (keyPressed) {
if (key == 'b' || key == 'B') {
fill(255);
}
} else {
fill(0);
}
square(80, 80, 220);
if (keyPressed) {
if (key == 'a' || key == 'A') {
fill(255);
}
} else {
fill(0);
square(80, 320, 220);
}
if (keyPressed) {
if (key == 'c' || key == 'C') {
fill(255);
}
} else {
fill(0);
}
square(320, 80, 220);
if (keyPressed) {
if (key == 'd' || key == 'D') {
fill(255);
}
} else {
fill(0);
}
square(320, 320, 220);
}
void stop()
{
player.close();
minim.stop();
super.stop();
}