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

170
Vistas
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
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