PASS — this code satisfies the rule
float x = 200, y = 200, dx = 3, dy = 2;
void setup() {
size(400, 400);
}
void draw() {
background(255);
moveBall();
bounce();
ellipse(x, y, 20, 20);
}
void moveBall() {
x += dx;
y += dy;
}
void bounce() {
if (x < 0 || x > width) dx = -dx;
if (y < 0 || y > height) dy = -dy;
}
FAIL — this code triggers the rule
float x = 200, y = 200, dx = 3, dy = 2, px = 150;
int score = 0, lives = 3, level = 1, hits = 0;
void setup() {
size(400, 400);
}
void draw() { // over 50 statements in one function
background(255); fill(0); noStroke(); textSize(16); rectMode(CORNER);
x += dx; y += dy; px = constrain(mouseX - 50, 0, width - 100);
if (x < 10) { x = 10; dx = -dx; hits++; }
if (x > width - 10) { x = width - 10; dx = -dx; hits++; }
if (y < 10) { y = 10; dy = -dy; hits++; }
if (y > 370 && x > px && x < px + 100) { y = 370; dy = -dy; score++; }
if (y > height) { lives--; x = 200; y = 200; dy = 2; }
if (score > 5 * level) { level++; dx = dx * 1.2; dy = dy * 1.2; }
if (lives <= 0) { lives = 3; score = 0; level = 1; dx = 3; dy = 2; }
fill(255, 0, 0); ellipse(x, y, 20, 20); fill(0, 0, 255); rect(px, 380, 100, 10);
fill(0); text("Score: " + score, 20, 30); text("Lives: " + lives, 20, 50);
text("Level: " + level, 20, 70); text("Hits: " + hits, 20, 90);
stroke(0); strokeWeight(2); line(0, 395, width, 395); noStroke();
}