Well I've done my homework on this one,
so I hope I can find some help.
This program spins a line around a point in the centre of the screen,
like a clock hand moving around a clock face.
The program works,
but as I increment the angle from 0-360, the line makes a full circle many times, and only has about 5 or 6 frames per full circle rotation.
If I increment the angle by 0.01, the display looks great, and movement
is fluid, but it only takes 7 or 8 degrees to make a full circle.
Any ideas what I'm doing wrong?
all vars are ints except for theta & thetab.
Code: Select all
while (1) {
clearScreen(0);
xx = 240; // set the starting point.
yy = 30;
drawLineScreen(240, 136, xx, yy, white); // draw stationary line for reference
x = xx - 240; // coords X=240,Y=136 is a point in the middle of the screen to spin around
y = yy - 136;
theta = theta + 1; // increment the angle to 360 degrees.
if (theta > 359) {theta = 0;}
thetab = 360 - theta;
sprintf (filler, " %f", theta); // print the current angle
printTextScreen(0,0,filler, white);
xnew = cos(thetab)*x - sin(thetab)*y;
ynew = sin(thetab)*x + cos(thetab)*y;
xnew = xnew + 240; // if I leave this out, the line spins around 0,0 coords, and I only see a quater of the action
ynew = ynew + 136;
drawLineScreen(240, 136, xnew, ynew, white);
sceDisplayWaitVblankStart();
flipScreen();
for(del=0; del<10; del++) {sceDisplayWaitVblankStart();} // delay to see the current frame
}