xxxxxxxxxx
71
let yAtor = 366;
let xAtor = 100;
let colisao = false;
let meusPontos = 0;
let pontosNegativos = 0;
function mostraAtor() {
image(imagemDoAtor, xAtor, yAtor, 30, 30);
}
function movimentaAtor() {
if (keyIsDown(UP_ARROW)) {
yAtor -= 3;
}
if (keyIsDown(DOWN_ARROW)) {
if(podeSeMover()){
yAtor += 3;
}
}
}
function verificaColisao() {
for (nCont = 0; nCont < imagemCarros.length; nCont++) {
colisao = collideRectCircle(
xCarro[nCont],
yCarro[nCont],
50,
40,
xAtor,
yAtor,
15
);
if (colisao)
{voltarParaOInicio() ;
somDaColisao.play();
if (sePontosMaiorQueZero())
{
meusPontos -=1
}
}
}
}
function sePontosMaiorQueZero(){
return meusPontos > 0
}
function voltarParaOInicio() {
yAtor = 366;
}
function incluiPontos() {
textAlign(CENTER);
text(meusPontos, width / 5, 27);
textSize(25);
fill(255, 255, 0);
}
function contabilizarPontos() {
if (yAtor < 15) {
meusPontos += 1;
somDoPonto.play();
voltarParaOInicio() ;
}
}
function podeSeMover(){
return yAtor < 366;
}