Codigo que muestra una pequena animacion en Allegro
1
2
3
4
5 void init();
6 void deinit();
7
8 int piramide(int a, int b, int c){
9 line(screen,a+(c/2),b,a,b+c,makecol(0,128,0));
10 line(screen,a,b+c,a+c,b+c,makecol(0,128,0));
11 line(screen,a+c,b+c,a+(c/2),b,makecol(0,128,0));
12 }
13
14 int main() {
15 init();
16 int a,b,inca,incb;
17 a=0,b=0;
18 inca=1, incb=1;
19 while (!key[KEY_ESC]) {
20 clear_to_color(screen,0);
21 circlefill(screen,a,b,50,makecol(128,0,128));
22 a=a+inca;
23 b=b+incb;
24
25 if (a==200){
26 inca=-1;
27 }
28 rest(10);
29 }
30
31 deinit();
32 return 0;
33 }
34 END_OF_MAIN();
35
36 void init() {
37 int depth, res;
38 allegro_init();
39 depth = desktop_color_depth();
40 if (depth == 0) depth = 32;
41 set_color_depth(depth);
42 res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
43 if (res != 0) {
44 allegro_message(allegro_error);
45 exit(-1);
46 }
47
48 install_timer();
49 install_keyboard();
50 install_mouse();
51 /* add other initializations here */
52 }
53
54 void deinit() {
55 clear_keybuf();
56 /* add other deinitializations here */
57 }