1exsprite(3)                     Allegro manual                     exsprite(3)
2
3
4

NAME

6       exsprite - Datafiles access and sprite animation. Allegro game program‐
7       ming library.
8

SYNOPSIS

10       #include <allegro.h>
11
12
13       Example exsprite
14

DESCRIPTION

16       This example demonstrates how to use datafiles, various sprite  drawing
17       routines and flicker-free animation.
18
19       Why  is the animate() routine coded in that way?  As you probably know,
20       VIDEO RAM is much slower than "normal" RAM, so it's advisable to reduce
21       VRAM  blits  to  a  minimum.   Drawing sprite on the screen (meaning in
22       VRAM) and then clearing a background for it  is  not  very  fast.  This
23       example uses a different method which is much faster, but require a bit
24       more memory.
25
26       First the buffer is cleared (it's a normal BITMAP), then the sprite  is
27       drawn  on  it,  and  when the drawing is finished this buffer is copied
28       directly to the screen. So the end result is that  there  is  a  single
29       VRAM  blit  instead  of  blitting/clearing the background and drawing a
30       sprite on it.  It's a good method even when you  have  to  restore  the
31       background. And of course, it completely removes any flickering effect.
32
33       When one uses a big (ie. 800x600 background) and draws something on it,
34       it's wise to use a copy of background somewhere in memory  and  restore
35       background  using this "virtual background". When blitting from VRAM in
36       SVGA modes, it's probably, that drawing routines have to  switch  banks
37       on video card. I think, I don't have to remind how slow is it.
38
39       Note that on modern systems, the above isn't true anymore, and you usu‐
40       ally get the best performance by caching all your animations  in  video
41       ram  and  doing  only  VRAM->VRAM  blits, so there is no more RAM->VRAM
42       transfer at all anymore. And usually, such transfers can run in  paral‐
43       lel on the graphics card's processor as well, costing virtually no main
44       cpu time at all.  See the exaccel example for an example of this.
45
46

SEE ALSO

48       BITMAP(3), DATAFILE(3), END_OF_FUNCTION(3), END_OF_MAIN(3),  LOCK_FUNC‐
49       TION(3),  LOCK_VARIABLE(3), SCREEN_H(3), SCREEN_W(3), allegro_error(3),
50       allegro_init(3),  allegro_message(3),  blit(3),  circle(3),  clear_bit‐
51       map(3),     clear_keybuf(3),    create_bitmap(3),    destroy_bitmap(3),
52       draw_sprite(3),      draw_sprite_h_flip(3),      draw_sprite_v_flip(3),
53       draw_sprite_vh_flip(3), fixed(3), font(3), hline(3), install_int_ex(3),
54       install_keyboard(3),  install_sound(3),  install_timer(3),   itofix(3),
55       key(3),  keypressed(3), load_datafile(3), makecol(3), palette_color(3),
56       pivot_sprite(3), pivot_sprite_v_flip(3),  play_sample(3),  rectfill(3),
57       replace_filename(3),   rest(3),  screen(3),  set_gfx_mode(3),  set_pal‐
58       ette(3),  text_height(3),   textout_centre_ex(3),   unload_datafile(3),
59       vsync(3)
60
61
62
63Allegro                          version 4.2.2                     exsprite(3)
Impressum