xxxxxxxxxx
var imageW = 200;
var imageH = 200;
//arrays of objects
var characters = [];
var waldo;
//// I spy Devils and Cats Game
function preload() {
characters[0] = {
img: loadImage("Spy C 1.png"),
feature: "the Cat with three round teeth"
};
characters[1] = {
img: loadImage("Spy C 2.png"),
feature: "the Cat with the circle nose"
};
characters[2] = {
img: loadImage("Spy C 3.png"),
feature: "the Cat with the rectangle nose"
};
characters[3] = {
img: loadImage("Spy C 4.png"),
feature: "the Cat missing a left tooth"
};
characters[4] = {
img: loadImage("Spy C 5.png"),
feature: "the Cat missing a right tooth"
};
characters[5] = {
img: loadImage("Spy C 6.png"),
feature: "the Cat missing a middle tooth"
};
characters[6] = {
img: loadImage("Spy C 8.png"),
feature: "the Cat with a pointy left tooth"
};
characters[7] = {
img: loadImage("Spy C 9.png"),
feature: "the Cat with a pointy right tooth"
};
characters[8] = {
img: loadImage("Spy C 7.png"),
feature: "the Cat with a pointy middle tooth"
};
characters[9] = {
img: loadImage("Spy C 10.png"),
feature: "the Cat with two pointy teeth"
};
characters[10] = {
img: loadImage("Spy C 11.png"),
feature: "the Cat with all three pointy teeth"
};
characters[11] = {
img: loadImage("Spy D 1.png"),
feature: "the Devil with three round teeth"
};
characters[12] = {
img: loadImage("Spy D 2.png"),
feature: "the Devil with the circle nose"
};
characters[13] = {
img: loadImage("Spy D 3.png"),
feature: "the Devil with the rectangle nose"
};
characters[14] = {
img: loadImage("Spy D 4.png"),
feature: "the Devil missing a left tooth"
};
characters[15] = {
img: loadImage("Spy D 5.png"),
feature: "the Devil missing a right tooth"
};
characters[16] = {
img: loadImage("Spy D 6.png"),
feature: "the Devil missing a middle tooth"
};
characters[17] = {
img: loadImage("Spy D 7.png"),
feature: "the Devil with a pointy middle tooth"
};
characters[18] = {
img: loadImage("Spy D 8.png"),
feature: "the Devil with a pointy left tooth"
};
characters[19] = {
img: loadImage("Spy D 9.png"),
feature: "the Devil with a pointy right tooth"
};
characters[20] = {
img: loadImage("Spy D 10.png"),
feature: "the Devil with two pointy teeth"
};
characters[21] = {
img: loadImage("Spy D 11.png"),
feature: "the Devil with all three pointy teeth"
};
/*
characters[1] = loadImage("Spy C 2.png");
characters[2] = loadImage("Spy C 3.png");
characters[3] = loadImage("Spy C 4.png");
characters[4] = loadImage("Spy C 5.png");
characters[5] = loadImage("Spy C 6.png");
characters[6] = loadImage("Spy C 7.png");
characters[7] = loadImage("Spy C 8.png");
characters[8] = loadImage("Spy C 9.png");
characters[9] = loadImage("Spy C 10.png");
characters[10] = loadImage("Spy C 11.png");
characters[11] = loadImage("Spy D 1.png");
images[12] = loadImage("Spy D 2.png");
images[13] = loadImage("Spy D 3.png");
images[14] = loadImage("Spy D 4.png");
images[15] = loadImage("Spy D 5.png");
images[16] = loadImage("Spy D 6.png");
images[17] = loadImage("Spy D 7.png");
images[18] = loadImage("Spy D 8.png");
images[19] = loadImage("Spy D 9.png");
images[20] = loadImage("Spy D 10.png");
images[21] = loadImage("Spy D 11.png");
*/
} //end preload
function setup() {
createCanvas(800, 800);
imageMode(CENTER);
//randomize
randomize();
}
function randomize() {
background(83, 224, 224);
for (var i = 0; i < characters.length; i++) {
characters[i].x = random(0, width);
characters[i].y = random(0, height);
}
waldo = random(characters);
//draw characters
for (var i = 0; i < characters.length; i++) {
var c = characters[i];
image(c.img,c.x,c.y,140, 230);
}
//sentence
var sentence = "Spy " + waldo.feature;
fill(255, 255, 255);
textSize(35);
textAlign(CENTER);
text(sentence, 400, 50);
redraw();
}
function mousePressed() {
//if the mouse position on the target
if (mouseX > waldo.x - imageW / 2 && mouseX < waldo.x + imageW / 2 && mouseY > waldo.y - imageH / 2 && mouseY < waldo.y + imageH / 2) {
print("CORRECT!!!");
randomize();
} else {
print("WRONG! WRONG! WRONG!");
}
}