A89: Re: Rotating Sprites


[Prev][Next][Index][Thread]

A89: Re: Rotating Sprites




Hi!

|     I have several ideas for some games, which require displaying a sprite
| at various angles. I remember something about using matrices to do this,
but
| I don't know how to implement this.  I'm looking for a C function which
can
| quickly rotate a sprite at various angles. Any ideas?

Depending on what you want, yes.  If the angles are just 90, 180, and
270, this is rather easy to do.  180 just involves switching rows in the
sprite from the outside to the inside or verse vica.  90 and 270 are more
complicated:  You'll have to test each bit and put it in its new location.
I don't want to think about any details right now, but the fact is that it's
doable.

All other angles involve a lot of math, especially trigonometry.  For small
sprites, this also reduces quality a lot.  Calculating new positions for all
pixels is really slow as well.  I would recommend vectorizing your sprites
into polygons and calculating the new points for all corners of the
polygons.  Again, this involves trig; remember that floating point functions
are slow.  I don't want to go into any detail here; I assume you can do the
math.

Sorry if I wasn't able to help a lot.

Bye,
Sebastian




Follow-Ups: References: