xxxxxxxxxx
function preload() {
for (let i = 0; i < 10; i++)
let smily = createSprite(100, 100, 200, 200);
let smilyAnimation = smily.addAnimation('smily', 'smily0.png');
smily.changeAnimation('smily');
smily.position.x = random(windowWidth);
smily.position.y = random(windowHeight);
smilies.push(smily);
}
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(255);
// Delete smily from list when mouse pressed
if (mouseIsPressed)
}
if (smilies.length > 0)
{
smilies[0].remove(); // Removes from list of sprites to draw
smilies.splice(0,1); // Removes from array of smily sprites
}
}
drawSprites();
}
function draw() {
background(255);
// Delete smily from list when mouse pressed
if (mouseIsPressed)
{
for (let i = smilies.length -1; i >=0; i--) {
if (dist(mouseX,mouseY,smilies[i].position.x,smilies[i].position.y)<75)
{
smilies[i].remove();
smilies.splice(i,1);
}
}
}
drawSprites();
}
function draw() {
background(100);
moveSmily();
// This version makes the rectangle immovable
rectangle.immovable = true;
// This says if the smily initiates movement
// into the rectangle then don't allow it
// to push or go into the rectangle
smily.collide(rectangle);
drawSprites();
}