int color1 = 0;
int color2 = 0;
int color3 = 0;
int color4 = 0;
int color5 = 0;
int color6 = 0;
int start;
void setup() {
start = millis();
size(700,700);
background(255,255,255);
SetRandomColor();
fill(122,122,122);
rect(0,50,50,50);
rect(50,50,50,50);
rect(100,50,50,50);
}
void SetRandomColor()
{
color1 = int(random(3)) +1;
if (color1 == 1)
{
fill(0,255,255);
rect(0,0,50,50);
}
else if (color1 == 2)
{
fill(255,0,255);
rect(0,0,50,50);
}
else if (color1 == 3)
{
fill(255,255,0);
rect(0,0,50,50);
}
color2 = int(random(3)) +1;
if (color2 == 1)
{
fill(0,255,255);
rect(50,0,50,50);
}
else if (color2 == 2)
{
fill(255,0,255);
rect(50,0,50,50);
}
else if (color2 == 3)
{
fill(255,255,0);
rect(50,0,50,50);
}
color3 = int(random(3)) +1;
if (color3 == 1)
{
fill(0,255,255);
rect(100,0,50,50);
}
else if (color3 == 2)
{
fill(255,0,255);
rect(100,0,50,50);
}
else if (color3 == 3)
{
fill(255,255,0);
rect(100,0,50,50);
}
}
void draw(){
int timer = millis()-start;
if (timer > 5000)
{
start = millis();
fill(255,255,255);
rect(0,0,150,50);
}
fill(122,122,122);
rect(0,200,100,100);
fill(0, 102, 153);
text("Перемещать",0,200);
rect(200,200,100,100);
fill(0, 102, 153);
text("Проверить",200,200);
}
void mouseClicked()
{
if (mouseX > 0 && mouseX <= 50 && mouseY > 50 && mouseY < 100)
{
color4++;
if (color4 > 3) color4 = 1;
if (color4 == 1) fill(0,255,255);
if (color4 == 2) fill(255,0,255);
if (color4 == 3) fill(255,255,0);
rect(0,50,50,50);
println("color4");
}
if (mouseX > 50 && mouseX < 100 && mouseY > 50 && mouseY < 100)
{
color5++;
if (color5 > 3) color5 = 1;
if (color5 == 1) fill(0,255,255);
if (color5 == 2) fill(255,0,255);
if (color5 == 3) fill(255,255,0);
rect(50,50,50,50);
println("color5");
}
if (mouseX > 100 && mouseX < 150 && mouseY > 50 && mouseY < 100)
{
color6++;
if (color6 > 3) color6 = 1;
if (color6 == 1) fill(0,255,255);
if (color6 == 2) fill(255,0,255);
if (color6 == 3) fill(255,255,0);
rect(100,50,50,50);
println("color6");
}
if (mouseX > 0 && mouseX < 100 && mouseY > 200 && mouseY < 300)
{
SetRandomColor();
}
if (mouseX > 200 && mouseX < 300 && mouseY > 200 && mouseY < 300)
{
fill(0,0,0);
if (color1 == color4) text("1 = 1",0,350);
if (color2 == color5) text("2 = 2",0,400);
if (color3 == color6) text("3 = 3",0,450);
}
}
|