Original Post
Hi, I've got an issue in XNA which is driving me insane and I'm confused as to whats going on. Basically I'm new to XNA but experienced in OpenGL and Direct X with c++. I want to tween between rotations for a tank game so when you press the analog stick you new rotation is set to the orientation of the stick, and for smooth movement I want to blend between current rotation and the new rotation. Simple enough, I have already implemented similar things before so just did the code as usual and expected it to work... but no it doesn't. what I get is the sprite randomly spinning around franticly before it stops, So from the above source, you would expect baseRotation to update to 40 then get set to the same as intRot and then thats it. If I debug and step through, this happens, just if I run the game it doesn't, it just spins around a few times and then eventually stops. I just call the update function move from inside my main update function. Anyone had any experience of this or am I doing something silly along the way? Just a quick note, I'm not updating based on time or using floats because I initially thought that this was causing the issue but evidently not.
//intialisation
int baseRotation = 0;
int intRot = 45;
public void move(GameTime gameTime)
{
if (baseRotation < intRot)
{
int diff = intRot - baseRotation;
if (diff <= 5)
{
baseRotation = intRot;
}
else
{
baseRotation++;
}
}
else
{
baseRotation = intRot;
}
}