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

164
Views
How to detect if an image is touching an element in a Javascript game

I'm building an arcade game with plain javascript. I built bricks using images and not with canvas, I want to build a function that stops the character from moving also I want him to be able to jump over the objects, and if the character is on top of one of the bricks I want him to not dropdown.

I built an interval that checks that character top && left and also the bricks' left (still haven't built the top )

also each time I placed a brick in the level I also inserted them in an array that I could refer to them in a loop later.

**here's the code: **

if (
  characterLeft >= 1000 ||
  (characterLeft >= BrickLeftArray[b] - 160 &&
    characterLeft <= BrickLeftArray[b] + 80)
) {
  /*|| characterLeft == BrickLeftArray[b] - 100)*/
  clearInterval(IntervalMoveRight);
  flagfortherunning = false;
}

notes** clear interval move right clears the interval of the character from moving. flagfortheruning is a flag that if it's true the moving function is on.

if there's a need to load more code please say.

about 4 years ago · Juan Pablo Isaza
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!