GBA Sprites

Started by
1 comment, last by Nick2048 20 years, 11 months ago
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?
Advertisement
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.
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

This topic is closed to new replies.

Advertisement