#16337 - delbogun - Thu Feb 12, 2004 8:27 pm
If I have a sprite and want to place it for example on pos x=300 y=300, how do I do that when the limit for sprite position is 256?
Is there an easier way to check collision on other sprites rather then retrieve the x, y, size and shape of the sprite?
#16338 - DekuTree64 - Thu Feb 12, 2004 8:47 pm
Treat OAM as your interface to the hardware, not your sprite info storage. Keep your sprite pos/size data in an array of structs and then set the OAM to display them each frame. The OAM positions are only for displaying sprites, not for keeping track of where they are in the world, and because of that, they're not really limits. Since the largest sprite size is 64x64, you only need 0 to 240 for X positions with the upper left corner to the right of the left edge of the screen, and -1 to -64 for off the left side, which are mapped onto 511 to 448, which convieniently works out if you AND a negative number with 511. Same for Y, except since the screen is only 160 pixels tall, that gives you more than 64 past the bottom edge before you use up 256 values, so they only used an 8-bit position for it, so then you AND with 255 instead.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#16636 - delbogun - Sat Feb 21, 2004 7:08 pm
Thanks, that clears up a lot.
About the other question, I guess there isn't any hardware option to check sprite collision (like NES programming).
#16640 - tepples - Sat Feb 21, 2004 8:12 pm
No, the GBA's PPU does not report sprite-sprite or sprite-background collision back to the CPU. There's also nothing like NES's sprite 0-background collision check, which was usually used as a cheap hack to get around the NES's lack of a VCOUNT register in order to set up raster effects.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.