Guest User

Untitled

a guest
Apr 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.81 KB | None | 0 0
  1.  
  2. void init();
  3. void deinit();
  4.  
  5. void desenhaInstrucoes( BITMAP *bmp[] ) {
  6.   bmp[0] = load_bitmap( "mover.bmp", NULL );
  7. }
  8. typedef struct personagem
  9. {
  10.         int x, y;
  11.         enum direcao d;
  12.         bool andando;
  13.     int image;
  14.     int pixels_andados;
  15.     //BITMAP *img;
  16. } personagem;
  17.  
  18. int mouseSobreBotaoInstrucao( personagem *j, int x, int y ) {
  19.   if( 400 <= x && x < 400 + j.pixels_andados &&
  20.       j.y <= y && y < j.y + j.pixels_andados ) {
  21.     set_mouse_sprite( j->bmpInstrucao[0] );
  22.     return 1;
  23.   }
  24.   else
  25.     return 0;
  26. }
  27.    
  28. int main() {
  29.  
  30.   init();
  31.   rectfill( screen, 0, 0, 499, 499, makecol( 23,47, 60 ) );
  32.   allegro_message("Welcome to tibia");
  33.   int grab = 0;
  34.  
  35.  
  36.   while (!key[KEY_ESC])
  37.   {
  38.     if( mouse_b & 1 ) {
  39.       if( !grab ) {
  40.         int mouseX = mouse_pos >> 16,
  41.             mouseY = mouse_pos & 0x0000ffff;
  42.  
  43.         if( mouseSobreBotaoInstrucao( &personagem, mouseX, mouseY ) ) {
  44.           select_mouse_cursor( MOUSE_CURSOR_ALLEGRO );
  45.           show_mouse( screen );
  46.           grab = 1;
  47.         }
  48.       }
  49.     }
  50.     else if( grab ) {
  51.       select_mouse_cursor( MOUSE_CURSOR_ARROW );
  52.       show_mouse( screen );
  53.       grab = 0;
  54.     }
  55.   }  
  56.   }
  57.   deinit();
  58.   return 0;
  59. }
  60. END_OF_MAIN()
  61.  
  62. void init() {
  63.   int depth, res;
  64.   allegro_init();
  65.   depth = desktop_color_depth();
  66.   if (depth == 0) depth = 32;
  67.   set_color_depth(depth);
  68.   res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 500, 500, 0, 0);
  69.   if (res != 0) {
  70.     allegro_message(allegro_error);
  71.     exit(-1);
  72.   }
  73.  
  74.    
  75.   install_timer();
  76.   install_keyboard();
  77.   install_mouse();
  78.  
  79.   /* add other initializations here */
  80.    enable_hardware_cursor();
  81.   select_mouse_cursor( MOUSE_CURSOR_ARROW );
  82.   show_mouse( screen );
  83.  
  84. }
  85.  
  86. void deinit() {
  87.   clear_keybuf();
  88.   /* add other deinitializations here */
  89. }
Add Comment
Please, Sign In to add comment