Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. ///Text
  2.  
  3. //t is for modifiers
  4. t++;
  5.  
  6. //Set Font
  7. draw_set_font(f_chat);
  8.  
  9. //Set Colour
  10. draw_set_colour(c_white);
  11.  
  12. //Read in array length
  13. message_end = array_length_1d(message);
  14.  
  15. //If there are messages
  16. if (message_end > 0)
  17. {
  18. //Draw chat box
  19. draw_sprite(spr_chatbox, 0, window_get_width()/2, window_get_height()-sprite_get_height(spr_chatbox) - 5);
  20. //Draw Portrait
  21. if (portrait != "none") draw_sprite(portrait, 0, window_get_width()/2 - (sprite_get_width(spr_chatbox)/2) + ((sprite_get_height(spr_chatbox) - sprite_get_height(spr_portrait))/2), window_get_height()- sprite_get_height(spr_chatbox) + ((sprite_get_height(spr_chatbox) - sprite_get_height(spr_portrait))/2));
  22.  
  23. //This is for the effects
  24. var modifier = 0;
  25. //Character Width
  26. var charWidth = 14;
  27. //How many characters allowed in each line
  28. if (portrait == "none") var lineEnd = 44;
  29. else var lineEnd = 43;
  30. //Variables for spacing characters
  31. var line = 0;
  32. var space = 0;
  33. var i = 1;
  34. //Delay time between printing each character
  35. var delay = 0;
  36.  
  37. //Text Position
  38. var tY = window_get_height()- sprite_get_height(spr_chatbox) + padding_y;
  39. //Change the horizontal position if there is a portrait
  40. if (portrait == "none") var tX = (window_get_width()/2) -(sprite_get_width(spr_chatbox)/2) + padding;
  41. else var tX = (window_get_width()/2) -(sprite_get_width(spr_chatbox)/2) + padding + ((sprite_get_height(spr_portrait))/2);
  42. //If we are done printing out the current message
  43. if (cutoff == string_length(message[message_current]))
  44. {
  45. //draw blinking cursor
  46. timer+= 1;
  47. if (timer < 15) draw_sprite(spr_cursor, 0, (window_get_width()/2) + (sprite_get_width(spr_chatbox)/2) -15, window_get_height()-15);
  48. if (timer > 30) timer = 0;
  49.  
  50. //Check player input
  51. if (keyboard_check_pressed(vk_space) || gamepad_button_check_pressed(0, gp_face1))
  52. {
  53. //If we still have messages left, go to next message
  54. if (message_current < message_end-1)
  55. {
  56. message_current++;
  57. cutoff = 0;
  58. }
  59. //If we dont, make done = true and destroy this object
  60. else
  61. {
  62. timer = 0;
  63. done = true;
  64. }
  65. }
  66. }
  67.  
  68. //Typewriter
  69. //This is so we print each character one at a time
  70. if (cutoff < string_length(message[message_current]))
  71. {
  72. if (timer >= delay)
  73. {
  74. if(!audio_is_playing(so_chat)) audio_play_sound(so_chat, 10, false);
  75. cutoff++;
  76. timer = 0;
  77. }
  78. else timer++;
  79. }
  80.  
  81. //Text
  82. while(i <= string_length(message[message_current]) && i <= cutoff)
  83. {
  84. //check for modifier
  85. if (string_char_at(message[message_current], i) == "\")
  86. {
  87. modifier = real(string_char_at(message[message_current], ++i));
  88. ++i;
  89. }
  90.  
  91. //Go to next line
  92. //Check if the current word fits inside the text box, and if not we go to the next line
  93. var length = 0;
  94. while (string_char_at(message[message_current], i) != " " && i <= string_length(message[message_current]))
  95. {
  96. i++;
  97. length++;
  98. }
  99.  
  100. if (space+length > lineEnd)
  101. {
  102. space = 0;
  103. line++;
  104. }
  105. i -= length;
  106.  
  107. var sp = 18
  108. //Draw Text
  109. switch(modifier)
  110. {
  111.  
  112. case 0: //normal
  113. {
  114. draw_set_colour(c_white);
  115. draw_text(tX+(space*charWidth), tY+(sp*line), string_char_at(message[message_current], i));
  116. break;
  117. }
  118. case 1: //shaky
  119. {
  120. draw_set_colour(c_white);
  121. draw_text(tX+(space*charWidth)+random_range(-1, 1), tY+(sp*line)+random_range(-1, 1), string_char_at(message[message_current], i));
  122. break;
  123. }
  124. case 2: //color
  125. {
  126. draw_set_colour(c_lime);
  127. draw_text(tX+(space*charWidth), tY+(sp*line), string_char_at(message[message_current], i));
  128. break;
  129. }
  130. case 3: //color and shake
  131. {
  132. draw_set_colour(c_lime);
  133. draw_text(tX+(space*charWidth)+random_range(-1, 1), tY+(sp*line)+random_range(-1, 1), string_char_at(message[message_current], i));
  134. break;
  135. }
  136. case 4: //Sine movement
  137. {
  138. var so = t + i;
  139. var shift = sin(so*pi*freq/room_speed)*amplitude;
  140. draw_set_colour(c_white);
  141. draw_text(tX+(space*charWidth), tY+(sp*line)+shift, string_char_at(message[message_current], i));
  142. break;
  143. }
  144. case 5: //Gradient Text
  145. {
  146. draw_set_colour(make_colour_hsv(t+i, 255, 255));
  147. draw_text(tX+(space*charWidth), tY+(sp*line), string_char_at(message[message_current], i));
  148. break;
  149. }
  150. case 6: //Gradient & Sine
  151. {
  152. draw_set_colour(make_colour_hsv(t+i, 255, 255));
  153. var so = t + i;
  154. var shift = sin(so*pi*freq/room_speed)*amplitude;
  155. draw_text(tX+(space*charWidth), tY+(sp*line)+shift, string_char_at(message[message_current], i));
  156. break;
  157. }
  158. }
  159.  
  160. //Move to next character
  161. space++;
  162. i++;
  163. }
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement