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 > Rotational Sprite coordinates

#26495 - wlan - Fri Sep 17, 2004 3:52 am

Whats the deal on x-,y-coordinates when a sprite is set to rotation mode?

I set two sprites to rotation/double-size and when they would normally be apart they ended up stacked on top of each other. Sprite A was 32x32 and sprite B was 8x32. On VBA the read out said A was at (30,30) and B was at (30,62) yet B was clearly somewhere around the middle of A.

Could anyone give an insight as to how GBA handles the coordinates in rotational mode? I'd appreciate it immensely.

#26511 - Cearn - Fri Sep 17, 2004 8:59 am

the oam coordinates mark the top-left of the sprite rendering area, but the the center of the sprite itself is placed at the center of this area. Normally these two coincide, but the double-size flag moves the center of the rendering by half the size of the sprite.

In the case of a 32x32 and 32x8 sprite, their normal centers are at (16,16) and (16,4). To place these on top of each other you could use (0,0) and (0,32). But when you switch on the double size flag, the rendering centers shift to (32,32) and (32,8). If you are still using the same coords, the sprite's centers are now only 8 apart, which will make them look on top of each other.
It might help if you drew a picture on graph paper to see what I'm talking about; it's kinda tricky to express in words.