So I have very beginner knowledge with code, and am trying to make a ‘forest’ scene where the user can click on 5 little blobs of slime mould, and once they click on them they disappear.
Right now the 5 blobs of slime mould are there, but nothing is happening when they are clicked.
I copied a lot of this code from someone else but didn’t get to see all their code so don’t know what I’m missing.
I have no idea what to do from here, but this is my code:
Any help is appreciated
var slimeMould1x = 210;
var slimeMould1y = 550;
var slimeMould2x = 400;
var slimeMould2y = 540;
var slimeMould3x = 650;
var slimeMould3y = 560;
var slimeMould4x = 930;
var slimeMould4y = 580;
var slimeMould5x = 1100;
var slimeMould5y = 565;
var slimeMouldx = [210, 400, 650, 930, 1100];
var slimeMouldy = [550, 540, 560, 580, 565];
var slimeMouldClicked = [slimeMould1Clicked, slimeMould2Clicked,
slimeMould3Clicked, slimeMould4Clicked, slimeMould5Clicked];
var slimeMould = [slimeMould1, slimeMould2, slimeMould3, slimeMould4,
slimeMould5];
var forest;
function preload () {
slimeMould1 = loadImage("assets/slimemould-01.png");
slimeMould2 = loadImage("assets/slimemould-01.png");
slimeMould3 = loadImage("assets/slimemould-01.png");
slimeMould4 = loadImage("assets/slimemould-01.png");
slimeMould5 = loadImage("assets/slimemould-01.png");
forest = loadImage("assets/forest-03.png");
}
function setup() {
createCanvas(1200, 800);
imageMode(CENTER);
}
function draw() {
background(10);
image(forest,width/2,height/2);
fill(255);
noStroke();
textAlign(CENTER, CENTER);
textSize(25);
text("collect all the slime mould!", width/2, height*0.97);
image(slimeMould1,slimeMould1x,slimeMould1y);
image(slimeMould2,slimeMould2x,slimeMould2y);
image(slimeMould3,slimeMould3x,slimeMould3y);
image(slimeMould4,slimeMould4x,slimeMould4y);
image(slimeMould5,slimeMould5x,slimeMould5y);
slimeMould1Click();
slimeMould2Click();
slimeMould3Click();
slimeMould4Click();
slimeMould5Click();
var noslimeMould = true;
for (i = 0; i < slimeMould.length; i++){
if (slimeMouldClicked[i] == false) {
image(slimeMould[i], slimeMouldx[i], slimeMouldy[i]);
noslimeMould = false;
}
}
}
function slimeMould1Click() {
if (slimeMouldClicked[0] == false) {
if ((mouseX > slimeMould1x) && (mouseX < (slimeMould1x+ 50)) &&
(mouseY > slimeMould1y) && (mouseY < (slimeMould1y+ 50))) {
slimeMouldClicked[0] = true;
}
}
}
function slimeMould2Click() {
if (slimeMouldClicked[1] == false) {
if ((mouseX > slimeMould2x) && (mouseX < (slimeMould2x+ 50)) &&
(mouseY > slimeMould2y) && (mouseY < (slimeMould2y+ 50))) {
slimeMouldClicked[1] = true;
}
}
}
function slimeMould3Click() {
if (slimeMouldClicked[2] == false) {
if ((mouseX > slimeMould3x) && (mouseX < (slimeMould3x+ 50)) &&
(mouseY > slimeMould3y) && (mouseY < (slimeMould3y+ 50))) {
slimeMouldClicked[2] = true;
}
}
}
function slimeMould4Click() {
if (slimeMouldClicked[3] == false) {
if ((mouseX > slimeMould4x) && (mouseX < (slimeMould4x+ 50)) &&
(mouseY > slimeMould4y) && (mouseY < (slimeMould4y+ 50))) {
slimeMouldClicked[3] = true;
}
}
}
function slimeMould5Click() {
if (slimeMouldClicked[4] == false) {
if ((mouseX > slimeMould5x) && (mouseX < (slimeMould5x+ 50)) &&
(mouseY > slimeMould5y) && (mouseY < (slimeMould5y+ 50))) {
slimeMouldClicked[4] = true;
}
}
}