Advertisement
Guest User

Game Maker game_resize

a guest
Oct 19th, 2019
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///game_resize(view,zoom)
  2. // braffolk
  3. //First of all lets check if gui width or height is not equal to window width or height , if not then let's make them equal
  4. /*
  5. view_wport[argument0] = window_get_width();
  6. view_hport[argument0] = window_get_height();
  7. view_wview[argument0] = (view_wport[argument0]/argument1);
  8. view_hview[argument0] = (view_hport[argument0]/argument1);
  9. if( surface_get_width( application_surface ) != view_wview[argument0] or surface_get_height( application_surface ) != view_hview[argument0] ){
  10.     surface_resize( application_surface , view_wview[argument0] , view_hview[argument0] );
  11.     display_set_gui_size( view_wview[argument0] , view_hview[argument0] );
  12.     return true;
  13. }
  14.  
  15. exit;*/
  16.  
  17.     var zoom = argument1;
  18.     var ww = floor(window_get_width()/zoom);
  19.     var hh = floor(window_get_height()/zoom);
  20.     if( ww = 0 or hh = 0 ){
  21.         return false;
  22.     }
  23. /*    if( window_get_width() < 640 or window_get_height() < 480 ){
  24.         window_set_size( clamp( window_get_width() , 640 , 9999 ) , clamp( window_get_height() , 480 , 9999 ) );
  25.         var ww = floor(window_get_width()/zoom);
  26.         var hh = floor(window_get_height()/zoom);
  27.     }*/
  28. if ( view_wview[ argument0 ] != ww or view_hview[ argument0 ] != hh ){
  29.     /*
  30.      * We need to save window position and size for later usage
  31.      * Because using display_reset() window size and position will be reset to what it was before.
  32.     */
  33.     /*var xx = window_get_x();
  34.     var yy = window_get_y();
  35.     var w = window_get_width();
  36.     var h = window_get_height();*/
  37.     /*
  38.      * display_reset() is the key for pixel perfect resizing
  39.      * Now we reset the display , without that it will look blurry and awful.
  40.     */
  41.     //display_reset( 0 , false );
  42.     /*
  43.      * Finally we set window size and position back to what it was before then we make view sizes and display_gui sizes equal to window sizes, and it's done!
  44.     */
  45.    
  46.     //window_set_rectangle( xx , yy , w , h );
  47.     surface_resize( application_surface , ww , hh )
  48.     view_wview[argument0] = ww;
  49.     view_hview[argument0] = hh;
  50.     view_wport[argument0] = ww*zoom;
  51.     view_hport[argument0] = hh*zoom;
  52.     display_set_gui_size( ww , hh );
  53.    
  54.     //display_reset( 0 , false );
  55.    
  56.     return true;
  57.    
  58. }
  59.  
  60. return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement