Sprite animation

A place for your artistic side. Discuss techniques and tools for pixel art on the NES, GBC, or similar platforms.

Moderator: Moderators

Post Reply
User avatar
johnnystarr
Posts: 22
Joined: Thu Dec 27, 2012 8:15 pm

Sprite animation

Post by johnnystarr » Thu Dec 27, 2012 8:26 pm

I have been trying to locate any animation tutorials online but havent so far. I have gone over basic tutorials and have been learning quite a bit.

An example or two might go a long way. I have a few questions as well:

Can you run the animation routine during NMI?

Is there any built in PPU tricks, or is it all up to writing ASM?

How would you handle delays for slower animation or timed events?

Thanks!

User avatar
tokumaru
Posts: 11495
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Sprite animation

Post by tokumaru » Thu Dec 27, 2012 8:48 pm

johnnystarr wrote:I have been trying to locate any animation tutorials online but havent so far.
Advanced topics are hardly covered in friendly tutorials, I'm not sure why.
An example or two might go a long way.
I think memblers posted some animation code at some point... Search for his name and "animation" and you might find something.
Can you run the animation routine during NMI?
you shouldn't, unless all your game logic is inside the NMI handler, running after the video and sound updates (like in SMB1, for example). Character animation would work better close to the character's AI.
Is there any built in PPU tricks, or is it all up to writing ASM?
No tricks at all, there are absolutely no hardware functions that will help you with animations. All graphics are static unless you change them from frame to frame, which you do with pure logic.
How would you handle delays for slower animation or timed events?
I'm not sure what you mean here... Could you provide an example?

Delays are often represented as numbers between 1 and 256 (which you can store as 0-255 and use the carry to compensate) that you add to an accumulator, and whenever that accumulator overflows (the carry flag will be set after the addition) you have a "tick" (in the case of animation this means you'd advance to the next frame). You can easily adjust this value to make the animations faster or slower, with a good deal of precision. This works for music too.

User avatar
infiniteneslives
Posts: 2097
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: Sprite animation

Post by infiniteneslives » Fri Dec 28, 2012 2:14 am

This tut is pretty decent: game engine. The first couple go into sprite animations.
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers

User avatar
mikejmoffitt
Posts: 1348
Joined: Sun May 27, 2012 8:43 pm

Re: Sprite animation

Post by mikejmoffitt » Fri Dec 28, 2012 8:03 pm

The psuedo-code for the animation engine in my C++ fighting game works like so:

Code: Select all

variable currentFrame;
variable advanceCounter;
variable frameLength[]; // each cell of this array corresponds to every frame of the animation
constant animationLength;
constant loopbackFrame;

updateAnimations:

if the currentFrame > animationLength:
  reset currentFrame to loopbackFrame;
else:
  increment advanceCounter;
  if advanceCounter > frameLength[currentFrame]:
    reset advanceCounter to 0;
    increment currentFrame;
display animation frame #[currentFrame]
I'm too tired to proofread that, but I hope that clarifies how you might structure animation playback.

Post Reply