Change your rotation values themselves. Instead of rotating in 90-degree increments, make it say: 10, 15 or even 20 degree increments.
Also, I would attach some sort of timer mechanism to the call. As it is right now, an UP-KEY instantly places the sprite at 0-degrees (facing UP?). The Right key makes it facing right...
Here's a summary (with source) of my approach:
Here's my LoopGDK:
while (LoopGDK())
{
...
elapsed = ElapsedTime();
...
// MyRotateObject will rotate 1-full 360-degree rotation every 6-seconds
// of *real* time - regardless of frame-rate...
MyRotateObject->Update(elapsed);
...
dbSync();
}
Here's my RotatingObject's Update() method:
void CRotatingPoint::Update( int elapsed_time )
{
/*
Rotating points by default expect to perform a full 360-degree rotation
within a 6-second interval (this makes for quick and easy calculations
where 1-second = 60-degrees of rotation - regardless of frame-rate)...
As such, we will check the length of time since the last call to
Update() and see just how much we need to rotate ourselves in order to
keep pace of one-full 360-degree cycle within a 6-second period...
Assuming a frame-rate of 60-fps, this will require a rotation of 1-degree
per frame; however, as the frame-rate may vary from time to time, we will
need to adjust our rotation accordingly. As such, some frames may be the
precise 1-degree that we hope for; others will be less than the 1-degree
optimal change and still others will be more than the 1-degree difference
in change...
As an average, however, we expect the object to rotate 360-degrees every
6-seconds of game-time...
*/
if (m_LastUpdate == 0)
{
/* First call! No rotation required... */
m_LastUpdate = elapsed_time;
return;
}
/*
To save some CPU-Cycles, we know the formula will never change so we are using
a constant value multiplier. This value can be acquired by the following
mathematical formula:
(1/6000) * 360 = 0.06 -> (1-rotation every 6-seconds) * 360-degrees per rotation
= rotation adjustment per m/s of time.
And, since elapsed_time is passed in as a count of m/s since the last call...
elapsed_time * .06 = The amount of rotation required to meet our requirements of
1-full 360-degree rotation every 6-seconds of time...
*/
float amount_of_change = (static_cast<float>(elapsed_time) * 0.06f);
TurnRight( amount_of_change );
m_LastUpdate += elapsed_time;
}
Here's my code for ElapsedTime()...
int ElapsedTime(void) {
static DWORD current_Timer = timeGetTime();
static DWORD last_Timer = 0;
static int elapsed_Time = 0;
/* Record our last frame... */
last_Timer = current_Timer;
/* Get the current time for this frame */
current_Timer = timeGetTime();
/* Calculate the total time that's elapsed (in m/s) */
elapsed_Time = static_cast<int>(current_Timer - last_Timer);
/* Now see if our internal clock has flipped... */
if (elapsed_Time < 0) {
/*
If we've hit in here, then our internal clock has flipped. In this
case, we will subtract our last_Timer from the highest possible
positive number we can store as a type DWORD. This will give us
the amount of time that has passed before the internal timer had
flipped. Next, we add the new current_Timer value to the
previous subtraction-value in order to account for the additional
time that has elapsed since the flip occurred.
If we're off by a couple of m/s, who cares... We should only
have to do this once in about every 50 days of running; we'll
catch up in the next frame (or about 16 m/s from now)...
*/
elapsed_Time = static_cast<int>(0xFFFFFFFF - last_Timer) + current_Timer;
}
return elapsed_Time;
}
Of course, you will have to add checks to make sure that you don't EXCEED the desired finished direction accordingly...
I hope this gives you some ideas to work with...
JTK
Edit: CODE tags are lower case? I never realized that before...