Hey everyone,
I''m having a problem with moving an object across the screen independent of frame rate. what I''m doing is taking the speed of the object and dividing by frames per second to get the pixels moved per frame. Then I multiply by the cos/sin of the angle of the line to get the pixels moved relative to the angle of the line.
Something like this:
float dX, dY;
int LineAngle = 30; // Degrees
dX = (float)Speed / (float)fps * cos(LineAngle * PI/180);
dY = (float)Speed / (float)fps * sin(LineAngle * PI/180);
|
The problem comes in when I do this every frame:
// the variables x and y are current positions
x += dX;
y += dY;
|
When I check the values of these numbers after even 1 frame I get a value of 1.#INF, which is NOT a good thing.
Also, x and y were set to the beginning of the line at the beginning of the program and dX and dY calculate properly, because their values, when displayed, are correct.
Can anyone help solve this crazy problem?
-Hyren
"Back to the code mines... ka-chink... ka-chink..."
vidgamez.iwarp.com