XNA2D negative to Positive values

Recommended Posts

ok this may have a rediculous ans that im missing :P but .... if i define a Varible as
GameBall.Velocity = (-GameBall.Velocity);

how would you reverse this? (e.g)
GameBall.Velocity = (+GameBall.Velocity); //i know this doesnt work but it Illustrates what im trying to do


Share on other sites
Take a look at Math.Abs()

Cheers,
Mark

Share on other sites
Or go back to simple algebra and multiply by -1.

Share on other sites
Nice thank you :) its also worked just doing the same thing

GameBall.Velocity = (-GameBall.Velocity); on an already -GameBall.Velocity just made it pos ofc :P

Create an account

Register a new account

• Forum Statistics

• Total Topics
628294
• Total Posts
2981882

• 9
• 9
• 11
• 10
• 10