Archived

This topic is now archived and is closed to further replies.

Nick2048

GBA Sprites

Recommended Posts

I''ve made a little sprite demo on my GBA and I''ve noticed that the coordinates can go past 240x160 but they cannot be negative. So, how is it these games can have half the sprite on the left hand side and the other half off the screen?

Share this post


Link to post
Share on other sites
Check the coordinates of the sprite before you draw. If it is going to go off the screen, clip off only the visible part and draw that.

Share this post


Link to post
Share on other sites
The X coordinate of your sprite goes from 0 to 511 and the Y coordinate goes from 0 to 255. Whenever your sprite coordinate goes above 240 (x) or 160 (y) it is ''wrapped around'' to appear at the top / left of the screen.
So if you have a 32x32 sprite to put it in the upperleft corner of the screen set the coordinates to (511 - 16), (255 - 16) and you''ll only view the lower right part of the sprite.
The only problem you can run into is when you have a 64x64 sprite with the size double flag on (used in rotation). Then the sprite will be 128x128 pixels in size and it can''t wrap around completely. But that''s something you won''t often use so don''t worry about it. Good luck,

Jasper

Share this post


Link to post
Share on other sites