xxxxxxxxxx
53
//Joey Avalos.
//1.create p5.js play.
//2.create gravity and sprites.
//3.add images to files.
//4.create texts to show on screen.
//5.tap screen to see images pop out.
// I've created my p5.js project similar to the accessing and deleting project in the p5.js play.
let GRAVITY = 0.2;
let newSprite;
function setup() {
createCanvas(windowWidth,windowHeight);
}
function draw() {
background(0,0,0);
fill(0);
textAlign(CENTER);
stroke('#f01c05');
// scale(0.5);
text('CLICK TO VIEW SPRITES ON SCREEN', width/2, height-20);
for( i=0; i<allSprites.length; i++)
{
var mySprite = allSprites[i];
mySprite.addSpeed(GRAVITY, 90);
if(mySprite.position.y > height + 100)
mySprite.remove();
}
if(frameCount%10 == 0)
print('Sprite in the scene: ' +allSprites.length);
drawSprites();
}
function mousePressed() {
newSprite = createSprite(mouseX, mouseY);
newSprite.addAnimation('normal','playboy.png', 'nintendo.png', 'pokeball.png', 'SSB.png', 'lucas.png', 'ness.png');
newSprite.animation.stop();
var f = round(random(0, newSprite.animation.getLastFrame()));
newSprite.animation.changeFrame(f);
}