Fala, pessoal!
Concluí com sucesso esse projeto do Freeway, foi muito divertido.
Aqui está o meu código no ator.js. Fiz algumas modicações para que o ator se movimentasse nas horizontais através das setas para esquerda e para a direita. Eu criei duas novas funções: podeSeMoverEsquerda() e podeSeMoverEsquerda() com os valores return diferentes.
Alguém tem alguma sugestão? Seria possível refatorar esse código ainda mais?
// variaveis do ator
let yAtor = 365;
let xAtor = 30;
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;
  }
  }
 if (keyIsDown(LEFT_ARROW)){
   if (podeSeMoverEsquerda()){
   xAtor -=3;
   } 
   }
 if (keyIsDown(RIGHT_ARROW)){
   if (podeSeMoverDireita()){
   xAtor +=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], comprimentoCarros, alturaCarros, xAtor, yAtor, 15)
    if (colisao){
      voltaAtorPosicaoInicial();
      somDaColisao.play();
    if (pontosMaiorQueZero()){
      meusPontos -= 1;
    }
    }
  }
}
function voltaAtorPosicaoInicial(){
  xAtor = 30;
  yAtor = 365;
}
function mostraPontos(){
  textAlign(CENTER);
  textSize(25);
  fill(color(140,0,211));
  text("Pontos", width / 5, 27);
  textAlign(CENTER);
  textSize(25);
  textStyle(BOLD);
  fill(color(140,0,211));
  text(meusPontos, 400, 27);
}
function marcaPonto(){
  if (yAtor < 15){
    meusPontos += 1;
  voltaAtorPosicaoInicial();
    somDoPonto.play();
  }
  }
function pontosMaiorQueZero(){
  return meusPontos > 0;
}
function podeSeMover(){
  return yAtor < 366;
}
function podeSeMoverEsquerda(){
  return xAtor > 5; 
  ;}
function podeSeMoverDireita(){
  return xAtor < 466;
};