[SDL] Best way to rotate a sprite?
sami.naatanen at kolumbus.fi
Mon Jan 27 15:15:01 PST 2003
On Tuesday 28 January 2003 00:40, Tane Piper wrote:
> On this note, I think your right, and I need to re-think it. I was
> thinking more 1 image which I rotate through 360-degrees, but I don't
> really need more than 8, or 16 directions at the most. So basically
> each time I press the left or right arrow key, it will turn the
> graphic 22.5 degrees, and then make it travel along that vector for
> the up/down arrow keys. If I need to I can always make the
> resolution of the turn smaller to make 32 or 36 directions if needed.
Well 32 is better than 36, because with 32 different angles you will get
the 45 degree diagonal angles, but with 36 steps the angles will go in
10 degree steps.
PS. With 32 (or 16) steps you can use logical and to clamp the angle
after increasing or decreasing it.
angle = (angle + 1) & $1F; // clamps the angle between 0 and 31
angle = (angle - 1) & $1F; // clamps the angle between 0 and 31
More information about the SDL