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

166
Visualizações
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 à 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