xxxxxxxxxx
45
var imgNaveA;
var imgNaveB;
var xNaveA = 150;
var yNaveA = 100;
var corFundo = 0;
var naveAVisivel = true;
function preload(){
imgNaveA = loadImage("ship_14.png")
imgNaveB = loadImage("ship_21.png")
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(corFundo);
imageMode(CENTER);
fill(250,0,0);
image(imgNaveA,xNaveA,yNaveA);
ellipse(xNaveA,yNaveA,10,10);
yNaveA = yNaveA + 5
if ( yNaveA > 400 ){
yNaveA = 0
}
image(imgNaveB,mouseX,mouseY);
ellipse(mouseX,mouseY,10,10);
imageMode(CORNER);
distancia = dist(xNaveA,yNaveA, mouseX,mouseY)
//console.log(distancia)
if (distancia< 80){
yNaveA = -200
xNaveA = random(0,360)
}
}