1
resposta

Pontos negativos sem movimentar ator

Fiz o primeiro teste de apenas incuir no código :

if (colisao){ voltaAtorPosicaoInicial (); meusPontos -= 1;

e meus pontos são retirados sem nem movimentar o ator, fica logo -23 e assim vai... ` //Ator let yAtor = 366; let xAtor = 100; let meusPontos =0;

let colisao = false;

function mostraAtor(){ image (imagemDoAtor,xAtor,yAtor,30,30); }

function movimentaAtor(){ if (keyIsDown (UP_ARROW)){ yAtor -= 3; } if (keyIsDown (DOWN_ARROW)){ yAtor += 3; } }

function verificarColisão (){ //collideRectCircle(x1, y1, width1, height1, cx, cy, diameter)

for (let i = 0; i < imagemCarros.length; i = i+1){ colisao = collideRectCircle (xCarros [i], yCarros [i], comprimentoCarro, alturaCarro, xAtor, yAtor,15 )

if (colisao){
  voltaAtorPosicaoInicial ();
  meusPontos -= 1;

}

} }

function voltaAtorPosicaoInicial (){ yAtor = 366; }

function incluiPonto(){ textAlign (CENTER); textSize (25); fill (color(255, 240, 60)); text(meusPontos, width / 5, 27); }

function marcaPonto (){ if (yAtor < 15){ meusPontos += 1 voltaAtorPosicaoInicial(); } }

1 resposta

Olá Daniella! Tudo bem? Coloca o link de seu projeto para que puder ajudar, poder ver!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software