gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Horizontal Flip + Rotation = erm...

#35283 - mr_square - Wed Feb 02, 2005 4:32 pm

Bizarre problem here - I'm trying to make an enemy rotate. My code differentiates between enemies facing left and facing right using the following code:

Code:

if //facing right....
{
sprites[x].attribute0 = COLOR_256 | SQUARE | ROTATION_FLAG | yPos & 0x00FF;
sprites[x].attribute1 = SIZE_64 |  ROTDATA(17 + x) | xPos & 0x01FF;
etc...
}
else //facing left...                {
{
sprites[x].attribute0 = COLOR_256 | SQUARE | ROTATION_FLAG |yPos & 0x00FF;
sprites[x].attribute1 = SIZE_64 | HORIZONTAL_FLIP |  ROTDATA(17 + x) | xPos & 0x01FF;
etc...
}


Literally the only code difference is the addition of the HORIZONTAL_FLIP flag, but whenever enemies are facing left, they come up as big single blocks of colour (as though its zoomed too far). Take out the HORIZONTAL_FLIP flag, and they look fine. Whats going on??

#35285 - mr_square - Wed Feb 02, 2005 4:52 pm

Ah - answered my own question. Just added a negative scaling factor instead of using the HORIZONTAL_FLIP flag, and it works perfectly.