Skip to main content
gamedev.net
🔒 Locked

Object Velocity

Started by Bluseed Jul 3, 2006 at 3:46 PM 3 replies 1.1k views
Original Post
Bluseed
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?
Zakwayda
Zakwayda
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.
Bluseed
Bluseed
Vector instead of pre-component notation? Can you explain a little more?
Zakwayda
Zakwayda
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).
Bluseed
Bluseed
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..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.