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

127
Visualizações
compare pixel postition via code on javacript

i have a problem. i'm using javascript and i'm always trying to make a faster code.

so i create an app that check the pixel position.

if your pixel pointer(red) is in the target position, the target make an action.. just press (t) to see it down

But when cross the red tile on loop to create a lot of places akk "if" dont work.

I wish he alert everytime the red takes the blue.

have any trigger to make check colision to the first object to another??

how to make a lot of if to be checked automated?

<body>
    
</body>
<script>


//ok... trying again

document.addEventListener('keydown', function(e) {
  if (e.keyCode == 84) {
    e.preventDefault();
    check();
  }
})

var position = 0

let a = document.createElement("div")

    a.style.backgroundColor = "red"       
    a.style.height          = '1px'
    a.style.width           = '1px'
    a.style.top             = position
    a.style.position        = "absolute" 

    document.body.append(a)

for (let index = 0; index < 10; index++) {

let x = index

//b = new b all the time

  let b = document.createElement("div")
      b.style.backgroundColor = "blue"  
      b.style.height          = '1px'
      b.style.width           = '1px'
      b.style.position        = "absolute"      
      b.style.top = Math.floor(Math.random(10 - 0) * 100)

      document.body.append(b)
//remember b = nem b on let all the time

function check(){

    a.style.top = position++
if (a.style.top === b.style.top ){
    alert("its ok")
}
}

}

</script>

help

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