Archived

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

Snoobab

GameBoy Advance : Sprites

Recommended Posts

Hi. I''ve got two questions relating to the GBA and sprites which I hope someone could help me with. Firstly: How do u animate a sprite? Eg. A person walking. Would u store the desired frames in OAMData memory(0x6010000) then just changed the value of sprites[0].attribute2 to point to the beginning of your next frame? Secondly: I know it is possible but I''m not sure how to use sprites in the GBA''s bitmap video modes. Apparently the sprite tile memory is halved in the these modes. Hope somebody is able to help! - Ed.

Share this post


Link to post
Share on other sites
Firstly, you're best off overwriting the image data each time you want the animation frame to change. You can move in a different sprite every time, and have each sprite contain a different frame, but really that's just going to take up too many sprites to be practical. That's why you're best off just using a DMA copy to overwrite the data each time.

Secondly, all that means is that every sprite needs to have a character number no lower than 512 in the bitmap modes. Everything else works the same.

[edit] - "character number greater no lower than 512" made no sense. surprised i didn't catch that earlier.

-Arek the Absolute

[edited by - Arek the Absolute on July 5, 2003 6:45:43 PM]

Share this post


Link to post
Share on other sites
Thanks a lot Arek the Absolute, it works really well. A bit to well actually. My animation is now being displayed as fast as the GBA hardware can render each frame which is MUCH to fast. I managed to slow my animation down to the desired speed using about 40 WaitForVSync(); functions calls between frame copies. I know this is the wrong way of doing it! What would be the least CPU intensive way of slowing my animation down to the desired speed? Would using the GBA''s timers to do this be the best option?

Thanks again

- Ed.

Share this post


Link to post
Share on other sites
Depends on what you need. Actually, in most of my simple examples I do the exact same thing you did, which is to say, wait for a ton of v-syncs. You can also have a variable that say, increments every v-sync, and use that to track when to update animation. Maybe something like this:


int main(){
int delay = 0;
while (1){
if (delay == 40){
UpdateAnimation();
delay = 0;
}
delay++;
WaitForVSync();
}
}


Of course, this isn''t very accurate, and if your program starts running slow, your animation will go slower too. Timers are probably the most accurate way of measuring when to update animation frames, but certainly not the easiest to implement.

To put it simply, I wouldn''t be so abrupt as to say there''s a wrong way to do it, so long as it does what you want it to. Just find out what''s easiest for you to implement that will match whatever requirements you may have. Be creative.

-Arek the Absolute

Share this post


Link to post
Share on other sites
Thanks again for your help. I¡¦ve got ANOTHER question! ƒº

How would I get rid of the black border which can be seen around non-square sprites (i.e. the whole sprite is not filled in) when I use a tiled background? Is there something built into the GBA hardware which can do this for me (transparency?) or would I have to implement some sort of colour keying manually?

- Ed.

Share this post


Link to post
Share on other sites
This is true for both tiles and sprites. Any pixel that is palette color 0, whatever color that may happen to be, will not be shown. So basically, anything you want to be transparent (such as the space around the character that fills in the rest of the square) should all be palette index 0.

-Arek the Absolute

Share this post


Link to post
Share on other sites