int x1, x2, x3, y1, y2 = 400, y3 = 300, k = 0, n = 0; void setup() { fullScreen(); } void draw() { background(0); textSize(20); fill(255, 0 ,0); text(k, 20, 20); fill(0, 255, 0); text(n, width - 40, 20); fill(255, 0, 0); rect(x1, y1, 20, 20); rect(x2, y2, 10, 10); fill(0, 255, 0); rect(x3, y3, 20, 20); if( keyCode == UP) {y1 = y1 - 5;} if( keyCode == DOWN) {y1 = y1 + 5;} if (keyCode == LEFT) {x1 = x1 - 5;} if(keyCode == RIGHT) {x1 = x1 + 5;} int x21 = x1 + 20; int x22 = x1 - 20; int y21 = y1 + 20; int y22 = y1 - 20; if(x1>width) {x1 = 0;} if(x1<0) {x1 = width;} if(y1>height) {y1 = 0;} if(y1<0) {y1 = height;} if(x2<=x21 && x2>=x22 && y2<=y21 && y2>=y22) { x2 = floor(random(width)); y2 = floor(random(height)); k++; } int x31 = x3 + 20; int x32 = x3 - 20; int y31 = y3 + 20; int y32 = y3 - 20; if(x2<=x31 && x2>=x32 && y2<=y31 && y2>=y32) { n++; x2 = floor(random(width)); y2 = floor(random(height)); } if(x3 < x2) {x3 = x3 + 2;} if(x3 > x2) {x3 = x3 - 2;} if(y3 < y2) {y3 = y3 + 2;} if(y3 > y2) {y3 = y3 - 2;} if(k > n+10) {textSize(100); fill(255, 0, 0); text("YOU WIN", 0, height);} if(n > k + 10) { textSize(100); fill(255, 0, 0); text("YOU LOOOOOOSEEEER", 0, height);} }