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.

Beginners > Sprite Animation

#34794 - Mitch GBA - Wed Jan 26, 2005 9:34 am

ok. I've now completed my first platform movement code. I now want my character sprite to be animated when I walk and jump. How do I do this? And if it matters, I'm using Mode 4..

Help would be much appreciated!
-Mitch[/i]

#34795 - jenswa - Wed Jan 26, 2005 11:22 am

You've already setup a sprite?
By using the gba's sprite system (faster, use tilepointer 512 and above) or by just plotting it to screen.

Animating a sprite is done by chaning the tilepointer from the sprite. So your first picture is in position 512 and your second picture maybe in position 520, your third picture another 8 further and so on. When you've reached your last picture of the animation, make sure you set the position to 512 in orde to get the first picture again and start the animation over.
(in this case position 512, is the first picture of your animation)

To do this you've to set up your own animation system, most of them a time based, that will say, after x seconds change the picture to the next picture.

If you want to make the difference between left and right, use variable which tells you what position the character is facing.

I hope this helps you a litte...

(excuse me for my english, it's still morning for me and i actually should be in bed right now)
_________________
It seems this wasn't lost after all.

#34799 - Mitch GBA - Wed Jan 26, 2005 1:30 pm

Nederlands kan ook :) Ik ken jou. Hooghaar en Fishhead etc on MMF :) Anyway, thanks, I think I know what you mean. I'll try and figure it out, and if I fail, I'll ask for a code example ;)

#34800 - Mitch GBA - Wed Jan 26, 2005 1:45 pm

hmmm. No I cant get it to work. Can someone show me some code, for example 1 sprite of pacman, that you can move left-right and see animated? caus I dont really know how to switch between drawing 512, 512+8, 512+16 etc..

Example would be VERY appreciated :D
-mitch

#34801 - Celeryface - Wed Jan 26, 2005 1:54 pm

Rather than changing the tile index, you could DMACopy the next frame of sprite data overtop of current sprite that you're using for your character. This will save on sprite/tile space and you won't have to change the tile index for your sprite.

:)

#34807 - jenswa - Wed Jan 26, 2005 4:28 pm

This is an example of the way i was talking about, the ghost shifts colour when you move him.

http://www.geocities.com/flashsite_jrj/gba/sources/ghost_animation.zip

What Celeryface is meaning, is that you can load a new image with DMA.
What i do is i already have all of my images loaded.

And yes i am the author from HoogHaar and a friend of mine is the author of fishhead.
_________________
It seems this wasn't lost after all.

#34892 - Mitch GBA - Thu Jan 27, 2005 11:59 pm

Thanks dude! :) really helpfull. I guess I can use the same technique in Mode 4 ey?

#34906 - Celeryface - Fri Jan 28, 2005 4:05 am

Mitch GBA wrote:
Thanks dude! :) really helpfull. I guess I can use the same technique in Mode 4 ey?


Yes, you can use the DMACopy method as well in Mode 4. :)