Jump to content
  • Advertisement


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


Animation without BitBlt or Controls?

This topic is 6183 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

Hi, can anyone help? I am making a game and I need to animate my sprite moving. I am not using any BitBlt API or anything like that. I have a set of 10 images that need to be used for the animation. Whenever I press the up key the sprite sholud animate going up and when I relsease the key it should stop animating right away. Is there a possible way I can do this? Thanks a bunch.

Share this post

Link to post
Share on other sites
As long as you know how to actually display an image, it should be easy. Animation just requires you to draw one frame of animation, wait a certain amount of time, and draw the next frame. Nothing too complicated in that.

If your animation is supposed to last long and has a small number of frames, then use a larger period wait between switching frames. If your animation is smoother with more frames in it, then use a shorter period.

You should be able to figure it out from there. Basically the game has to have some way of knowing whether sprite is actually being animated. For your case, your sprite could have some kind of flag which determines whether the animation is running or not. You also need to keep track of which frame of animation is currently being drawn. The animation would start at frame 0, and then every so much time the frame gets incremented by 1 which tells the game to draw the next frame. The actual images it uses would be depending on which direction your sprite was facing (judging by your post, I''m assuming your sprite can face more than one direction). When the user pressed a movement key, the game sets the sprite''s animation flag to 1, and when the user releases the key, it gets set to 0 which causes the game to stop the animation. Once the current animation frame reaches the actual number of frames, it needs to be reset to 0 to start over again.

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!