# Sprite motion multiple angles without rotozoomSurface

Hi,

Im having a bit trouble figuring out a way how to rotate an sprite without using rotozoomSurface.

I have a SpriteSheet which has 32 angles and wish to use those angles.

what would be the best approach?

Kind regards,
Nicklorion

Im having a bit trouble figuring out a way how to rotate an
sprite without using rotozoomSurface.

I have a SpriteSheet which has 32 angles and wish to use
those angles.

what would be the best approach?

Well, you can have an array of rects with the coordinate for each sprite.

Or, if the sprites are linear in their representation, all horizontal or all vertical, you can do something like

sprite.x (or .y if vertical) = (int)(angle / # of sprites) * (width of one sprite)

if in a grid say 8 x 4

sprite.x = ((int)(angle / # of sprites) % 8) * (sprite width)
sprite.y = floor((angle / # of sprites) / 8) * (sprite height)

% = modulus operator if not using C.

or something like that.— On Wed, 2/10/10, nicklorion <bram.koster at getronics.com> wrote:

From: nicklorion <bram.koster at getronics.com>
Subject: [SDL] Sprite motion multiple angles without rotozoomSurface
To: sdl at lists.libsdl.org
Date: Wednesday, February 10, 2010, 9:29 PM

Anthony T.

Hi thanks for your input, i actually have an array of each angle.
Thing were i get stuck on is how to adress the sprite direction on a key press.

I have a Tank body sprite (16x2), so I have 32 possible angles
SDLK_UP increases the throttle.
SDLK_DOWN decreases the throttle.
SDLK_LEFT and RIGHT changes the angle from current angle ++ or –

so the angle should be a single integer containing 1 to 32.

any ideas on that?