Sequence animation by codes or using .gif image

Started by
8 comments, last by mic_k 8 years, 11 months ago

Hi,

I'm working on 2D air shooting (using c++), idea is something like 1943 or Gradius.

Basically, player moving around up, down, left & right, shoot bullets to enemy, and enemy shoot too.
It works find, and now i'm in modif & fix-up things.

The ship movement animate some sprites, following the direction button hit by player.
If moving up, then i animate the up-movement sprites,
about 4 images within some(1 or 1.5) seconds, as long the player hold the up-button.
Same on with moving left, i play the left-movement sprites,
also the behavior for moving right & down.

And now i have this in mind:
1. I will stick to play animation sequence using program(codes) everytime player push the button.
Or,
2. Should i change, by prepare 4 images(up, down, left, right) in gif format,
which is each image already play their own frame sequence as i setup from image designer tool

(not to play the sequence by codes)

I'm thinking about:
- Memory consumption when game is running, overall, regarding player's directional movement.
- Game modification (if someday i need to change/add the sprites, sequences, etc... related to efficiency or practically)

Does anybody have opinion ?

smile.png Thanks.

Advertisement

Since you asked for opinions: GIF as in-game format is a no-go for me. I mean … it is GIF, isn't it?

From a more technical point of view, you need to have an animation system anyway. It should work considering delta frame times which is not included in GIF animations (AFAIK). Having the own code controlling things gives the best flexibility. So, why not using this same mechanism for all instead of introducing a second mechanism for the gain of, well, nothing in the end.


I mean … it is GIF, isn't it?

** Yes, i mean an image file with extension .GIF


Having the own code controlling things gives the best flexibility. So, why not using this same mechanism for all instead of introducing a second mechanism for the gain of, well, nothing in the end.

** I do feel safer when many things are under control(by my codes), and gives flexibility too, of course. biggrin.png

Many ways can be done, or maybe certain, to achieve one purpose, i got it.

It is a thought, maybe, about to mix some partial existing objects (if possible), rather than to build/rebuild a new one.

Since you mention about gain, mean benefit, pros or cons, yes.. that's what i'm currently thinking..

Well, thanks for the opinion smile.png


4 images within some(1 or 1.5) seconds

A sequence that long will likely cause problems using an animated GIF - timing. You won't know exactly when the GIF animation has completed. If the user presses "up" and, before the animation finishes, presses another key ("left" or "down" or ...) - what action does your game take, and when do you take it? Do you just interrupt the animation (probably won't be pleasing for the user), or guess at the time it finishes, and/or guess which image in the sequence is being presented to make a smooth transition?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


4 images within some(1 or 1.5) seconds

A sequence that long will likely cause problems using an animated GIF - timing. You won't know exactly when the GIF animation has completed. If the user presses "up" and, before the animation finishes, presses another key ("left" or "down" or ...) - what action does your game take, and when do you take it? Do you just interrupt the animation (probably won't be pleasing for the user), or guess at the time it finishes, and/or guess which image in the sequence is being presented to make a smooth transition?

You're right, i had those issue.
This time, the process is interrupted, my animation-set instantly changed into the new direction of images sequences.
Also, back to the learn of "object not stop instantly, but it slowing down (stopping) until zero-movement",
i have to fix this, regarding the transition scenarios. Thanks!

Ok, i think the GIF animation won't work for this necessity of directional (smooth)transition control.

Perhaps, i still be 'allowed' biggrin.png to use GIF animation for explosion/crash images,

since it just to running static in sequence.

I can't see that using a gif gives you any advantage at all. It's used for animating low quality images on the web, why would it be appropriate for a game written in c++?

There are the following disadvantages:

- limited to 256 color palettes (for the most part)

- limited to single bit transparency

- you'll need to find some library to support loading and drawing/animating gifs. This will probably be more work than just writing code that displays a new image in a sequence every few frames, based on your game's internal timers and whatever image format you currently have working in your game.

On the file format specifically, some formats are based around data transmission, such as .gif, .jpg, .png. They focus around small file size at the expense of display processing compute power.

Other formats are typically used by games. Modern graphics cards can handle the S3/DDS formats (DDS = DirectDraw Surface) also labeled DXT1 through DXT5. Since there is no processing or memory involved, you can dump the data directly to the card, the formats are great for games.

On the concepts of using sprites, there is no problem with that. Many games are sprite-based. Some use hand drawn 2D sprites, some games turn 3D models into 2D rendered sprites. On rendering, some games draw just the sprites in plain 2D, others use a 3D engine and draw the sprites as textured quads (rectangles) as billboards within the 3D world. It is quite common, so go ahead and do that with your game.

I've been search any info related render .gif animation with SDL2 (currently i use this for display, text and sound).
And from what i've got is.. since i run the render in my routine (game)frame loop, that .gif does not show animation as i expected,
it shows only the sequence 1 from my .gif file.

As i read forums/articles, said that SDL2 rendering static image based,

nothing more about feature of automatic/direct draw for ready-animation .gif file.

Has anyone found-out one ?

But, if to force the idea (display an animated gif file, and let it play itself, independently),
is to separate things by multithreading tricks.. haven't tried this.
Will this worth ? biggrin.png(not sure)
Or maybe need another library, to work together with SDL2, just to show my animated .gif as @phil_t mentioned.


Modern graphics cards can handle the S3/DDS formats (DDS = DirectDraw Surface) also labeled DXT1 through DXT5. Since there is no processing or memory involved, you can dump the data directly to the card, the formats are great for games.

** i'll find out about this.. thanks!

Well, meanwhile i'll stick on the manual animation mechanism (frame-by-frame) inside my codes,

fix up things, gameplay especially, overall.

Thanks for all opinion.. keep up!

As part of my game i had some assets which were royalty free assets provided in animated gif format.

Animated gif being ugly as sin, i extracted all the frames into 24-bit png, and then used them in my game as sprite animation frames so i have full control over what is drawn and when as outlined by many above.

If you have gifs and no other format, this is an approach you can take. If you DO have other formats, insist on them, because gif is just horrid and limited (e.g. only one bit of alpha, eww, and only 255 solid colours, ewwww unsure.png).

Hi,


If you have gifs and no other format, this is an approach you can take. If you DO have other formats, insist on them, because gif is just horrid and limited (e.g. only one bit of alpha, eww, and only 255 solid colours, ewwww unsure.png).

I've read about the frame-extraction for .gif file, thanks.

This will much help, when i want to do prototyping project and to use an ready-animation image of someone's creation out there. smile.png

At first, i was thinking, that i with our graphic designer friend working together to integrate images(created by our team) into our game,

then someday, need a change in an object with animation frames, regarding the sequence change or additional images (with)in the sequences itself.

So the designer just to modif the image file, as i imagined first time, then when finish, just to plug and play.. ta da..

(without i need to change some code, even nothing matter for the total frame numbers of the sequences) biggrin.png

Some animation objects i need to control the sequences from code, maintain the detail & smoothness in graphic, yes i do.

But what about for some other static/passive(not a main) objects ? (like simple-crash explosion, some medium stars that twinkle, bullets, etc..)

Actually not just about the .gif format in specific (sorry the title mention only '..gif image'),

maybe any other format, tools, library, anything that animate a group of images. If there are..

That's what i have in mind happy.png

This topic is closed to new replies.

Advertisement