Page 1 of 1

Problems with 2D Image Rotation (Interpolation?) [SOLVED]

Posted: Sat Jun 25, 2011 5:54 am
by g0bl1n
I'm making a simple 2d game that has a grid based building system. I have several "parts" (square, triangle, etc...) And for everything to look pretty the pixels have to line up correctly. For some reason the system I am using to rotate sprites is causing some of the sprites to rotate off of their center, so the pixel no longer line up (so if a square is at rotation 0, rotating it to 90 shouldn't cause a shift in the square's center). I'm using this system by Lonesome Ducky. I've also provided a link to my drawing source in case there is any questions on the drawing system, I've been working on it for a while and I can't seem to fix it, at first I thought my centers were off but I've triple checked everything and it is right.

Drawing Source
Header
CPP

Thanks!
G0bl1n

Posted: Sun Jun 26, 2011 2:06 am
by Lonesome Ducky
You're setting the rotation center depending on the origin, which means that the rotation center won't always be at the center of the object. If you set the rotation center to the position + half the dimension, it will rotate around the center of the image.

Posted: Sun Jun 26, 2011 6:03 am
by g0bl1n
Hey I figured it out! Turns out my origin was at (5.5,5.5) on my 11x11 image, but I was using a u32 to store the origin, so it was only storing (5,5), switched to f32 and all works fine now! Funny thing is that I didn't even look at that part of the code until you mentioned the origin stuff!

Thanks!
Goblin