[Allegro] Animation / Sprite en 2D, théorie...

Animation / Sprite en 2D, théorie... [Allegro] - C++ - Programmation

Marsh Posté le 01-04-2003 à 09:32:10    

   Salut,
J'ai trouvé un exemple qui propose la méthode suivante pour animer un sprite:
 

Citation :


As you probably know, VIDEO RAM is much slower than "normal" RAM, so
 *  it's advisable to reduce VRAM blits to a minimum.
 *  So, drawing sprite on the screen (I mean in VRAM) and then clearing
 *  a background for him is not very fast. I've used a different method which
 *  is much faster, but require a bit more memory.
 *  I clear a buffer (it's a normal BITMAP), then I draw sprite to it, and
 *  after all I blit only one time this buffer to the screen. So, I'm using a
 *  single VRAM blit instead of blitting/clearing background and drawing
 *  a sprite on it. It's a good method even when I have to restore background.
 *  And of course, it completely remove flickering effect.
 *  When one uses a big (ie. 800x600 background) and draws something on it,
 *  it's wise to use a copy of background somewhere in memory and restore
 *  background using this "virtual background". When blitting from VRAM in SVGA
 *  modes, it's probably, that drawing routines have to switch banks on video
 *  card. I think, I don't have to remind how slow is it.


 
j'ai fait un bête copier coller de son explication.
Je ne comprends pas trop lorsqu'il dit que c'est mieux que blitting/clearing background & drawing.
 
La théorie c'est quoi (sans parler d'allegro), pour déplacer un sprite par exemple?
 
on dessine dans le back buffer et après on blit à une certaine position. Si on blit juste un petit carré de la taille du sprite, ça écrase ce qu'il y a l'écran? Comment ensuite redessiner à la position précédente le background?
 
Je demande juste l'idée pour faire ça de la manière la plus optimisée possible! De plus si des personnes connaissent bien allegro, peut être pourront-ils m'indiquer des fonctions aidant à faire de l'animation de sprite... (draw_sprite,...)
si y a un exemple simple je suis aussi preneur, merci.
   ANT

Reply

Marsh Posté le 01-04-2003 à 09:32:10   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed