xxxxxxxxxx
82
let bloodSpots = [];
let handX, handY;
let washCount = 0;
let messages = [
"Out, damned spot! Out, I say!",
"Yet here's a spot.",
"Who would have thought the old man to have had so much blood in him?",
"All the perfumes of Arabia will not sweeten this little hand."
];
let currentMessage = 0;
function setup() {
createCanvas(600, 400);
for (let i = 0; i < 5; i++) {
bloodSpots.push(createVector(random(width), random(height)));
}
handX = width / 2;
handY = height / 2;
}
function draw() {
background(50); // Dark background
// Draw blood spots
fill(150, 0, 0);
noStroke();
for (let spot of bloodSpots) {
ellipse(spot.x, spot.y, 20, 20);
}
// Draw hand
fill(255, 200, 150);
ellipse(handX, handY, 40, 40);
// Display message
fill(255);
textAlign(CENTER, TOP);
textSize(18);
text(messages[currentMessage], width/2, 20);
// Display wash count
textAlign(LEFT, BOTTOM);
text(`Washes: ${washCount}`, 20, height - 20);
}
function mouseMoved() {
handX = mouseX;
handY = mouseY;
}
function mousePressed() {
washCount++;
// Check if hand is over a blood spot
for (let i = bloodSpots.length - 1; i >= 0; i--) {
let d = dist(handX, handY, bloodSpots[i].x, bloodSpots[i].y);
if (d < 30) {
bloodSpots.splice(i, 1); // Remove the spot
// Add a new spot elsewhere
bloodSpots.push(createVector(random(width), random(height)));
// Change the message
currentMessage = (currentMessage + 1) % messages.length;
break;
}
}
// Add more spots as the player washes more
if (washCount % 10 === 0) {
bloodSpots.push(createVector(random(width), random(height)));
}
}
function keyPressed() {
if (key === ' ') {
// Space key to move to next scene
console.log("Moving to next scene");
// Add your scene transition code here
}
}