I have a box which will speed up its rotation depending on which arrow key you press. The longer you hold it, the faster it will go, and when you let go, it gradually slows down.
When I have it spin to the left or down, it works fine. When I have it spin to the right or up, it will speed up, slow down, but never completely stop. This only happens if I hold the key down for a while, if I just tap it or hold it for a second, it works as I intended it to.
When it does keep spinning to the right, it fixes itself if I have it spin to the left for an equal or greater length of time as I had it spin to right.
Does all that make sense? If it does, take a look at my code please.
these declarations are global:
GLfloat rcubeX = 0.0f;
GLfloat rcubeY = 0.0f;
GLfloat Xspeed = 0.0f;
GLfloat Yspeed = 0.0f;
GLfloat slower = 0.05f;
GLfloat faster = 0.1f;
here’s what I have for my left and right rotations, the up and down rotations are the same.
if(Yspeed >= 0.0f)
if(Yspeed <= 0.0f)
here’s what draws and rotates the cube.
glTranslatef(0.0f, 0.0f, -6.0f);
glRotatef(rcubeX, 1.0f, 0.0f, 0.0f);
glRotatef(rcubeY, 0.0f, 1.0f, 0.0f);
[This message has been edited by skorman00 (edited 06-07-2003).]