0

my problem is this: In my game, the sprites all face in the same direction all the time, so sometimes they end up walking backwards or sideways etc and it doesn't look very good! So here is what I need help with:

Lets say I had an array of pixel data (reg, green, blue) stored in memory, loaded from a bitmap image. When I draw it to the screen, it always faces the same way (upwards), but I was thinking if there was a way to rotate the image by an amount (in degrees). This would be useful in top-down shooters, etc, where the player's sprite may have to rotate to the direction where it was facing. So, I need a way of rotating the pixel data by any amount of degrees.

My pixel arrays are stored like this:

A|B|C

A|B|C

A|B|C

And I would like a function which might look like:

D3DColor* RotateArray(D3DColor* array, float degrees);

so I could say:

RotateArray(my_pixel_array, 90.0f);

which would rotate the image so it looks like

A|A|A

B|B|B

C|C|C

..but I have no idea how I could do it. Any help would be greatly appreciated! :)

I have thought about this for quite a while and I'm not sure how to do it. I am using c++ on windows 8.1. Also, if it helps, I'm following the Chili Direct X Programming Tutorials on YouTube. In terms of experience, I have been programming for 2 years, and I'm pretty familiar with c++ it's just things like this which I have trouble with. Thanks!

  • possible duplicate of [Image scaling and rotating in C/C++](http://stackoverflow.com/questions/299267/image-scaling-and-rotating-in-c-c) – abacabadabacaba Mar 22 '14 at 19:19

1 Answers1

0

D3D has tranformations that help you do exactly that

http://msdn.microsoft.com/en-us/library/windows/desktop/bb206269(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb206365(v=vs.85).aspx

Read about it.

shoosh
  • 76,898
  • 55
  • 205
  • 325