Jump to content
  • Advertisement


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

Lord Hen

Keeping track of animations? (and collisions)

This topic is 5462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the 2d tile based game I''m writing, I am trying to think of how to keep track of animations... Should I keep an array of structs with the x,y,width,height of each frame, and load that info from a file? And what if one animation needs to loop, and another animation needs to alternate directions from first frame to last to first? One more think on animations...How should I keep track of, say, the character''s attack, walk, jump, etc. animations? Lastly, I dont want to do pixel perfect collision detection, because, what if the players head goes over the bottom of a tree? Thats not a collision... Any suggestions? Thanks, Lord Hen "I am free of all prejudices. I hate everyone equally." - W. C. Fields [edited by - Lord Hen on December 2, 2008 2:32:49 AM]

Share this post

Link to post
Share on other sites
what you need to do is store your animation frames separate from your animating object. Your animationObjects can then store the current animation that it is displaying as well as the currentFrame of that animation. That way all animationObjects are displaying different frames at different times. One animationObject could be looping while another could be alternating directions between the frames.

struct Animation
Surface* frames;
int numFrames;
int Width;
int Height;

//this is your animation frames array
Animation animations[NUM_ANIMATIONS];

struct AnimationObject
Animation* currentAnimation;
int currentAnimationFrame;

As for collisions, use bounding circles. If you have a character that's 32x32 pixels you can use a bounding circle with a radius of 16 to do your collisions. Make the circle smaller if you want the collisions to be less precise.

[edited by - BoosterBoy on November 9, 2003 4:17:14 AM]

Share this post

Link to post
Share on other sites
Incidentally if you want to animate your tiles, a simple method is to have an array of old tile->new tile numbers. Each frame (or anim unit) set the old to new and reprint. That way you can set up loops of tile numbers or whatever. I used that trick years ago on Amiga and it was quite versitile. You can get tiles to run little explosions that end in a rubble tile for example.


Flatspace is coming: Topdown Elite for 2004

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!