Hey everyone,
I’m trying to make the squares I’ve created change their colour randomly.
Instead my code is only working on click.
The reason I am doing this is so that when a square changes the colour, the person playing the game has to click that corresponding box, so I need the ‘on click’ to work as well as the colours changing by themselves.
It’s a very basic dance mat.
This is my code 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/groove.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();
}
What do you think? Is there a way to have the squares change their colour at certain times?
I’m trying to use:
int timer=0;
int timeSpan=333;
Thanks so much