Ejemplo n.º 1
0
/* parse_leftclick: the mouse was leftclicked */
void parse_leftclick(void)
{
    LIST_ELEMENT *old_selection = selection;
    if ((mouse_b & 1) && !left_down) {
        /* mouse clicked */
        left_down = 1;

        if (point_in_rec(get_mouse_pos(), TILE_WIN)) {
            /* within the TILE_LIST */
            selection = list_element_clicked(get_mouse_pos(), tile_elem_lst,
                                             tile_elem_lst_sz);
            if (selection) {
                /* select in this list and disselect in the other list */
                set_pressed_element(selection, tile_elem_lst,
                                    tile_elem_lst_sz);
                set_pressed_element(selection, spr_elem_lst, spr_elem_lst_sz);
                /*set_mouse_sprite(selection->bmp); */
                mode = TILE_MODE;
            } else {
                selection = old_selection;
                old_selection = NULL;
            }
        } else if (point_in_rec(get_mouse_pos(), SPRITE_WIN)) {
            /* within SPRITE_LIST */
            selection = list_element_clicked(get_mouse_pos(), spr_elem_lst,
                                             spr_elem_lst_sz);
            if (selection) {
                /* select in this list and disselect in the other list */
                set_pressed_element(selection, spr_elem_lst, spr_elem_lst_sz);
                set_pressed_element(selection, tile_elem_lst,
                                    tile_elem_lst_sz);
                /*set_mouse_sprite(selection->bmp); */
                mode = SPRITE_MODE;
            } else {
                selection = old_selection;
                old_selection = NULL;
            }
        } else if (point_in_rec(get_mouse_pos(), MAP_WIN)) {
            /* mouse clicked on the map! */
            parse_leftmouse_on_map();
        } else if (point_in_rec(get_mouse_pos(), SPRITE_FRW)) {
            list_elem_switch_page(1, SPRITE_WIN.y, spr_elem_lst,
                                  spr_elem_lst_sz);
        } else if (point_in_rec(get_mouse_pos(), SPRITE_REW)) {
            list_elem_switch_page(0, SPRITE_WIN.y, spr_elem_lst,
                                  spr_elem_lst_sz);
        } else if (point_in_rec(get_mouse_pos(), TILE_FRW)) {
            list_elem_switch_page(1, TILE_WIN.y, tile_elem_lst,
                                  tile_elem_lst_sz);
        } else if (point_in_rec(get_mouse_pos(), TILE_REW)) {
            list_elem_switch_page(0, TILE_WIN.y, tile_elem_lst,
                                  tile_elem_lst_sz);
        } else {
            set_mouse_sprite(NULL);
        }
    } else if (!(mouse_b & 1) && left_down) {
        /* reset mouse */
        left_down = 0;
    }
}
Ejemplo n.º 2
0
int main(){
    int grab = 0;
	int draggedImage = 0;
	
    JOGO_T *jogo = NULL;
    jogo = (JOGO_T*) malloc(sizeof(JOGO_T));
    if(!jogo) exit(1);
    
    init();
   	allegro_message("Aperte ESC para sair\nBom jogo!");
    
    novoJogo(jogo);
	while(!key[KEY_ESC]){
	    atualizaTela(jogo);
        
        if(mouse_b & 1){
           mouseClickEsquerdo(jogo, &grab, &draggedImage);
        }
        
        else if(mouse_b & 2){
           mouseClickDireito(jogo);
        }
        
        else if(grab){
           set_mouse_sprite(NULL);
           select_mouse_cursor(MOUSE_CURSOR_ARROW);
		   dropSobreArea(jogo, mouse_x, mouse_y, draggedImage);
           grab = 0;
           jogo->dragTemp = NULL;
        }
	}

	deinit();
	return 0;
}
Ejemplo n.º 3
0
//changes the mouse cursor to the tile when you click on a tile
//also changes the actual mouse xy position to the center of the tile
void CGame::DrawCursor() {
	
	CObject *object;
	CTile *tile;

	if (players[currplayer].cursor == NULL) {
		set_mouse_sprite(NULL);
		set_mouse_sprite_focus(0,0);
	}
	else{
		object = players[currplayer].cursor;
		tile = (CTile*) object;
		set_mouse_sprite((WINDOWS_BITMAP *)data[tile->GetIndex()].dat);
		set_mouse_sprite_focus(18,18);
	}
}
Ejemplo n.º 4
0
/* parse_middleclick: use this btn as disselect */
void parse_middleclick(void)
{
    if ((mouse_b & 4) && !middle_down) {
        set_pressed_element(NULL, tile_elem_lst, tile_elem_lst_sz);
        set_pressed_element(NULL, spr_elem_lst, spr_elem_lst_sz);
        /*selection = NULL; */
        set_mouse_sprite(NULL);
        middle_down = 1;
    } else if (!(mouse_b & 4) && middle_down) {
        middle_down = 0;
    }
}
Ejemplo n.º 5
0
/* set_mouse_etc:
 *  Hook for setting up the motion range, cursor graphic, etc, called by
 *  the mouse init and whenever we change the graphics mode.
 */
static void set_mouse_etc(void)
{
   if ((!mouse_driver) || (!gfx_driver))
      return;

   if ((!_mouse_pointer) || 
       ((screen) && (_mouse_pointer) &&
	(bitmap_color_depth(_mouse_pointer) != bitmap_color_depth(screen))))
      set_mouse_sprite(NULL);
   else
      hw_cursor_dirty = TRUE;

   set_mouse_range(0, 0, SCREEN_W-1, SCREEN_H-1);
   set_mouse_speed(2, 2);
   position_mouse(SCREEN_W/2, SCREEN_H/2);
}
Ejemplo n.º 6
0
/* set_mouse_etc:
 *  Hook for setting up the motion range, cursor graphic, etc, called by
 *  the mouse init and whenever we change the graphics mode.
 */
static void set_mouse_etc(void)
{
   if ((!mouse_driver) || (!gfx_driver))
      return;

   if ((!_mouse_pointer) ||
       ((screen) && (_mouse_pointer) &&
        (bitmap_color_depth(_mouse_pointer) != bitmap_color_depth(screen))))
      set_mouse_sprite(NULL);
   else
      hw_cursor_dirty = TRUE;

   set_mouse_range(0, 0, SCREEN_W-1, SCREEN_H-1);
   set_mouse_speed(2, 2);

   /* As now we support window resizing, it's not recommended to change the mouse position. */
   /*position_mouse(SCREEN_W/2, SCREEN_H/2);*/
}
Ejemplo n.º 7
0
int savecity()
{
     buffer = create_bitmap(640,480);
     
     samSong = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\savecity.wav");
     samExplosion1 = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\explosion1.wav");

     textout(buffer,font,"Save City (ESC to quit)",0,1,WHITE);

     updatescore();

//     rect(buffer, 0, 12, SCREEN_W-2, SCREEN_H-2, RED);

     city = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\city.bmp", NULL);
     for (n = 0; n < 5; n++)
         masked_blit(city, buffer, 0, 0, 20+n*120, SCREEN_H-city->h-2, city->w, city->h);

     crosshair = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\crosshair.bmp", NULL); 
     set_mouse_sprite(crosshair);
     set_mouse_sprite_focus(15,15);
     show_mouse(buffer); 
     
     play_sample(samSong, 128, 128, 1000, 1);
     
     while (!key[KEY_ESC])
     {
           //above the red was border get destroyed
           rect(buffer, 0, 12, SCREEN_W-2, SCREEN_H-2, RED);
           
           mx = mouse_x;
           my = mouse_y;
           mb = (mouse_b & 1);
     
           if (destroyed)
                firenewmissile();
     
           if (mb)
           {
                explosion1(screen,mx,my,GREEN);
                play_sample(samExplosion1, 40, 128, 1000, 0);
           }
           
           movemissile();
           
           blit(buffer,screen,0,0,0,0,640,480);
           
           if(key[KEY_BACKSPACE])
           {    
                 score=-1;        
                 firenewmissile();
                 stop_sample(samSong);

                 openscreen();        
           }
              
           if(key[KEY_ESC])
           {
                           exit(1);
           }
           
                         
           if(score>=0 && score <5)
                 rest(10);
           else if(score>=5 && score<10)
                 rest(9);            
           else if(score>=10 && score<15)
                 rest(8);            
           else if(score>=15 && score<20)
                 rest(7);            
           else if(score>=20 && score<25)
                 rest(6);            
           else if(score>=25 && score<30)
                 rest(5);            
           else if(score>=30 && score<35)
                 rest(4);            
           else if(score>=35 && score<40)
                 rest(3);
           else if(score>=40 && score<45)
                 rest(2);
           else if(score>=45)
                 rest(1);            
                                   
     }
     
     set_mouse_sprite(NULL);
     destroy_bitmap(city);
     destroy_bitmap(crosshair);
    // openscreen();
     return 0;
}
Ejemplo n.º 8
0
int save_options_proc(int msg, DIALOG *d, int c)
{
   int ret;
   int old_baud_rate;
   BITMAP *bmp;
   FILE *file;

   ret = d_button_proc(msg, d, c);

   if (ret == D_CLOSE)
   {
      old_baud_rate = comport.baud_rate;
      broadcast_dialog_message(MSG_SAVE_OPTIONS, 0);
      
      if (comport.baud_rate != old_baud_rate)
      {
         if (alert("WARNING!", "This operation may cause scan tool to stop responding.", "Are you sure you want to change the baud rate?", "Yes", "No", 0, 0) != 1)
         {
            comport.baud_rate = old_baud_rate;
            broadcast_dialog_message(MSG_REFRESH, 0);
            return D_O_K;
         }
      }

      close_comport(); // close current comport
      open_comport(); // try reinitializing comport (comport.status will be set)
      
      if ((!(display_mode & WINDOWED_MODE) && (display_mode & WINDOWED_MODE_SET)) || ((display_mode & WINDOWED_MODE) && !(display_mode & WINDOWED_MODE_SET)))
      {
         bmp = create_bitmap(SCREEN_W, SCREEN_H);
         if (bmp)
         {
            scare_mouse();
            blit(screen, bmp, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
            unscare_mouse();

            if (display_mode & WINDOWED_MODE)
            {
               if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) == 0)
                  display_mode |= WINDOWED_MODE_SET;
               else
                  display_mode &= ~WINDOWED_MODE_SUPPORTED;
            }
            else
            {
               if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0) == 0)
                  display_mode &= ~WINDOWED_MODE_SET;
               else
                  display_mode &= ~FULLSCREEN_MODE_SUPPORTED;
            }

            set_pallete(datafile[MAIN_PALETTE].dat);
            gui_fg_color = C_BLACK;  // set the foreground color
            gui_bg_color = C_WHITE;  // set the background color
            gui_mg_color = C_GRAY;   // set the disabled color
            set_mouse_sprite(NULL); // make mouse use current palette
            blit(bmp, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
            show_mouse(screen);
            destroy_bitmap(bmp);
         }
         else
            alert("Error switching display modes.", "Not enough memory to save screen.", NULL, "OK", NULL, 0, 0);
      }

      file = fopen(options_file_name, "a");

      if (file == NULL)
         alert("Options could not be saved, because file", options_file_name, "could not be open for writing", "OK", NULL, 0, 0);
      else
      {
         fclose(file);
         save_program_options();
      }
   }

   return ret;
}
Ejemplo n.º 9
0
Archivo: MOUSE.C Proyecto: kashopi/KMid
int main()
{
   int mickeyx = 0;
   int mickeyy = 0;
   BITMAP *custom_cursor;
   char msg[80];
   int c = 0;

   allegro_init();
   install_keyboard(); 
   install_mouse();
   install_timer();
   set_gfx_mode(GFX_VGA, 320, 200, 0, 0);
   set_pallete(desktop_pallete);

   do {
      /* the mouse position is stored in the variables mouse_x and mouse_y */
      sprintf(msg, "mouse_x = %-5d", mouse_x);
      textout(screen, font, msg, 16, 16, 255);

      sprintf(msg, "mouse_y = %-5d", mouse_y);
      textout(screen, font, msg, 16, 32, 255);

      /* or you can use this function to measure the speed of movement.
       * Note that we only call it every fourth time round the loop: 
       * there's no need for that other than to slow the numbers down 
       * a bit so that you will have time to read them...
       */
      c++;
      if ((c & 3) == 0)
	 get_mouse_mickeys(&mickeyx, &mickeyy);

      sprintf(msg, "mickey_x = %-7d", mickeyx);
      textout(screen, font, msg, 16, 64, 255);

      sprintf(msg, "mickey_y = %-7d", mickeyy);
      textout(screen, font, msg, 16, 80, 255);

      /* the mouse button state is stored in the variable mouse_b */
      if (mouse_b & 1)
	 textout(screen, font, "left button is pressed ", 16, 112, 255);
      else
	 textout(screen, font, "left button not pressed", 16, 112, 255);

      if (mouse_b & 2)
	 textout(screen, font, "right button is pressed ", 16, 128, 255);
      else
	 textout(screen, font, "right button not pressed", 16, 128, 255);

      if (mouse_b & 4)
	 textout(screen, font, "middle button is pressed ", 16, 144, 255);
      else
	 textout(screen, font, "middle button not pressed", 16, 144, 255);

      vsync();

   } while (!keypressed());

   clear_keybuf();

   /*  To display a mouse pointer, call show_mouse(). There are several 
    *  things you should be aware of before you do this, though. For one,
    *  it won't work unless you call install_timer() first. For another,
    *  you must never draw anything onto the screen while the mouse
    *  pointer is visible. So before you draw anything, be sure to turn 
    *  the mouse off with show_mouse(NULL), and turn it back on again when
    *  you are done.
    */
   clear(screen);
   textout_centre(screen, font, "Press a key to change cursor", SCREEN_W/2, SCREEN_H/2, 255);
   show_mouse(screen);
   readkey();
   show_mouse(NULL);

   /* create a custom mouse cursor bitmap... */
   custom_cursor = create_bitmap(32, 32);
   clear(custom_cursor); 
   for (c=0; c<8; c++)
      circle(custom_cursor, 16, 16, c*2, c);

   /* select the custom cursor and set the focus point to the middle of it */
   set_mouse_sprite(custom_cursor);
   set_mouse_sprite_focus(16, 16);

   clear(screen);
   textout_centre(screen, font, "Press a key to quit", SCREEN_W/2, SCREEN_H/2, 255);
   show_mouse(screen);
   readkey();
   show_mouse(NULL);

   destroy_bitmap(custom_cursor);

   return 0;
}
Ejemplo n.º 10
0
static void init()
{
   char temp_buf[256];

   is_not_genuine_scan_tool = FALSE;
   
   /* initialize some varaibles with default values */
   strcpy(options_file_name, "scantool.cfg");
   strcpy(data_file_name, "scantool.dat");
   strcpy(code_defs_file_name, "codes.dat");
   
   datafile = NULL;
   comport.status = NOT_OPEN;
   display_mode = 0;

   set_uformat(U_ASCII);
   
   /* initialize hardware */
   write_log("\nInitializing Allegro... ");
   allegro_init();
   write_log("OK");
   
   set_window_title(WINDOW_TITLE);
   
   write_log("\nInstalling Timers... ");
   if (install_timer() != 0)
   {
      write_log("Error!");
      fatal_error("Error installing timers");
   }
   write_log("OK");
   write_log("\nInstalling Keyboard... ");
   install_keyboard();
   write_log("OK");
   write_log("\nInstalling Mouse... ");
   install_mouse();
   write_log("OK");

   /* load options from file, the defaults will be automatically substituted if file does not exist */
   write_log("\nLoading Preferences... ");
   set_config_file(options_file_name);
   /* if config file doesn't exist or is of an incorrect version */
   if (strcmp(get_config_string(NULL, "version", ""), SCANTOOL_VERSION_STR) != 0)
   {
      /* update config file */
      remove(options_file_name);
      set_config_file(options_file_name);
      set_config_string(NULL, "version", SCANTOOL_VERSION_STR);
      load_program_options();  // Load defaults
      save_program_options();
   }
   else
      load_program_options();
   write_log("OK");

   display_mode |= FULLSCREEN_MODE_SUPPORTED;
   
   write_log("\nTrying Windowed Graphics Mode... ");
   if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) == 0)
   {
      display_mode |= WINDOWED_MODE_SUPPORTED;
      write_log("OK");
   }
   else
   {
      display_mode &= ~(WINDOWED_MODE_SUPPORTED | WINDOWED_MODE_SET);
      write_log(allegro_error);
   }

   if (!(display_mode & WINDOWED_MODE_SET))
   {
      write_log("\nTrying Full Screen Graphics Mode... ");
      if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0) == 0)
      {
         display_mode |= FULLSCREEN_MODE_SUPPORTED;
         write_log("OK");
      }
      else
      {
         display_mode &= ~FULLSCREEN_MODE_SUPPORTED;
         write_log(allegro_error);
      }
   }
   
   if (!(display_mode & (FULLSCREEN_MODE_SUPPORTED | WINDOWED_MODE_SUPPORTED)))
      fatal_error(allegro_error);
   else if ((display_mode & WINDOWED_MODE_SUPPORTED) && !(display_mode & FULLSCREEN_MODE_SUPPORTED))
   {
      set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
      display_mode &= WINDOWED_MODE_SET;
   }
   
   write_log("\nLoading Data File... ");
   packfile_password(PASSWORD);
   datafile = load_datafile(data_file_name);
   packfile_password(NULL);
   if (datafile == NULL)
   {
      sprintf(temp_buf, "Error loading %s!", data_file_name);
      write_log(temp_buf);
      fatal_error(temp_buf);
   }
   write_log("OK");

   set_pallete(datafile[MAIN_PALETTE].dat);
   font = datafile[ARIAL12_FONT].dat;
   gui_fg_color = C_BLACK;  // set the foreground color
   gui_bg_color = C_WHITE;  // set the background color
   gui_mg_color = C_GRAY;   // set the disabled color
   set_mouse_sprite(NULL); // make mouse use current palette

   write_log("\nInitializing Serial Module... ");
   serial_module_init();
   write_log("OK");

   sprintf(temp_buf, "\nOpening COM%i... ", comport.number + 1);
   write_log(temp_buf);
   /* try opening comport (comport.status will be set) */
   open_comport();
   switch (comport.status)
   {
      case READY:
         write_log("OK");
         break;

      case NOT_OPEN:
         write_log("Error!");
         break;
         
      default:
         write_log("Unknown Status");
         break;
   }
}
Ejemplo n.º 11
0
void initialize()
{
    char buf[1024];
    int i;

    // Do the libxml binary compatibility check
    initXML();

    // Initialise Allegro
    allegro_init();
    install_keyboard();
    install_mouse();
    install_timer();

    set_config_file("rpgedit.cfg");
    int grph_drv = (get_config_int("video", "fullscreen", 1)) ?
        GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED;
    int screen_w = get_config_int("video", "width", 800);
    int screen_h = get_config_int("video", "height", 600);

    if (get_config_int("tile_zoom", "grid", 1)) {
        showTileGrid = true;
    }

    set_color_conversion(
            (COLORCONV_TOTAL &
             ~(
                 COLORCONV_32A_TO_8  |
                 COLORCONV_32A_TO_15 |
                 COLORCONV_32A_TO_16 |
                 COLORCONV_32A_TO_24
              ))
            );

    int colordepth = 0;
    if (grph_drv == GFX_AUTODETECT_WINDOWED) {
        colordepth = desktop_color_depth();
    }
    if (colordepth == 0) {
        colordepth = 16;
    }
    set_color_depth(colordepth);

    if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) {
        set_color_depth(15);
        if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) {
            set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
            allegro_message("Unable to set graphic mode\n%s\n", allegro_error);
            exit(1);
        }
    }

    buffer = create_bitmap(SCREEN_W, SCREEN_H);


    // Initialize GUI look and feel stuff
    agup_init(aphoton_theme);
    gui_fg_color = agup_fg_color;
    gui_bg_color = agup_bg_color;
    gui_shadow_box_proc = d_agup_shadow_box_proc;
    gui_button_proc = d_agup_button_proc;
    gui_edit_proc = d_agup_edit_proc;
    gui_text_list_proc = d_agup_text_list_proc;

    engine_data = load_datafile("gui.dat");

    DATAFILE* font_data = find_datafile_object(engine_data, "SmallFont");
    if (font_data) font = (FONT*)font_data->dat;

    engine_font = font;

    DATAFILE* mouse_pointer = find_datafile_object(engine_data, "_MS_STD_BMP");
    if (mouse_pointer) set_mouse_sprite((BITMAP*)mouse_pointer->dat);

    DATAFILE* logo = find_datafile_object(engine_data, "MoonlightLogo");
    if (logo) about_dlg[1].dp = (BITMAP*)logo->dat;
    else console.log(CON_QUIT, CON_ALWAYS, "Error loading MoonlightLogo");

    console.log(CON_LOG, CON_ALWAYS, "Loading module \"data\"...");
    module = new Module("data");

    // Lua initialisation
    console.log(CON_LOG, CON_ALWAYS, "Initialising scripting environment...");
    initScripting();

    D_AUTOTEXT_STATUS.dp2 = status_message;
    D_AUTOTEXT_MAPINFO.dp2 = status_mapinfo;

    set_dialog_color(main_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(newmap_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(import_tileset_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(export_tileset_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(resizemap_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(about_dlg, agup_fg_color, agup_bg_color);


    // Position the dialogs on the screen
    int margin = 6;
    int zoom_w = get_config_int("tile_zoom", "zoom_width", 120) - 1;
    int zoom_h = get_config_int("tile_zoom", "zoom_height", 120) - 1;
    int x, y, w, h;

    // Main (back + menu)
    set_dialog_size(&main_dlg[0],          -2,                -2,              SCREEN_W + 4,          SCREEN_H + 4);
    set_dialog_size(&main_dlg[1],          0,                 0,               SCREEN_W,              15);

    // Status bars
    set_dialog_size(&main_dlg[6],          0,                 SCREEN_H - 17,   SCREEN_W - 256,        17);
    set_dialog_size(&main_dlg[7],          SCREEN_W - 256,    SCREEN_H - 17,   256,                   17);
    set_dialog_size(&main_dlg[8],          3,                 SCREEN_H - 14,   SCREEN_W - 262,        11);
    set_dialog_size(&main_dlg[9],          SCREEN_W - 253,    SCREEN_H - 14,   250,                   11);

    // Edit tile area
    w = zoom_w + 4;
    h = zoom_h + 4;
    x = margin;
    y = main_dlg[6].y - margin - h;
    set_dialog_size(&edit_tile_layer[0],   x,                 y,               w,                     h);
    set_dialog_size(&edit_tile_layer[1],   x + 2,             y + 2,           w - 4,                 h - 4);
    set_dialog_size(&edit_tile_layer[2],   x + margin + w,    y + h - 14,      50,                    14);

    // Color sliders
    x += w + margin;
    w = 128;
    set_dialog_size(&edit_tile_layer[8],   x,                 y,               16,                    8);
    set_dialog_size(&edit_tile_layer[9],   x,                 y + 16,          16,                    8);
    set_dialog_size(&edit_tile_layer[10],  x,                 y + 32,          16,                    8);
    set_dialog_size(&edit_tile_layer[11],  x,                 y + 48 + 8,      16,                    8);
    set_dialog_size(&edit_tile_layer[12],  x,                 y + 64 + 8,      16,                    8);
    set_dialog_size(&edit_tile_layer[3],   x + 16,            y,               w,                     8);
    set_dialog_size(&edit_tile_layer[4],   x + 16,            y + 16,          w,                     8);
    set_dialog_size(&edit_tile_layer[5],   x + 16,            y + 32,          w,                     8);
    set_dialog_size(&edit_tile_layer[6],   x + 16,            y + 48 + 8,      w,                     8);
    set_dialog_size(&edit_tile_layer[7],   x + 16,            y + 64 + 8,      w,                     8);
    set_dialog_size(&edit_tile_layer[13],  x + 16 + w + 4,    y - 1,           11,                    10);
    set_dialog_size(&edit_tile_layer[14],  x + 16 + w + 4,    y + 16 - 1,      11,                    10);
    set_dialog_size(&edit_tile_layer[15],  x + 16 + w + 4,    y + 32 - 1,      11,                    10);
    set_dialog_size(&edit_tile_layer[20],  x + 16 + w + 18,   y + 4,           18,                    32);

    // Select tile area
    x = edit_tile_layer[20].x + edit_tile_layer[20].w + margin;
    w = SCREEN_W - x - margin;
    set_dialog_size(&edit_tile_layer[16],  x,                 y,               104,                   h);
    set_dialog_size(&edit_tile_layer[17],  x + 104,           y,               w - 104,               h);
    set_dialog_size(&edit_tile_layer[18],  x + 104 + 2,       y + 2,           w - 104 - 4 - 11,      h - 4);
    set_dialog_size(&edit_tile_layer[19],  x + w - 14,        y,               14,                    h);

    // Obstacle edit stuff
    w = 24;
    h = 24;
    x = margin;
    y = main_dlg[6].y - margin - h;
    for (i = 0; i < 5; i++) {
        set_dialog_size(&edit_obstacle_layer[i],   x + i*(w+margin),     y,     w,     h);
        set_dialog_size(&edit_obstacle_layer[i+5], x + i*(w+margin) + 2, y + 2, w - 4, h - 4);
    }

    // Edit map area
    x = margin;
    y = 16 + margin;
    w = SCREEN_W - 2 * margin;
    h = edit_obstacle_layer[0].y - margin - y;
    set_dialog_size(&main_dlg[2],          x,                 y,               w,                     h);
    set_dialog_size(&main_dlg[3],          x + 2,             y + 2,           w - 15,                h - 15);
    set_dialog_size(&main_dlg[4],          x + w - 14,        y,               14,                    h - 11);
    set_dialog_size(&main_dlg[5],          x,                 y + h - 14,      w - 11,                14);
    set_dialog_size(&main_dlg[10],         x + w - 12,        y + h - 12,      10,                    10);

    // Edit objects area
    w = 160;
    h = 120;
    x = margin;
    y = main_dlg[6].y - margin - h;
    set_dialog_size(&edit_objects_layer[0], x,                y,               w,                     h);
    set_dialog_size(&edit_objects_layer[1], w + margin * 2, main_dlg[6].y - margin - 14,  97,                    14);


    // Initialize map and tile stuff
    tileRepository = new TileRepository();

    // Import tilesets specified in rpgedit.cfg
    i = 1;
    while (i > 0) 
    {
        uszprintf(buf, sizeof buf, "tileset%d", i);

        const char* filename = get_config_string(buf, "filename", NULL);
        int tile_w = get_config_int(buf, "tile_w", 16);
        int tile_h = get_config_int(buf, "tile_h", 16);
        int tile_spacing = get_config_int(buf, "tile_spacing", 0);

        if (filename) {
            if (tile_w > 0 && tile_h > 0 && tile_spacing >= 0) {
                import_tile_bitmap(filename, tile_w, tile_h, tile_spacing);
            } else {
                allegro_message("Error, incorrect parameters for automatic tile import (%s)!", filename);
                // Print warning in log file
            }
            i++;
        } else  {
            i = -1;
        }
    }

    currentMap = new SquareMap(TILES_W, TILES_H);
    ustrcpy(map_filename, "untitled.tmx");

    // Load map specified in rpgedit.cfg
    const char* filename = get_config_string("startup", "load_map", NULL);
    if (filename) {
        if (!currentMap->loadMap(filename)) {
            ustrcpy(map_filename, filename);
            object_message(&D_MAP, MSG_NEW_MAP, 0);
            set_map_changed(false);
        } else {
            console.log(CON_LOG, CON_ALWAYS,
                    "Error while loading default map (%s)!\n", filename);
        }
    }

    update_window_title();

    map_edit_mode = EM_TILE;
    menu_item_edit_objects();
    //activate_mode(edit_objects_layer);
}
Ejemplo n.º 12
0
void normalmouse::bmpstr::restore()
{
	set_mouse_sprite(original_mouse_sprite);
}
Ejemplo n.º 13
0
void normalmouse::bmpstr::set()
{
	if (newmousebmp) {
		set_mouse_sprite(newmousebmp);
	}
}
Ejemplo n.º 14
0
int main()
{
    //initialize allegro
    allegro_init();
    install_keyboard();
    install_mouse();      
    //initialize video mode to 640x480
    set_color_depth(32);
    int ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
    install_sound(DIGI_AUTODETECT, MIDI_NONE, "") ;

    pointer = load_bitmap("pointer.bmp", NULL);
    board=load_bitmap("bord.bmp",NULL);
    tiger=load_bitmap("tiger.bmp",NULL);
    goat=load_bitmap("goat.bmp",NULL);
    target=load_bitmap("target.bmp",NULL);
    buffer = create_bitmap(640,480);
    // mouse
    set_mouse_sprite(pointer);
    set_mouse_sprite_focus(15,15);
    show_mouse(screen);
    //top
    top:;
    
    count_dead_goat = 0;
    count_steps = 0;
    
    reset_bord_player();
    textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
    show_bord_player();
    turn=2;  
//background sound
        background=load_sample("background.wav");
        play_sample(background, volume, panning, pitch, TRUE);

//wait
int tempx,tempy,temp_player ;    
while (!key[KEY_ESC])
{
//grab the current mouse values
mx = mouse_x;
my = mouse_y;
mb = (mouse_b & 1);

    

 temp_player= check_location_available(getx(mx),getx(my));
if (temp_player!=3 && mb==1)
{
    if (turn==1 && temp_player==1)
    {
             textout_ex(buffer, font, "TIGER'S TURN", 480, 1, 1, -1);
              textout_ex(buffer, font, "FIND TIGER PLACE",480, 1 , white, -1);
                  tempx=getx(mx);
                  tempy=gety(my);
                turn=11;
    }
    else if(turn==11 && temp_player==0)
    {
         if(check_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
        add_tiger_player(getx(mx),gety(my));
//sound
        sound=load_sample("tiger.wav");
        play_sample(sound, volume, panning, pitch, FALSE);
        remove_player(tempx,tempy);
        turn=2;
         textout_ex(buffer, font, "FIND TIGER PLACE", 480, 1, 1, -1);
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
         }
         else if(check_jump_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
        add_tiger_player(getx(mx),gety(my));
        remove_player(tempx,tempy);
//sound
        sound=load_sample("tiger.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

        remove_player((tempx+getx(mx))/2,(tempy+gety(my))/2);
        turn=2;
         textout_ex(buffer, font, "FIND TIGER PLACE", 480, 1, 1, -1);
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
         count_dead_goat++;
         }

         
    }
    else if(turn==2  && temp_player==2 && count_steps>=20)
    {
         turn=22;
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , 1, -1);
         textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , white, -1);
                  tempx=getx(mx);
                  tempy=gety(my);

    }
    else if(turn==22 && temp_player==0)
    {
         if(check_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
//sound
        sound=load_sample("goat.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

             add_goat_player(getx(mx),gety(my));
              remove_player(tempx,tempy);
    turn=1;
         textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , 1, -1);
         textout_ex(buffer, font, "TIGER'S TURN", 480, 1, white, -1);
         }
    }
    else if(turn==2 && temp_player==0 && count_steps<20)
    {
         count_steps++;
    add_goat_player(getx(mx),gety(my));
//sound
        sound=load_sample("goat.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

    turn=1;
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , 1, -1);
         textout_ex(buffer, font, "TIGER'S TURN", 480, 1, white, -1);

    }
    if ( check_game_over()==1)
    {
         textout_ex(buffer, font, "GOAT WINS", 480, 30, white, -1);
         goto end;
         }
    else if ( check_game_over()==2)
    {
         textout_ex(buffer, font, "TIGER WINS", 480, 30, white, -1);
         goto end;
         }
    

    show_bord_player();
}
       if (turn==11)
    {     

          jump=check_possible_jump_movement(tempx,tempy);     
          move=check_possible_movement(tempx,tempy);
          show_possible_jump_movement(tempx,tempy);
          show_possible_movement(tempx,tempy);
          if( jump==0 && move==0 )
          {
          turn=1;
          textout_ex(buffer, font,"FIND TIGER PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "TIGER'S TURN",480, 1 , white, -1);
          show_bord_player();          
          }
    }
       if (turn==22)
    {
          move=check_possible_movement(tempx,tempy);
          show_possible_movement(tempx,tempy);          
          if (move==0)
          {
          turn=2;
          textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , 1, -1);
          textout_ex(buffer, font, "GOAT'S TURN", 480, 1, white, -1);
          show_bord_player();
          }

     
    }
    

/* uncheck tiget or goat to move
     if(turn==11 && mb==2)
     {  turn=1;
          textout_ex(buffer, font,"FIND TIGER PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "TIGER'S TURN",480, 1 , white, -1);
          show_bord_player();          
        }
     if(turn==22 && mb==2)
     {  turn=2;
          textout_ex(buffer, font,"FIND GOAT PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
            show_bord_player();
     }
*/


     
//pause
rest(10);
}
end:;



allegro_message("game over");    
//sound        
        sound=load_sample("clapping.wav");
        play_sample(sound, volume, panning, pitch, FALSE);
          textout_ex(screen, font, "PLAY AGAIN?(Y/N)",480, 10 , white, -1);        
while (!key[KEY_N])
{
 if(key[KEY_Y])
    goto top;
}
    set_mouse_sprite(NULL);
    destroy_sample(sound);        
    destroy_sample(background);    
    destroy_bitmap(pointer);
    destroy_bitmap(board);
    destroy_bitmap(tiger);
    destroy_bitmap(goat);
    destroy_bitmap(buffer);
    destroy_bitmap(target);
    allegro_exit();    
    return 0;
}
Ejemplo n.º 15
0
void create_cursors(BITMAP * curs, BITMAP * busy, BITMAP * flood, BITMAP * eye)
{
    if (curs != NULL)
    {
	// this is actually the default cursor for AmigaDos 2.x
	// it's a cool cursor, so i'm stealing it. ;}
	clear(curs);

	line(curs, 0, 0, 4,  9, MOUSE_COLOR_DARK);
	line(curs, 6, 7, 9, 10, MOUSE_COLOR_DARK);

	line(curs, 0, 0, 9,  4, MOUSE_COLOR_LIGHT);
	line(curs, 7, 6, 10, 9, MOUSE_COLOR_LIGHT);

	rect(curs, 2, 2, 3, 3, MOUSE_COLOR_MID);
	rect(curs, 3, 3, 5, 5, MOUSE_COLOR_MID);
	rect(curs, 6, 4, 7, 5, MOUSE_COLOR_MID);
	rect(curs, 4, 6, 5, 7, MOUSE_COLOR_MID);
	line(curs, 8, 5, 9, 5, MOUSE_COLOR_MID);
	line(curs, 5, 8, 5, 9, MOUSE_COLOR_MID);
	line(curs, 0, 0, 9, 9, MOUSE_COLOR_MID);

	// now install the new cursor, and set the hot-spot
	set_mouse_sprite(curs);
    }

    if (busy != NULL)
    {
	// make a simple busy pointer, as i can't muster the
	// thought to come up with anything better.
	clear(busy);
	text_mode (-1);
	rectfill(busy, 0, 0, 34, 11, MOUSE_COLOR_LIGHT);
	rect(busy, 0, 0, 34, 11, 1);
	textout(busy, font, "Wait", 3,3, MOUSE_COLOR_DARK);
	textout(busy, font, "Wait", 2,2, MOUSE_COLOR_MID);
    }

    if (flood != NULL)
    {
	clear(flood);

	// the spilling paint... 
	// perhaps change MOUSE_COLOR_DARK to be the color to fill with?
	line (flood, 0,5,  0,14, MOUSE_COLOR_DARK);
	line (flood, 1,4,  1,15, MOUSE_COLOR_DARK);
	line (flood, 1,4,  3,4,  MOUSE_COLOR_DARK);

	// paint can outline
	line (flood, 3,3,  6,0,  MOUSE_COLOR_MID);
	line (flood, 7,0,  13,6, MOUSE_COLOR_MID);
	line (flood, 13,7, 9,11, MOUSE_COLOR_MID);
	line (flood, 8,11, 2,5,  MOUSE_COLOR_MID);

	// paint can body
	floodfill(flood, 8,6, MOUSE_COLOR_LIGHT);

	// paint can top
	line (flood, 3,5,  7,1,  MOUSE_COLOR_MID);

	/*
	// the paint can handle
	line (flood, 7,5,  11,1, MOUSE_COLOR_DARK);
	line (flood, 7,6,  12,1, MOUSE_COLOR_DARK);
	line (flood, 8,6,  12,2, MOUSE_COLOR_DARK);
	*/

	// the hot spot -- make it brighter
	putpixel(flood, 1, 15, MOUSE_COLOR_MID);
    }

    if (eye != NULL)
    {
	clear(eye);
	// the dropper
	line(eye, 1,0,  3,0,  MOUSE_COLOR_DARK);
	line(eye, 0,1,  0,6,  MOUSE_COLOR_DARK);
	line(eye, 4,1,  4,6,  MOUSE_COLOR_DARK);
	line(eye, 0,6,  4,6,  MOUSE_COLOR_DARK);
	floodfill(eye, 2,2,   MOUSE_COLOR_DARK);
	// the vial
	line(eye, 1,7,  1,12, MOUSE_COLOR_MID);
	line(eye, 3,7,  3,12, MOUSE_COLOR_MID);
	line(eye, 2,13, 2,14, MOUSE_COLOR_MID);
	floodfill(eye, 2,8,   MOUSE_COLOR_LIGHT);
    }

    set_mouse_sprite_focus(0,0);
}
Ejemplo n.º 16
0
int main(int argc, char *argv[])
{
   int c, w, h;
   char buf[256], buf2[256];
   ANIMATION_TYPE type;

   for (c = 1; c < argc; c++) {
      if (stricmp(argv[c], "-cheat") == 0)
         cheat = TRUE;

      if (stricmp(argv[c], "-jumpstart") == 0)
         jumpstart = TRUE;
   }

   /* The fonts we are using don't contain the full latin1 charset (not to
    * mention Unicode), so in order to display correctly author names in
    * the credits with 8-bit characters, we will convert them down to 7
    * bits with a custom mapping table. Fortunately, Allegro comes with a
    * default custom mapping table which reduces Latin-1 and Extended-A
    * characters to 7 bits. We don't even need to call set_ucodepage()!
    */
   set_uformat(U_ASCII_CP);
   
   srand(time(NULL));
   if (allegro_init() != 0)
      return 1;
   install_keyboard();
   install_timer();
   install_mouse();

   if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) {
      allegro_message("Error initialising sound\n%s\n", allegro_error);
      install_sound(DIGI_NONE, MIDI_NONE, NULL);
   }

   if (install_joystick(JOY_TYPE_AUTODETECT) != 0) {
      allegro_message("Error initialising joystick\n%s\n", allegro_error);
      install_joystick(JOY_TYPE_NONE);
   }

   if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
      if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
         set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
         allegro_message("Unable to set any graphic mode\n%s\n",
                         allegro_error);
         return 1;
      }
   }

   get_executable_name(buf, sizeof(buf));
   replace_filename(buf2, buf, "demo.dat", sizeof(buf2));
   set_color_conversion(COLORCONV_NONE);
   data = load_datafile(buf2);
   if (!data) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error loading %s\n", buf2);
      exit(1);
   }

   if (!jumpstart) {
      intro_screen();
   }

   clear_bitmap(screen);
   set_gui_colors();
   set_mouse_sprite(NULL);

   if (!gfx_mode_select(&c, &w, &h))
      exit(1);

   if (pick_animation_type(&type) < 0)
      exit(1);

   init_display(c, w, h, type);

   generate_explosions();

   //stop_sample(data[INTRO_SPL].dat);

   clear_bitmap(screen);

   while (title_screen())
      play_game();

   destroy_display();

   destroy_explosions();

   stop_midi();

   set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);

   end_title();

   unload_datafile(data);

   allegro_exit();

   return 0;
}
Ejemplo n.º 17
0
int main(void)
{
	allegro_init();
	install_keyboard();
	install_mouse();
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	buffer = create_bitmap(640, 480);
	vpic[0] = load_pcx("antivirus.dat#virus_red.pcx", pal);
	vpic[1] = load_pcx("antivirus.dat#virus_yellow.pcx", NULL);
	vpic[2] = load_pcx("antivirus.dat#virus_blue.pcx", NULL);
	map = create_bitmap(8, 16);
	clear_bitmap(map);
	set_palette(pal);
	set_mouse_sprite(NULL);
	while(!done)
	{
		if(key[KEY_ESC])
		{
			done = 1;
		}
		if(key[KEY_1])
		{
			virus = 16;
		}
		else if(key[KEY_2])
		{
			virus = 17;
		}
		else if(key[KEY_3])
		{
			virus = 18;
		}
		if(key[KEY_F2])
		{
			if(file_select_ex("Save:", filename, "pcx", 1024, 320, 240))
			{
				save_pcx(filename, map, pal);
			}
			clear_keybuf();
		}
		if(key[KEY_F3])
		{
			if(file_select_ex("Load:", filename, "pcx", 1024, 320, 240))
			{
				destroy_bitmap(map);
				map = load_pcx(filename, NULL);
			}
			clear_keybuf();
		}
		mx = mouse_x;
		my = mouse_y;
		if(mouse_b & 1 && mx / 16 < 8 && my / 16 < 16)
		{
			map->line[my / 16][mx / 16] = virus;
		}
		else if(mouse_b & 2 && mx / 16 < 8 && my / 16 < 16)
		{
			map->line[my / 16][mx / 16] = 0;
		}
		clear_bitmap(buffer);
		for(int i = 0; i < 16; i++)
		{
			for(int j = 0; j < 8; j++)
			{
				if(map->line[i][j])
				{
					draw_sprite(buffer, vpic[map->line[i][j] - 16], j * 16, i * 16);
				}
			}
		}
		draw_sprite(buffer, mouse_sprite, mouse_x, mouse_y);
		blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h);
	}
	return 0;
}