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

119
Visualizações
how can i make a svg ball roll to the last click

I am trying to make a game like online bowling, and I cannot get the ball to launch correctly in js. when I click on it the ball goes the wrong way or off the screen. I have been trying to fix this for a while.

var xup
  var yup
  var x = 50;
  var y = 95
document.onmouseup = function(e){
  xup = -(e.pageX/screen.width)
  yup = -(e.pageY/screen.height)
  let d = setInterval(function(){
    x += xup
    y += yup
    document.getElementById("player").innerHTML = '<circle id="ball"  cx="'+x+'%" cy="'+y+'%" r="1%" fill="url(#ball)" />'
    if(y<=20){
      d=null
    }
  },10)
  }
<svg style='position: absolute;left: 0;top: 1%;' width='100%' height='100%'>
  <defs>

    <radialGradient id="ball" cx="50%" cy="25%" r="50%" fx="50%" fy="50%">
      <stop offset="0%" style="stop-color:#ff00ff;stop-opacity:1" />
      <stop offset="100%" style="stop-color:#800080;stop-opacity:1" />
    </radialGradient>
  </defs>

  <g id="player">
  <circle id="ball" cx="50%" cy="95%" r="1%" fill="url(#ball)" />
  </g>
  </svg>

about 4 years ago · Santiago Gelvez
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