// Define Variables float laserX = random(10, 390); float laserY = random(10, 390); float timer = 0; float interval = 2000; float catWidth = 20; float catHeight = 50; int score = 0; float pawTimer = 0; void setup() { size(400, 400); noCursor(); } // Repeats Loop void draw() { // Update if (millis()-timer > interval) { laserX = random(10, 390); laserY = random(10, 390); timer = millis(); } // Living Room Floor background(192, 141, 19); // Wooden Floor Planks fill(70); rect(200, 0, 2, 400); rect(100, 0, 2, 400); rect(300, 0, 2, 400); rect(50, 0, 2, 400); rect(150, 0, 2, 400); rect(250, 0, 2, 400); rect(350, 0, 2, 400); // Rug fill(81, 110, 10); stroke(0); ellipse(width/2, height/2, 215, 125); noStroke(); fill(114, 155, 16); ellipse(width/2, height/2, 175, 105); fill(156, 212, 21); ellipse(width/2, height/2, 125, 75); // Laser Point Light fill(255, 0, 0); noStroke(); ellipse(laserX, laserY, 10, 10); // Cat fill(255, 160, 37); // Cat Torso ellipse(mouseX, mouseY, 20, 30); ellipse(mouseX, mouseY+15, 25, 30); // Cat Paws & Feet // Cat Paws if (millis()-pawTimer > 300) { ellipse(mouseX-10, mouseY, 10, 15); ellipse(mouseX+10, mouseY, 10, 15); } else { ellipse(mouseX-10, mouseY-12, 10, 15); ellipse(mouseX+10, mouseY-12, 10, 15); } // Cat Feet ellipse(mouseX-12, mouseY+22, 11, 19); ellipse(mouseX+12, mouseY+22, 11, 19); // Cat Tail ellipse(mouseX, mouseY+40, 11, 30); // Cat Head triangle(mouseX-9, mouseY-10, mouseX-15, mouseY-25, mouseX-5, mouseY-20); triangle(mouseX+9, mouseY-10, mouseX+15, mouseY-25, mouseX+5, mouseY-20); ellipse(mouseX, mouseY-15, 20, 20); // Scoreboard textSize(29); fill(255, 255, 255); text("Score:", 12, 35); text(score, 100, 36); } // Every time the player clicks the mouse when the cat overlaps the laser a point will be awarded void mousePressed() { pawTimer = millis(); if (laserX > (mouseX-catWidth/2) && laserX < (mouseX+catWidth/2) && laserY > (mouseY-catHeight/2) && laserY < (mouseY+catHeight/2)) { score++; interval = constrain(interval - 100, 500, 2000); println("score is " + score); // Attempt at debugging // println("laserX is " + laserX); // println("mouseX is " + (mouseX-catWidth/2)); // Attempt at determining the area the cat had to overlap with the laser for a point to be awarded //ellipse(mouseX-catWidth/2, mouseY-catHeight/2, 5, 5); //ellipse(mouseX+catWidth/2, mouseY+catHeight/2, 5, 5); } }