Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
Failed Collision detection function

I have made a game using p5.js. The player is the white square and the walls are blue. I have made a collison detection function, but it is pretty spotty. Sometimes, it works fine, but other times there is a slight distance between the player and the wall. Can you please tell me what is going wrong? Any help would be greatly appreciated! Code is below:

function collide(a, b, dx, dy){
  var newx = a.x + dx * playerSpeed;
  var newy = a.y + dy * playerSpeed;
  if (newx < b.x + b.size && newx + a.size > b.x && newy < b.y + b.size && newy + a.size > b.y){
    return true;
  }
  return false;
}

For full code go to https://replit.com/@TonyWu4/Project

If you want examples on what is happening, Links to screenshots are below.

Working Fine

Not working

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda