What type of animation file should I add to a pygame game?

Question:

I want to make complex animation for my game but I don’t know how to.

I first thought that you have to add an animation file to the game and blit it. For example my game, every time you shoot and it touches a ghost it explodes. So the external animation file gets called and get copied to the screen and plays where the ghost touched the bullets. Is this used in most games?

If this is used what animation file extension should I use for it, .ani?, .flc?, .gif? or .webp. I’m not saying that these are the only animation file extensions available though.
Its kind of like background sound effects in games, like .wav files, when a certain thing occur it plays, but in this case the animation blits to the screen and then play.

But when I saw in a python/pygame code example on the internet they just added code that probably won’t make an explosion look like an actual explosion. The animations just moves pygame images and shapes.

But I’m considering if I should have animations…

  • So should I make an external animation file or stick to the python code example?
  • But if I make an external animation file how do I copy the animation to the screen plus play it at the same time?
Asked By: user2727932

||

Answers:

PyGame doesn’t have special functions to display file with animations.

Most games use images (for example .png) to create animation frame by frame.

Often all frames are in the one file like this: http://www.ucigame.org/Gallery/images/char9.png

enter image description here

You (as game developer) have to draw appropriate frame every 1/25 second (to get 25 FPS).

Game libraries (like PyGame) are there to help you with that – mostly they use objects called "Sprite".

Answered By: furas
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.