Advertisement
lalaladoomsday

hyuponia's simple music select template

Jul 15th, 2020
4,132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //hyuponia's simple music select template v1.2
  2. //this goes in draw_hud.gml
  3.  
  4. //this simple system allows you to select music with Right Stick while the match is starting.
  5. //no need to rely on random music and waiting until the music you want comes on anymore!!
  6.  
  7. /* the only things you have to alter */
  8.  
  9.  
  10.  
  11. var music_files, music_titles;
  12.  
  13. //music file name, in your /sounds folder
  14. //if you want to keep it empty, keep the placeholder name and it will disallow selecting that music
  15. music_files = ["MUSIC_FILE_NAME_HERE", "MUSIC_FILE_NAME_HERE", "MUSIC_FILE_NAME_HERE", "MUSIC_FILE_NAME_HERE"]
  16.  
  17. //music name title
  18. music_titles = ["put music title here", "put music title here", "put music title here", "put music title here"]
  19.  
  20.  
  21. //confirmation sound to play when music has been changed
  22. //sound_get and asset_get both works here.
  23. var confirm_sound = asset_get("mfx_player_ready");
  24.  
  25. //title name bar position
  26. //false for below GO, true for above GO
  27. //change when the bar overlaps the players at intial spawn point
  28. var music_bar_above = true;
  29.  
  30. //accent line color: optional
  31. //make it match one of your stage colors for best effect
  32. var music_line_color = make_color_rgb(180,180,180);
  33.  
  34. //bg color: very optional
  35. //for if black bg is hard to see in your stage or something
  36. var music_bg_color = make_color_rgb(0,0,0);
  37.  
  38. //text color: very optional
  39. //for when you chose white bg or something
  40. var music_txt_color = make_color_rgb(255,255,255);
  41.  
  42.  
  43.  
  44. /* below is code, don't alter unless you know what you're doing */
  45. /* big thank you to Delta Parallax for optimizing this code (and the code above) !! */
  46.  
  47. if (!variable_instance_exists(id, "mus_phase"))
  48. {
  49.     mus_phase = 0;
  50.     mus = 0;
  51.     mus_timer = 0;
  52. }
  53.  
  54. var placeholder_name = "MUSIC_FILE_NAME_HERE";
  55.  
  56. if (get_gameplay_time() <= 122 && mus_phase == 0)
  57. {
  58.     with (asset_get("oPlayer"))
  59.     {
  60.         var conditions;
  61.         conditions = [left_stick_down, right_stick_down, up_stick_down, down_stick_down];
  62.         for (var m = 0; m < array_length_1d(conditions); m++)
  63.         {
  64.             if (conditions[m] && music_files[m] != placeholder_name)
  65.             {
  66.                 other.mus = m;
  67.                 other.mus_phase = 1;
  68.                 break;
  69.             }
  70.         }
  71.     }
  72.    
  73.     if (mus_phase == 1)
  74.     {
  75.         sound_play(confirm_sound)
  76.     }
  77. }
  78.  
  79. if (get_gameplay_time() > 125 && mus_phase == 1){
  80.     music_play_file(music_files[mus]);
  81.     mus_phase = 2;
  82.     mus_timer = 0;
  83. }
  84.  
  85. var tw1, tw2, bh, vw;
  86. tw1 = 0;
  87. tw2 = 0;
  88. bh = (music_bar_above)?130:330;
  89. vw = view_get_wview();
  90.  
  91.  
  92. if (mus_phase != 0 and mus_phase != 3)
  93. {
  94. mus_timer++;
  95.     tw1 = (mus_phase == 1) ? ease_quartOut(0, 1, clamp(mus_timer,0,40), 40) : ease_quartIn(1, 0, clamp(mus_timer,0,30), 30);
  96.     tw2 = (mus_phase == 1) ? ease_quartOut(0, 30, clamp(mus_timer,0,40), 40) : ease_quartIn(30, 60, clamp(mus_timer,0,30), 30);
  97.     draw_set_alpha(tw1/2);
  98.     draw_rectangle_colour(0, bh, vw, bh+40, music_bg_color, music_bg_color, music_bg_color, music_bg_color, false);
  99.     draw_set_alpha(tw1);
  100.     draw_rectangle_colour(0, bh+4, vw, bh+5, music_line_color, music_line_color, music_line_color, music_line_color, false);
  101.        
  102.     mus_name = music_titles[mus];
  103.        
  104.     draw_set_font(asset_get("fName"));
  105.     draw_text_ext_transformed_colour(30+tw2, bh+15, "Music Selected: "+mus_name, 1, 1000, 1, 1, 0, music_txt_color, music_txt_color, music_txt_color, music_txt_color, tw1);
  106.     draw_set_alpha(1);
  107.    
  108.     mus_phase = (mus_timer > 30 and mus_phase == 2) ? 3 : mus_phase;
  109.    
  110. }
  111.  
  112. //music select template end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement