Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

135
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda