xxxxxxxxxx
48
//var ator
let xAtor = 60;
let yAtor = 366;
let velAtor= 5;
let colisao = false;
let meusPontos = 0;
function mostraAtor(){
image(imgAtor, xAtor, yAtor, 30, 30);
}
function movAtor(){
if (keyIsDown(UP_ARROW) && yAtor > 6 ){
yAtor = yAtor -= velAtor;
}
if (keyIsDown(DOWN_ARROW) && yAtor < 366){
yAtor = yAtor += velAtor;
}
}
function verColisao (){
for(let i = 0; i < imgCars. length; i ++ )
{ colisao = p5.prototype.collideRectCircle(xCar[i], yCar[i], lCar, aCar, xAtor, yAtor, 10)
if (colisao){
retornaAtor();
somColisao.play();
if(meusPontos > 0){
meusPontos -= 1
}
}
}
}
function incluiPontos(){
textAlign(CENTER);
fill (51, 204, 255);
rect(105, 4 ,38, 28)
fill (204, 0, 0);
textSize(25);
text(meusPontos, width / 4, 25);
}
function marcaPontos(){
if (yAtor < 10){
meusPontos += 1;
somPontos.play();
retornaAtor();
}
}
function retornaAtor(){
yAtor = 366
}