xxxxxxxxxx
66
//Código do ator
let xAtor = 50;
let yAtor = 370;
let colosao = false;
let meusPontos = 0;
function mostraAtor(){
image(imagemAtor, xAtor, yAtor, 25, 25);
}
function movimentaAtor(){
if (keyIsDown (UP_ARROW)){
yAtor -= 1
}
if (keyIsDown (DOWN_ARROW)){
if(podeSeMover()){
yAtor += 1
}
}
}
function podeSeMover(){
return yAtor < 366;
}
function verificaColisao(){
// collideRectCircle(x1, y1, width1, height1, cx, cy, diameter)
for (let i = 0; i < imagemCarros.length; i++){
colisao = collideRectCircle (xCarros[i], yCarros[i], comprimentoCarro, alturaCarro, xAtor, yAtor, 25)
if (colisao){
voltaAtorParaPosicaoInicial();
somDaColisao.play();
if(pontosMaiorQueZero()){
meusPontos -= 1;
}
}
}
}
function pontosMaiorQueZero(){
return meusPontos > 0
}
function voltaAtorParaPosicaoInicial(){
yAtor = 370;
}
function incluiPontos (){
textAlign (CENTER);
textSize (25);
fill (255,105,180);
text (meusPontos, width / 5, 27 );
}
function marcaPonto(){
if(yAtor < 10){
meusPontos += 1;
somDoPonto.play();
voltaAtorParaPosicaoInicial()
}
}