Jump to content
  • Advertisement
Sign in to follow this  
DesignerX

Mouse movement to object speed

This topic is 4071 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing an Air Hockey game. I get my mouse movement input using DirectInput. How can one translate mouse movement to object speed ? As you guessed it, the mouse controls the player's mallet. Should I invlove a timer for this issue ? thx.

Share this post


Link to post
Share on other sites
Advertisement
hey, try using the last mouse position and the current pos and make a vector and use its length to base your speed to.

Share this post


Link to post
Share on other sites
thats is my first dillema , should the vector length will be the speed or should I use a timer to calculate the time delta between the positions and get the speed from the known formula : v = s / dt.

The thing is that trying the second approach produces very large speed values which aren't seems to fit. The first approach its much better but I don't know if it is accurate.

If someone knows or did it before plz let me know what is the best way .

thx.

Share this post


Link to post
Share on other sites
try having 4 predefined speed ranges or more and split the mag in to that many
ranges and the you can control it a bit unless its a true sim is it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!