https://editor.p5js.org/dralvphd2/sketches/7Ndj4fes7
Código do ator
//ator
let xAtor = 100;
let yAtor = 367;
let wAtor = 30;
let hAtor = 30;
let colisao = false;
let pontos = 0;
function mostraAtor(){
image(imagemAtor,xAtor,yAtor,wAtor,hAtor);
}
function movimentoAtor(){
if(keyIsDown(UP_ARROW)){
yAtor -= 3
}
if(keyIsDown(DOWN_ARROW)){
yAtor += 3
}
if(keyIsDown(RIGHT_ARROW)){
xAtor += 3
}
if(keyIsDown(LEFT_ARROW)){
tor -= 3
}
}
function verificaColisao(){
for( let i=0; imagemCarros.length; i++){
colisao = collideRectCircle(xCarros[i], yCarros[i], wCarro, hCarro, xAtor, yAtor, 15)
}
if(colisao){
voltaInicio();
}
}
function voltaInicio(){
yAtor = 367;
}
function meusPontos(){
textAlign(CENTER);
textSize(25);
fill(color(0,0,139));
text(pontos,width/5,27);
}
function marcaPontos(){
pontos+=1;
voltaInicio();
}