I am writing a game that consists of controlling a ship that travels
around an arena shooting other ships. The right/left keys rotate the
ship, and the up/down keys propel it in the direction it is pointing.
I need to generate the rotated frames of the ship somehow, but there
doesn’t seem to be an easy way of doing it.
I have one image of the ship that is 128x128 with a black background. For
the ship, I resized the image to 49x49 and then filled in the background
with bright orange (for transparency).
Originally, I wanted to have a rotated image every 5 degrees, and store
all of the rotated images in one file so I could just modify the
SDL_Rect’s x and y coords to change the image used for the ship. The
problem with doing this is that when you rotate the image, the corners
stick out, so you have to cut them off while trying to keep the
center the same to avoid jitteryness. After rotation and cutting,
the resulting image must be resized down to the 49x49, and then the
background must be colored in with orange. Doing this with all 72 frames
for the image would take hours with gimp, and then arranging each frame
into one big image would take much more time than that, because every
image must be positioned perfectly.
I can use ImageMagick’s convert command to generate the rotated images
with a bash script, but the problem still remains of cutting off the
extraneous edges made from rotating, resizing to 49x49, coloring the
background orange, and then adding them all to each other (convert
I’m sure there is some algorithm that would rotate the image in-game from
one sprite, but I am not so sure that it would be fast enough.
Additionally, I have no idea whatsoever how such a beast would be written.
There will be many different ships, so anything I decide on will have to
be done for each ship.
Anyone know of something that would automate this process, or know of the
above mentioned algorithm and it’s implementation?
DVD-Playing-HOWTO - http://helo.org/dvd/howto