Advertisement
devonhg

scr_init_camera

Jun 28th, 2018
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///@param X The x location to initiate the view
  2. ///@param Y The y location to initiate the view
  3. ///@param Wview The width of the view
  4. ///@param Hview The height of the view
  5. ///@param *Scale how large to scale the port, 1 by default
  6. ///@param *Obj The object to follow
  7.  
  8. /*
  9.     This script initiates a global called global.cam. Using this global you can manipulate the camera.
  10.    
  11.     Ideally, put this script in the "room_start" event.
  12.  
  13.     Learn more about this script here: https://www.youtube.com/watch?v=2Jbaf2qfmy4
  14. */
  15. #region Set our variables
  16.     var scale = 1;
  17.     var obj = -1;
  18.     var view_index = 0;
  19.  
  20.     var xx = argument[0];
  21.     var yy = argument[1];
  22.     var wview = argument[2];
  23.     var hview = argument[3];
  24.     var wport = wview;
  25.     var hport = hview;
  26.  
  27.     if argument_count > 4 scale = argument[4];
  28.     if argument_count > 5 obj = argument[5];
  29. #endregion
  30.  
  31. #region Handle our view
  32.     if !view_enabled{ view_enabled = true; }
  33.     view_set_visible(view_index, true);
  34.     view_set_wport(view_index, wport);
  35.     view_set_hport(view_index, hport);
  36. #endregion
  37.  
  38. #region Create and Set Our Camera
  39.     if( variable_global_exists("cam") ){ camera_destroy( global.cam ); }
  40.     global.cam = camera_create_view(0,0,wport,hport,0,obj,-1,-1,0,0);
  41.     view_camera[view_index] = global.cam;
  42. #endregion
  43.  
  44. #region Set our Window and App Surface
  45.     window_set_rectangle(
  46.         (display_get_width() - view_wport[view_index] * scale) * .5,
  47.         (display_get_height() - view_hport[view_index] * scale ) * .5,
  48.         view_wport[view_index]* scale,
  49.         view_hport[view_index]* scale
  50.     );
  51.     surface_resize(application_surface, view_wport[view_index] * scale, view_hport[view_index] * scale);
  52. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement