SHARE
TWEET

Simple Responsive Tools

devonhg Aug 3rd, 2018 (edited) 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     To learn more about this code, watch my video:
  3.     https://www.youtube.com/watch?v=0ekoEYnqAe4
  4.    
  5. */
  6.  
  7.  
  8.  
  9. /*
  10. ================================================
  11. =================Objects========================
  12. ================================================
  13. */
  14.  
  15.     /*
  16.     ================================================
  17.     =================obj_alert======================
  18.     ================================================
  19.     */
  20.  
  21.     //Create Event
  22.         alert_title = "Alert";
  23.         alert_description = "You broke something, please report to developer.";
  24.         can_destroy = false;
  25.         alarm[0] = 10;
  26.  
  27.     //Alarm0 Event
  28.         can_destroy = true;
  29.  
  30.     //Draw Event
  31.         draw_set_color(c_white);
  32.         draw_set_halign( fa_center );
  33.         draw_set_valign( fa_middle );
  34.  
  35.             //Draw Base Box
  36.                 draw_rectangle( responsive_x(.5), responsive_y( 4 ), responsive_x( 11.5 ), responsive_y(4)+100, false );
  37.  
  38.             //Set up a breakpoint
  39.                 var _bp = 0;
  40.                 if( camera_get_view_width(view_camera[view_current]) < 300 ){
  41.                     _bp = -.1;
  42.                 }
  43.  
  44.             //Draw the content
  45.                 draw_set_color( c_black);
  46.                 draw_line_width( responsive_x( .5 )-1, responsive_y(4.8), responsive_x( 11.5 ), responsive_y(4.8), 3 );
  47.                 responsive_text( responsive_x( 6 ), responsive_y( 4 )+15, alert_title, responsive_y(.5 + _bp), responsive_x(10), c_black );
  48.                 responsive_text( responsive_x( 6 ), responsive_y( 4 )+50, alert_description, responsive_y(.4 + _bp), responsive_x(10), c_black );
  49.                 responsive_text( responsive_x( 6 ), responsive_y( 4 )+85, "Press any key to continue", responsive_y(.4 + _bp), responsive_x(10), c_black );
  50.  
  51.         draw_set_color( -1 );
  52.         draw_set_halign( -1 );
  53.         draw_set_valign( -1 );
  54.        
  55.     //Key Press Any Event
  56.         if( can_destroy ){
  57.             instance_destroy();
  58.         }
  59.  
  60.        
  61. /*
  62. ================================================
  63. =================Scripts========================
  64. ================================================
  65. */
  66.  
  67.     /*
  68.     ===================================================
  69.     =================responsive_x======================
  70.     ===================================================
  71.     */
  72.  
  73.     ///@description Get the x value at the width fraction, 12 base.
  74.     ///@param fraction 1-12 as to what fraction to use.
  75.  
  76.     var scrn_w = camera_get_view_width(view_camera[view_current ]);//Screen width
  77.     var scrn_x = camera_get_view_x(view_camera[view_current]);
  78.     var scrn_fract = scrn_w / 12;
  79.  
  80.     return scrn_x + (scrn_fract * argument[0]);
  81.  
  82.  
  83.     /*
  84.     ===================================================
  85.     =================responsive_y======================
  86.     ===================================================
  87.     */
  88.  
  89.     ///@description Get the y value at the height fraction, 12 base.
  90.     ///@param fraction 1-12 as to what fraction to use.
  91.  
  92.     var scrn_h = camera_get_view_height(view_camera[view_current]);//Screen width
  93.     var scrn_y = camera_get_view_y(view_camera[view_current]);
  94.     var scrn_fract = scrn_h / 12;
  95.  
  96.     return scrn_y + (scrn_fract * argument[0]);
  97.  
  98.  
  99.     /*
  100.     ======================================================
  101.     =================responsive_text======================
  102.     ======================================================
  103.     */
  104.  
  105.     ///@description Using this script draw text that dynamically scales with the screen
  106.     ///@param X The x position of the text
  107.     ///@param Y The y position of the text
  108.     ///@param Text The string position of the text
  109.     ///@param heightPerLine The height in pixels to scale the text to, per line
  110.     ///@param width The width in pixels to restrain the text to
  111.     ///@param color The color of the text
  112.  
  113.     var _width = camera_get_view_width(view_camera[view_current]);
  114.     var _str_height = string_height(argument[2]);
  115.     var _scale = argument[3]/_str_height;
  116.     var _sep = _str_height;
  117.  
  118.     draw_text_ext_transformed_color(
  119.         argument[0],
  120.         argument[1],
  121.         argument[2],
  122.         _sep,
  123.         argument[4] / _scale,
  124.         _scale,
  125.         _scale,
  126.         0,
  127.         argument[5],
  128.         argument[5],
  129.         argument[5],
  130.         argument[5],
  131.         1
  132.     );
  133.  
  134.  
  135.  
  136.     /*
  137.     ================================================
  138.     =================scr_alert======================
  139.     ================================================
  140.     */
  141.  
  142.     ///@description Create an alert message, companion to obj_alert
  143.     ///@param Message The message to show in the alert
  144.     ///@param *Title Optionally, modify the title
  145.  
  146.     show_debug_message( "===scr_alert: Initating Message: " + argument[0] );
  147.  
  148.     var title = "";
  149.  
  150.     if( argument_count > 1 ){
  151.         title = argument[1];
  152.     }
  153.  
  154.     if( !instance_exists( obj_alert ) ){
  155.         var messagebox = instance_create_depth(0,0,0, obj_alert);
  156.        
  157.         if( title != "" ) messagebox.alert_title = argument[1];
  158.         messagebox.alert_description = argument[0];
  159.     }else{
  160.         show_debug_message( "===scr_alert: Message already running!" );
  161.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top