devonhg

scr_FullWindow

May 19th, 2015
471
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///scrFullWindow(Height, Scale)
  2.  
  3. /*
  4. setHeight = Set the height for your game, the width is determined automatically based on
  5. monitor.
  6.  
  7. setScale = How large you wish to scale the game. Set to 0 for auto scaling to fill monitor.
  8.  
  9. Set SetScale to 0 for automatic scaling as high as possible while keeping it an even number
  10.  
  11. MUST BE PUT IN THE ROOM START EVENT!
  12. */
  13.  
  14. //Variables
  15. var setHeight = argument[0],
  16.     setScale = argument[1],
  17.     dispW = display_get_width(),
  18.     dispH = display_get_height(),
  19.     ratVal = dispW/dispH,
  20.     H = floor(setHeight),
  21.     W = floor( setHeight*ratVal );
  22.    
  23. //View properties
  24.     view_visible[0] = true;
  25.     view_enabled = true;
  26.     view_hview[0] = H;
  27.     view_wview[0] = W;
  28.    
  29. //Decide how we are going to scale this.
  30.     if setScale = 0{
  31.         var scaleTo = floor(dispH/H);
  32.         view_wport[0] = W*scaleTo;
  33.         view_hport[0] = H*scaleTo;
  34.         window_set_size(view_wport[0], view_hport[0]);
  35.         window_set_position((dispW-view_wport[0])/2,(dispH-view_hport[0])/2);
  36.     }else{
  37.         view_wport[0] = (H*setScale);
  38.         view_hport[0] = (W*setScale);  
  39.         window_set_size(view_wport[0],view_hport[0]);
  40.         window_set_position((dispW-view_wport[0])/2,(dispH-view_hport[0])/2);                
  41.     }
  42.        
  43.     surface_resize(application_surface, view_wport[0],view_hport[0]);
Advertisement
Add Comment
Please, Sign In to add comment