[SDL] Best way to rotate a sprite?

Nicolai Haehnle prefect_ at gmx.net
Tue Jan 28 09:58:01 PST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 28 January 2003 00:15, Sami Näätänen wrote:
> 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

Note that most compilers should optimize this automatically (IIRC gcc does 
it even with optimizations disabled). You could always look at the assembly 
output just be sure ;)

cu,
Nicolai
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+NsUWsxPozBga0lwRAu1CAJ42NS87UESGZ5laPhl3YKd8H5sa1gCgwddP
apsnfh0QN0mMjd6392ycw/I=
=19E3
-----END PGP SIGNATURE-----





More information about the SDL mailing list