xxxxxxxxxx
76
//ator
var xAtor = 250;
var yAtor = 360;
var colisao = false;
var meusPontos = 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 (var i = 0; i < imagemCarros.length; i++) {
colisao = collideRectCircle(xCarros[i], yCarros[i], comprimentoCarro, alturaCarro, xAtor, yAtor, 15)
if (colisao) {
voltaAtorParaPosicaoInicial();
somDaColisao.play();
if(pontosMaiorQueZero()) {
meusPontos -= 1;
}
}
}
}
function voltaAtorParaPosicaoInicial() {
yAtor = 360;
}
function incluiPontos() {
textAlign(CENTER);
textSize(25);
fill(color(255,165,0))
text(meusPontos, width / 5, 30);
}
function marcaPonto(){
if (yAtor < 15) {
meusPontos += 1;
voltaAtorParaPosicaoInicial();
somDoPonto.play();
}
}
function pontosMaiorQueZero() {
return meusPontos > 0;
}
function podeSeMover(){
return yAtor < 360;
}
function verificaColisaoVolta () {
for (var i = 0; i < imagemCarros.length; i++) {
colisao = collideRectCircle(xCarrosVolta[i], yCarrosVolta[i], comprimentoCarro, alturaCarro, xAtor, yAtor, 15)
if (colisao) {
voltaAtorParaPosicaoInicial();
somDaColisao.play();
if(pontosMaiorQueZero()) {
meusPontos -= 1;
}
}
}
}