xxxxxxxxxx
var octopus;
var mySound;
function preload() {
mySound = loadSound('SquidSisters.mp3');
octopus = loadAnimation("Octti0001.png", "Octti0041.png");
octopus = loadAnimation("Octti_spin0001.png", "Octti_spin0024.png");
octopus = loadAnimation("Octti_move0001.png", "Octti_move0024.png");
}
function setup() {
createCanvas(1200,800);
octopus = createSprite(400, 450, 200, 100);
var myAnimation = octopus.addAnimation("floating", "Octti0001.png", "Octti0041.png");
myAnimation.offY = 18;
octopus.addAnimation("spinning", "Octti_spin0001.png", "Octti_spin0024.png");
octopus.addAnimation("move", "Octti_move0001.png", "Octti_move0024.png");
}
function draw() {
background("Aqua");
if(mouseX < octopus.position.x - 10){
octopus.changeAnimation("move");
octopus.mirrorX(-1);
octopus.velocity.x = - 4;
}
else if(mouseX > octopus.position.x + 10) {
octopus.changeAnimation("move");
octopus.mirrorX(1);
octopus.velocity.x = 4;
}
else {
octopus.changeAnimation("floating");
octopus.velocity.x = 0;
}
if(mouseIsPressed) {
background(random(255), random(255), random(255));
ellipseMode(CENTER);
var c = color('white');
fill(c);
noStroke();
ellipse(random(800), random(1000), random(700));
frameRate= (20);
octopus.rotation -= 10;
octopus.changeAnimation("spinning");
if (mySound.isPlaying() == false) {
mySound.play();
}
else {
octopus.rotation = 0;
if(keyIsDown(UP_ARROW))
octopus.scale += 0.05;
if(keyIsDown(DOWN_ARROW))
octopus.scale -= 0.05;
}
}
else {
if (mySound.isPlaying() == true) {
mySound.pause();
}
}
drawSprites();
}