home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 July / Disc 2 / PCU0703CD2.iso / entertn / demos / files / ron.exe / scenario / screenshot.bhs < prev    next >
Encoding:
Text File  |  2003-04-29  |  3.5 KB  |  136 lines

  1.  
  2.  
  3. int scenario snap_screenshot( ref int center_screen_x, ref int center_screen_y, 
  4.                               ref int delta_horiz_x,   ref int delta_horiz_y, 
  5.                               ref int delta_vert_x,    ref int delta_vert_y,
  6.                               ref int num_x,           ref int num_y )
  7. {
  8.   scrolling_lock();
  9.   zooming_lock();
  10.   ui_hide();
  11.  
  12.   xs = world_x_size();
  13.   ys = world_y_size();
  14.  
  15.   x_min_x = 0;
  16.   x_min_y = 0;
  17.   x_max_x = 0;
  18.   x_max_y = 0;
  19.   y_min_x = 0;
  20.   y_min_y = 0;
  21.   y_max_x = 0;
  22.   y_max_y = 0;
  23.   x_center = 0;
  24.   y_center = 0;
  25.   first_eval = true;
  26.  
  27.   for( x = 0; x < xs; x++ ) {
  28.     for( y = 0; y < ys; y++ ) {
  29.       if( is_on_screen( x, y ) ) {
  30.         if( !first_eval ) {
  31.           if( x < x_min_x )  { x_min_x = x; x_min_y = y; } 
  32.           if( x > x_max_x )  { x_max_x = x; x_max_y = y; }
  33.           if( y < y_min_y )  { y_min_x = x; y_min_y = y; }
  34.           if( y > y_max_y )  { y_max_x = x; y_max_y = y; }
  35.         } else {
  36.           x_min_x = x;
  37.           x_min_y = y;
  38.           x_max_x = x;
  39.           x_max_y = y;
  40.           y_min_x = x;
  41.           y_min_y = y;
  42.           y_max_x = x;
  43.           y_max_y = y;
  44.           first_eval = false;
  45.         }
  46.       }
  47.     }
  48.   }
  49.  
  50.   delta_horiz_x = y_min_x - x_min_x;
  51.   delta_horiz_y = y_min_y - x_min_y;
  52.  
  53.   delta_vert_x  = y_max_x - x_min_x;
  54.   delta_vert_y  = y_max_y - x_min_y;
  55.  
  56.   center_screen_x = camera_x();
  57.   center_screen_y = camera_y();
  58.  
  59.   return 1;
  60. }
  61.  
  62.  
  63. scenario {
  64.   static int taking_screenshots = 0;
  65.   static int center_screen_x = 0;
  66.   static int center_screen_y = 0;
  67.   static int delta_horiz_x   = 0;
  68.   static int delta_horiz_y   = 0;
  69.   static int delta_vert_x    = 0;
  70.   static int delta_vert_y    = 0;
  71.   static int num_x = 3;
  72.   static int cur_x = 0;
  73.   static int num_y = 3;
  74.   static int cur_y = 0;
  75.   static int max_screen_shot_size = 5;
  76.   static string screenshot_name = "wide_screenshot_";
  77.  
  78.   run_once {
  79.     print_game_msg("*Wide Screenshot Loaded*");
  80.     print_game_msg("- Press '1' to take the screenshot");
  81.     print_game_msg("- Press '2' to cycle through the size options");
  82.   }
  83.  
  84.   trigger take_picture( key_down("1")) {
  85.     taking_screenshots = 1;
  86.     clear_game_msg();
  87.     snap_screenshot( center_screen_x, center_screen_y, delta_horiz_x, delta_horiz_y, delta_vert_x, delta_vert_y, num_x, num_y );
  88.   }
  89.  
  90.   trigger set_dimensions( key_down("2") && !taking_screenshots ) {
  91.     if( num_x <= max_screen_shot_size ) {
  92.       num_x++;
  93.     } else {
  94.       num_y++;
  95.       num_x = 1;
  96.       if( num_y > max_screen_shot_size ) {
  97.         num_x = 2;
  98.         num_y = 1;
  99.       }
  100.     }
  101.   
  102.     dimensions = "x";
  103.     dimensions = num_x + dimensions;
  104.     dimensions = dimensions + num_y;
  105.  
  106.     clear_game_msg();
  107.     print_game_msg(dimensions);
  108.     enable_trigger("set_dimensions");
  109.   }
  110.  
  111.   trigger snap_shot( taking_screenshots ) {
  112.     string cur_screenshot = screenshot_name + cur_x;
  113.     cur_screenshot = cur_screenshot + cur_y;
  114.     take_screenshot( cur_screenshot );
  115.  
  116.     cur_x = cur_x + 1;
  117.     if( cur_x >= num_x ) {
  118.       cur_y = cur_y + 1;
  119.       cur_x = 0;
  120.     }
  121.  
  122.     if( cur_y < num_y ) {
  123.       new_camera_x = center_screen_x + delta_horiz_x * cur_x + delta_vert_x * cur_y;
  124.       new_camera_y = center_screen_y + delta_horiz_y * cur_x + delta_vert_y * cur_y;
  125.       jump_camera( new_camera_x, new_camera_y );
  126.       enable_trigger("snap_shot");
  127.     } else {
  128.       taking_screenshots = 0;
  129.       print_game_msg("Screenshot complete.");
  130.       scrolling_unlock();
  131.       zooming_unlock();
  132.       ui_show();
  133.     }
  134.   }
  135. }
  136.