DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Animacion En Allegro

09.22.2006
| 3433 views |
  • submit to reddit
        Codigo que muestra una pequena animacion en Allegro


#include <allegro.h>

void init();
void deinit();

int piramide(int a, int b, int c){
    line(screen,a+(c/2),b,a,b+c,makecol(0,128,0));    
    line(screen,a,b+c,a+c,b+c,makecol(0,128,0));
    line(screen,a+c,b+c,a+(c/2),b,makecol(0,128,0));    
}

int main() {
	init();
	int a,b,inca,incb;
	a=0,b=0;
	inca=1, incb=1;
	while (!key[KEY_ESC]) {
          clear_to_color(screen,0);
            circlefill(screen,a,b,50,makecol(128,0,128));
            a=a+inca;
            b=b+incb;
            
            if (a==200){
               inca=-1;            
            }
        rest(10);
	}

	deinit();
	return 0;
}
END_OF_MAIN();

void init() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_mouse();
	/* add other initializations here */
}

void deinit() {
	clear_keybuf();
	/* add other deinitializations here */
}