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.

Coding > can't i use H/V FLIP together with Rotation/Scaling?

#3804 - jammin.won - Sun Mar 09, 2003 4:11 pm

after i've created a sprite ,everything is ok ,i can flip it freely

but the problem happens when i made this sprite rotatable ,after this ,as soon as i flip the sprite,the sprite changes into a square of some color...then i clear the flip bit, the sprite then came back

....that's really weird ....so if i cant can't i use H/V FLIP together with Rotation/Scaling?

#3806 - tepples - Sun Mar 09, 2003 4:28 pm

You can't use H/V flip with affine sprites directly, but you can accomplish vertically the same effect by creating another affine matrix.

Explanation: For non-affine sprites, sprite flipping is mapped to matrix indices 0-7, 8-15, 16-23, and 24-31. But for affine sprites, the matrices at those indices default to all-0, which produces a rectangle of the color of the center of your sprite.

Fix: Make another matrix by negating the appropriate elements of your current matrix.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#3809 - jammin.won - Sun Mar 09, 2003 4:57 pm

thanks a lot tepples,thats very helpful

hmmmm i nearly got it ....but still dont know the detail how to create another affine matrix and modify the flip bits

can u plz explain it in a little more detail ?

thx

#3812 - jammin.won - Sun Mar 09, 2003 5:32 pm

hmmmmm .... if it is accomplished by create a dummy sprite ???

i tried but failed =(

#3824 - DekuTree64 - Mon Mar 10, 2003 12:53 am

Well, if I remember right, pa is the h scale, and pd is the v scale, so say you want to flip horizontally, set pa to -256. And say you want to scale to 2x normal size, and flip v, set pd to -128. You can try writing a little test program where you can use the keys to add/subtract from the scale value and just watch it flip when you go below 0.

#3832 - jammin.won - Mon Mar 10, 2003 4:38 am

YES!!! i got it

just set PA = -255;PD = 255; to get a horizontally flip

thx deku
_________________
[Images not permitted - Click here to view it]