• Advertisement
Sign in to follow this  

Object Velocity

This topic is 4247 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

CAn someone tell me if this equation looks right. Im moving a ball on an x any y axis like this. Ball.x += cosf(BallAngle * PI / 180) * Ball.xv / 60; Is there anything fishy about this?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Bluseed
CAn someone tell me if this equation looks right.
Im moving a ball on an x any y axis like this.

Ball.x += cosf(BallAngle * PI / 180) * Ball.xv / 60;

Is there anything fishy about this?
It should probably look more like this:
Ball.x += cos(BallAngle * PI / 180.0f) * Ball.speed * timeStep;
Ball.y += sin(BallAngle * PI / 180.0f) * Ball.speed * timeStep;
There are other improvements that could be made as well, such as using vector rather than per-component notation.

Share this post


Link to post
Share on other sites
Vector instead of pre-component notation? Can you explain a little more?

Share this post


Link to post
Share on other sites
Quote:
Original post by Bluseed
Vector instead of pre-component notation? Can you explain a little more?
It's generally easier to work with geometric vectors as a class or struct of which the vector components are member variables, rather than individual variables as you're doing. Check out the articles section here for some introductory articles on vector and matrix math (you should be able to find some example code as well).

Share this post


Link to post
Share on other sites
Damn That is beautiful i never seen that section of GDNET, i feel like an asshole!! lol thx i think thats the best help ever..

Share this post


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

  • Advertisement