xxxxxxxxxx
39
let BG;
let tree;
let stump;
let chainsaw;
let xPos = [];
let yPos = [];
let spacing = 100;
function setup() {
createCanvas(500, 500);
BG = loadImage("Assets/grassBG_500.png");
tree = loadImage("Assets/pine_tree_75.png");
stump = loadImage("Assets/stump_75.png");
chainsaw = loadImage("Assets/chainsaw_75.png");
// load positions into our array
for(let x = 0; x < width; x+=spacing){
for( let y = 0; y < height; y+=spacing){
append(xPos,x);
append(yPos,y);
}
}
}
function draw() {
image(BG,0,0);
for( let i =0; i < xPos.length; i++){
if(dist(mouseX,mouseY,xPos[i],yPos[i]) <100){
image(stump,xPos[i],yPos[i]);
}else{
image(tree,xPos[i],yPos[i]);
}
}
image(chainsaw,mouseX,mouseY);
}