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

Manejo De Mouse En Allegro

09.22.2006
| 4827 views |
  • submit to reddit
        Manejo de mouse en Allegro

#include <allegro.h>

void init();
void deinit();

int main() {
	init();


    int x,y;
    show_mouse(screen);
	while (!key[KEY_ESC]) {
		/* put your code here */
  
       for (x=10;x<600;x+=50){
           for (y=10;y<420;y+=60){        
               if (mouse_x > x && mouse_x < x+40 && mouse_y >y && mouse_y < y+50){
                  circlefill(screen, x+20,y+25,20,makecol(128,y%255,0));    
               } else {
                  rectfill(screen, x,y,x+40,y+50,makecol(0,255,0));           
               }
           }    
       }
	}

	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 */
}