xxxxxxxxxx
60
//Ator
let yAtor = 366;
let xAtor = 85;
let Colisao = false;
let meusPontos = 0;
function mostraAtor(){
image(imagemDoAtor,xAtor, yAtor, 30, 30)
}
function movimentaAtor(){
// para baixo
if (keyIsDown(DOWN_ARROW)){
if (podeSeMover())
yAtor += 3
}
// para cima
if (keyIsDown(UP_ARROW)){
yAtor -= 3
}
}
function verificaColisao(){
for (let i = 0; i < imagemCarros.length; i++ ){
colisao = collideRectCircle(xCarros[i], yCarros[i], comprimentoCarro, alturaCarro, xAtor, yAtor, 15)
if (colisao){
colidiu();
if (pontosMaiorQueZero()){
meusPontos -= 1;
}
}
}
}
function colidiu(){
yAtor = 366;
somDaColisao.play();
}
function incluiPontos(){
textAlign(CENTER);
textSize(25);
fill(color(255,240,0))
text(meusPontos, width / 5, 28);
}
function marcaPonto(){
if (yAtor < 15){
meusPontos += 1;
colidiu();
somDoPonto.play();
}
}
function pontosMaiorQueZero(){
return meusPontos > 0
}
function podeSeMover(){
return yAtor < 366;
}