xxxxxxxxxx
var eyes = [];
var silhouette = [];
var currentEyeIndex = 0;
var currentSilhouetteIndex = 0;
var eyeWidth = 100; // Adjust the width as needed
var eyeHeight = 50; // Adjust the height as needed
var changeTimer = 0;
var changeInterval = 20;
function setup() {
createCanvas(windowWidth, windowHeight);
imageMode(CENTER);
noLoop();
}
function preload() {
eyes.push(loadImage("akys.png"));
eyes.push(loadImage("akys1.png"));
eyes.push(loadImage("akys2.png"));
eyes.push(loadImage("akys3.png"));
eyes.push(loadImage("akys4.png"));
eyes.push(loadImage("akys5.png"));``
eyes.push(loadImage("akys6.png"));
silhouette.push(loadImage("siluetas.png"));
silhouette.push(loadImage("siluetas2.png"));
silhouette.push(loadImage("siluetas3.png"));
}
function draw() {
background(777);
// Draw the silhouette image
image(silhouette[currentSilhouetteIndex], width / 2, height / 2);
// Draw the eyes image with hardcoded size
image(eyes[currentEyeIndex], width / 2, height / 2 - 300, eyeWidth, eyeHeight);
}
function mouseMoved() {
// Check if the mouse is within the silhouette area
var silhouetteAreaX = width / 2 - silhouette[currentSilhouetteIndex].width / 2;
var silhouetteAreaY = height / 2 - silhouette[currentSilhouetteIndex].height / 2;
var silhouetteAreaWidth = silhouette[currentSilhouetteIndex].width;
var silhouetteAreaHeight = silhouette[currentSilhouetteIndex].height;
if (mouseX > silhouetteAreaX && mouseX < silhouetteAreaX + silhouetteAreaWidth && mouseY > silhouetteAreaY && mouseY < silhouetteAreaY + silhouetteAreaHeight) {
// Increment changeTimer
changeTimer++;
// Check if changeTimer exceeds changeInterval
if (changeTimer >= changeInterval) {
// Change the silhouette image
var newSilhouetteIndex = currentSilhouetteIndex;
while (newSilhouetteIndex === currentSilhouetteIndex) {
newSilhouetteIndex = floor(random(silhouette.length));
}
currentSilhouetteIndex = newSilhouetteIndex;
// Change the eyes image
currentEyeIndex = floor(random(eyes.length));
// Reset changeTimer
changeTimer = 0;
redraw();
}
}
}