xxxxxxxxxx
82
//código do ator
let xAtor = 85;
let yAtor = 366;
let colisao = false;
let 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(){
//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, 15)
if (colisao){
somDaColisao.play();
voltaAtorParaPosicaoInicial();
if(pontosMaiorQueZero()){
meusPontos -= 1;
}
}
}
}
function voltaAtorParaPosicaoInicial(){
yAtor = 366;
}
function incluiPontos(){
textAlign(CENTER);
textSize(25);
fill(color(255, 240, 60))
text(meusPontos, width / 5, 27);
}
function marcaPonto(){
if (yAtor < 15){
meusPontos += 1;
somDoPonto.play();
voltaAtorParaPosicaoInicial();
}
}
function marcaPonto(){
if (yAtor < 15){
meusPontos += 1;
voltaAtorParaPosicaoInicial();
}
}
function pontosMaiorQueZero(){
velocidade();
return meusPontos > 0;
}
function podeSeMover(){
return yAtor < 366;
}
function velocidade(){
if(meusPontos < 4){
velocidadeCarros = [1.2, 1.3, 1.6, 1, 1.1, 1.5];
}
if(meusPontos >= 4)
{
velocidadeCarros = [2, 2.5, 3.2, 5, 3.3, 2.3];
}
if(meusPontos > 5){
velocidadeCarros = [3.5, 3.9, 4.3, 5, 4.4, 4.9];
}
}