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

138
Views
how can i make a svg ball roll to the cursor

hi I am trying to make a game like online bowling and I can not get the ball to lunch correctly in js. when I click on it the ball goes the wrong way or off the screen

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>

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