Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!