import processing.serial.*;
Serial port;
float brightness=0;
float circleX;
float speedX = 5;
float circleY;
float speedY = 3;
float rectX= 0;
float rectY= 0;
float rect0= rectX + 70;
float rect1 = rectY + 30;
float rectp= 70;
float rectv= 30;
float rect2= rectX + 140;
float rect3 = rectY + 60;
float recto= 140;
float rectm= 0;
float rect4= rectX + 210;
float rect5 = rectY + 30;
float rectl= 210;
float rectr= 30;
float rect6= rectX + 280;
float rect7 = rectY + 60;
float rectq= 280;
float rectw= 0;
float rect8= rectX + 350;
float rect9 = rectY + 30;
float rectj= 350;
float rectk= 30;
float rect10= rectX + 420;
float rect11 = rectY + 60;
float rectt= 100;
float rrect = 20;
float mmclick;
float torta;
PImage img;
void setup () {
port= new Serial(this , "COM12",9600);
port.bufferUntil('\n');
size(640,360);
circleX = random(540);
circleY = 160;
img = loadImage("ark.jpg");
}
void mousePressed(){
circleX=random(640);
circleY=50;
}
void draw() {
background(0,30,30);
image(img,10,5);
stroke(50);
fill(255);
ellipse(circleX,circleY,24,24);
fill(0,0,255);
rect(rectj,rectk,70,30,3,3,3,3);
fill(255,0,0);
rect(recto,rectm,70,30,3,3,3,3);
fill(255,0,0);
rect(rectq,rectw,70,30,3,3,3,3);
fill(0,0,255);
rect(rectl,rectr,70,30,3,3,3,3);
fill(255,0,0);
rect(rectX,rectY,70,30,3,3,3,3);
fill(0,0,255);
rect(rectp,rectv,70,30,3,3,3,3);
fill(200);
rect(brightness,340,rectt,rrect,18,18,18,18);
circleX = circleX + speedX;
circleY = circleY + speedY;
if (circleX > width) {
speedX = -5;
}
if (circleX < 0) {
speedX = 5;
}
if (circleY < 0) {
speedY = 3;
}
if ((circleX > brightness)&&(circleY > 340 )&&(circleX<mmclick)){
speedY = -3;
}
if (circleY > 350 ){
speedY = 3;
}
if ((circleX >= rectX)&&(circleX <= rect0)&&(circleY>=rectY)&&(circleY<=rect1)) {
rectX = -500;
rectY = -500;
rect0 = -500;
rect1 = -500;
speedX = 5;
speedY = 3;
}
if ((circleX >= rectp)&&(circleX <= rect2)&&(circleY>=rectv)&&(circleY<=rect3)) {
rectp = -500;
rectv = -500;
rect2 = -500;
rect3 = -500;
speedX = 5;
speedY = 3;
}
if ((circleX >= recto)&&(circleX <= rect4)&&(circleY>=rectm)&&(circleY<=rect5)) {
recto = -500;
rectm = -500;
rect4 = -500;
rect5 = -500;
speedX = -5;
speedY = 3;
}
if ((circleX >= rectl)&&(circleX <= rect6)&&(circleY>=rectr)&&(circleY<=rect7)) {
rectl = -500;
rectr = -500;
rect6 = -500;
rect7 = -500;
speedX = -5;
speedY = 3;
}
if ((circleX >= rectq)&&(circleX <= rect8)&&(circleY>=rectw)&&(circleY<=rect9)) {
rectq = -500;
rectw = -500;
rect8 = -500;
rect9 = -500;
speedX = 5;
speedY = 3;
}
if ((circleX >= rectj)&&(circleX <= rect10)&&(circleY>=rectk)&&(circleY<=rect11)) {
rectj = -500;
rectk = -500;
rect10 = -500;
rect11 = -500;
speedX = 5;
speedY = 3;
}
if ((rectX == -500)&&(rectY == -500)&&(rect1 == -500)&&(rect0 == -500)&&(rectp == -500)&&(rectv == -500)&&(rect2 == -500)&&(rect3 == -500)
&&(recto == -500)&&(rectm == -500)&&(rect4 == -500)&&(rect5 == -500)&&(rectl == -500)&&(rectr == -500)&&(rect6 == -500)&&(rect7 == -500)
&&(rectq == -500)&&(rectw == -500)&&(rect8 == -500)&&(rect9 == -500)&&(rectj == -500)&&(rectk == -500)&&(rect10 == -500)&&(rect11 == -500)) {
circleX = 300;
circleY = 200;
rectX = random(640);
rectY = 0;
rect0 = rectX + 70;
rect1 = rectY + 30;
rectp = random(640);
rectv = 30;
rect2 = rectp + 70;
rect3 = rectv + 30;
recto = random(640);
rectm = 60;
rect4 = recto + 70;
rect5 = rectm + 30;
rectl = random(640);
rectr = 90;
rect6 = rectl + 70;
rect7 = rectr + 30;
rectq = random(640);
rectw = 120;
rect8 = rectq + 70;
rect9 = rectw + 30;
rectj = random(640);
rectk = 150;
rect10 = rectj + 70;
rect11 = rectk + 30;
rectt = rectt - 20;
mmclick = mmclick - 20;
}
if ((rectX == -500)&&(rectY == -500)&&(rect1 == -500)&&(rect0 == -500)) {
textSize(25);
text("100",35,310);
}
if ((rectp == -500)&&(rectv == -500)&&(rect2 == -500)&&(rect3 == -500)) {
textSize(25);
text("100",35,310);
}
if ((recto == -500)&&(rectm == -500)&&(rect4 == -500)&&(rect5 == -500)) {
textSize(25);
text("100",35,310);
}
if ((rectl == -500)&&(rectr == -500)&&(rect6 == -500)&&(rect7 == -500)) {
textSize(25);
text("100",35,310);
}
if ((rectq == -500)&&(rectw == -500)&&(rect8 == -500)&&(rect9 == -500)) {
textSize(25);
text("100",35,310);
}
if ((rectj == -500)&&(rectk == -500)&&(rect10 == -500)&&(rect11 == -500)) {
textSize(25);
text("100",35,310);
}
if ((rectp == -500)&&(rectv == -500)&&(rect2 == -500)&&(rect3 == -500)&&(rectX == -500)&&(rectY == -500)&&(rect1 == -500)&&(rect0 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
if ((rectX == -500)&&(rectY == -500)&&(rect1 == -500)&&(rect0 == -500) && (recto == -500)&&(rectm == -500)&&(rect4 == -500)&&(rect5 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
if ((rectX == -500)&&(rectY == -500)&&(rect1 == -500)&&(rect0 == -500) &&(rectl == -500)&&(rectr == -500)&&(rect6 == -500)&&(rect7 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
if ((rectX == -500)&&(rectY == -500)&&(rect1 == -500)&&(rect0 == -500) &&(rectq == -500)&&(rectw == -500)&&(rect8 == -500)&&(rect9 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
if ((rectX == -500)&&(rectY == -500)&&(rect1 == -500)&&(rect0 == -500) &&(rectj == -500)&&(rectk == -500)&&(rect10 == -500)&&(rect11 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
if ((rectp == -500)&&(rectv == -500)&&(rect2 == -500)&&(rect3 == -500) &&(rectj == -500)&&(rectk == -500)&&(rect10 == -500)&&(rect11 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
if ((rectp == -500)&&(rectv == -500)&&(rect2 == -500)&&(rect3 == -500) &&(rectq == -500)&&(rectw == -500)&&(rect8 == -500)&&(rect9 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
if ((rectp == -500)&&(rectv == -500)&&(rect2 == -500)&&(rect3 == -500) &&(rectl == -500)&&(rectr == -500)&&(rect6 == -500)&&(rect7 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
if ((rectp == -500)&&(rectv == -500)&&(rect2 == -500)&&(rect3 == -500) &&(recto == -500)&&(rectm == -500)&&(rect4 == -500)&&(rect5 == -500)) {
text("100",500,500);
textSize(25);
text("200",35,310);
}
mmclick = brightness+100;
}
void serialEvent (Serial port)
{
brightness= float(port.readStringUntil('\n'));
}
Comments