Guest User

Untitled

a guest
Dec 9th, 2017
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.35 KB | None | 0 0
  1. =begin
  2.  ______________________
  3. <  wiggly text          │
  4.  │ by tuckie            │
  5.  │                      │
  6.  │ 7/7/17 woa lucky     │
  7.  │ Version: pretty done │
  8.  │______________________│
  9.  
  10.        ______________
  11. (-o-)< hi there!!👋 │
  12.       │_____________│
  13.  
  14.  __________________________________________
  15. <                                           │
  16.  │ uhh hi this lets you animate text〰️〰️〰️〰️ │
  17.  │                  pretty cool             │
  18.  │ i like credit link to my twitter         │
  19.  │ @plsvotetuckie  in the credit.txt        │
  20.  │ or website(tell ur fans to give me $100) │
  21.  │ tuckie.zone thank you i love yuo ❤️      │
  22.  │__________________________________________│
  23.  
  24. =end
  25.  
  26. #==============================================================================
  27. # how2use this scripty boy                                              _ ⬜ ❎
  28. #==============================================================================
  29. # Triggering animations is done via tags in the message window.
  30. #
  31. # Simply add a \ani[0-9] to pick the animation you want, and all text after will
  32. # be animated. If a new text box appears the animation will stop. You can
  33. # manually end animation with a \stop or \ani[7].
  34. #
  35. #-R/-\|NB0\^/-------------------------------------------------------------------
  36. # Much like an animation, you can turn on a rainbow effect with \ran . You can
  37. # turn off the rainbow and animation with \off but \bln will turn off only the
  38. # rainbow effect.
  39. #
  40. #==============================================================================
  41.  
  42. #==============================================================================
  43. # ** SETTINGS | hi im tuckie please tell your players i made this       _ ⬜ ❎
  44. #==============================================================================
  45.  
  46. module WiggleText
  47.  
  48.   # Characters 'drop in' when first drawn. 👇
  49.   DROP_IN     = true
  50.   # Height from where characters drop.
  51.   DROP_HEIGHT = 8
  52.  
  53.   # Enable or disable hitting a button to skip drawing characters one-by-one.
  54.   # true means players can skip, false means they can't.
  55.   SKIP_CHAR   = true
  56.  
  57.   # do /nam[number] to make a nametag box with that specific name
  58.   NAMES = [
  59.       "that guy", #0 🔥🔥🔥🔥🔥🔥🔥
  60.       "that other guy",   #1
  61.       "a jerk", #2 etc
  62.   ]
  63.   #the filename of the background for the nametag sprite, place in Graphics/System
  64.   NAME_SPRITE = "Nametag"
  65.  
  66.   # creature comfort feature: If you have a bunch of text codes (nametag, color
  67.   # sound effect, etc) that you need to have at the start of a message make them
  68.   # on line one, and use the text code \lin . this will "reset" the text height
  69.   # so line two is higher up. adjust the height to fit your font with this
  70.   # variable. Measurement in pixels.
  71.   LINE_HEIGHT = 16
  72. end
  73.  
  74. #==============================================================================
  75. # ** Sprite_TextAnim                                                    _ ⬜ ❎
  76. #------------------------------------------------------------------------------
  77. #  Sprite subclass for text animations.
  78. #==============================================================================
  79.  
  80. class Sprite_TextAnim < Sprite
  81.  
  82.   attr_accessor :anim_offset
  83.   attr_accessor :anim_type
  84.   attr_accessor :rainbow
  85.   attr_accessor :rainbow_offset
  86.   attr_accessor :drop
  87.   @timer      = false
  88.   attr_accessor :galv_ani
  89.  
  90.   def drop()
  91.     if WiggleText::DROP_IN
  92.       @drop -= @drop * 0.1
  93.       if @drop < 0
  94.         @drop = 0
  95.       end
  96.       return @drop
  97.     else
  98.       return 0
  99.     end
  100.   end
  101.  
  102.   def ani
  103.       @galv_ani += 0.015
  104.   end
  105.  
  106.   def update
  107.     return unless @anim_offset
  108.  
  109.     if @rainbow
  110.       @rainbow_offset += 0.03
  111.       self.color = Color.new(128 + Math.sin(@rainbow_offset) * 127,
  112.         128 + Math.sin(@rainbow_offset + 2*Math::PI/3) * 127,
  113.         128 + Math.sin(@rainbow_offset + 4*Math::PI/3) * 127,
  114.         255)
  115.     end
  116.     case @anim_type
  117.       when 1
  118.         @anim_offset += 0.115
  119.         self.oy = Math.sin(@anim_offset) * 3 + drop()
  120.         ani()
  121.       when 2
  122.         @anim_offset += 0.2
  123.         self.ox = Math.sin(@anim_offset) * 3
  124.         self.oy = Math.cos(@anim_offset) * -3 + drop()
  125.         ani()
  126.       when 3
  127.         @anim_offset += 0.15
  128.         self.zoom_x = 1 + Math.sin(@anim_offset) * 0.2
  129.         self.zoom_y = 1 + Math.cos(@anim_offset) * 0.2
  130.         self.oy = drop()
  131.         ani()
  132.       when 4
  133.         @anim_offset += 1
  134.         rand = 0
  135.         if @anim_offset % 8 == 0
  136.           rand = 4
  137.           self.ox = rand(rand) - rand(rand)
  138.           self.oy = rand(rand) - rand(rand) + drop()
  139.         end
  140.         ani()
  141.       when 5
  142.         @anim_offset += 0.1
  143.         sample  = Math.sin(@anim_offset) * 5
  144.         self.oy = sample.abs + drop()
  145.         ani()
  146.       when 6
  147.         @anim_offset += 0.1
  148.         self.ox = Math.sin(@anim_offset) * 3
  149.         self.oy = Math.cos(@anim_offset) * -2 + drop()
  150.         self.angle = Math.sin(@anim_offset * 0.5) * 10
  151.         ani()
  152.       when 7
  153.         #no animation
  154.         self.oy = drop()
  155.         ani()
  156.       when 8
  157.         @anim_offset += 0.1
  158.         self.ox = Math.sin(@anim_offset) * 3
  159.         self.oy = Math.cos(@anim_offset) * -2 + drop()
  160.         self.angle = Math.sin(@anim_offset) * 10
  161.       when 9
  162.         @anim_offset += 0.15
  163.         self.zoom_x = 2
  164.         self.zoom_y = 2
  165.         self.oy = Math.sin(@anim_offset / 2) * -4 + drop()
  166.       when 10
  167.         @anim_offset += 0.085
  168.         self.oy = Math.sin(@anim_offset / 2) * 3 + drop() + 2
  169.       else
  170.         return
  171.     end
  172.   end
  173.  
  174. end
  175.  
  176. #==============================================================================
  177. # ** Window_Message                                                     _ ⬜ ❎
  178. #------------------------------------------------------------------------------
  179. #  This message window is used to display text.
  180. #==============================================================================
  181.  
  182. class Window_Message < Window_Base
  183.  
  184.   #--------------------------------------------------------------------------
  185.   # * Window_Message Creation | Alias
  186.   #--------------------------------------------------------------------------
  187.   alias tuckie_wiggly_initialize initialize
  188.   def initialize
  189.     tuckie_wiggly_initialize
  190.     @animchars = []
  191.     @rainbow = false
  192.     @anim_offset = 0
  193.   end
  194.  
  195.   #--------------------------------------------------------------------------
  196.   # * Normal Character Processing | Overwrite
  197.   #--------------------------------------------------------------------------
  198.   def process_normal_character(c, pos)
  199.     if @anim_type && @anim_type > 0
  200.       process_anim_character(c, pos)
  201.     else
  202.       if WiggleText::DROP_IN
  203.         @anim_type = 7
  204.         process_anim_character(c, pos)
  205.       else
  206.         super
  207.       end
  208.     end
  209.     wait_for_one_chaaracter
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # * Animated Character Processing | New Method
  213.   #--------------------------------------------------------------------------
  214.   def process_anim_character(c, pos)
  215.     text_width = text_size(c).width
  216.     if defined? Graphics.fullscreen #MKXP fix
  217.       text_width += text_width * 0.6
  218.       text_width = text_width.round
  219.     end
  220.     letter = Sprite_TextAnim.new(self.viewport)
  221.     bitmap = Bitmap.new(text_width, pos[:height])
  222.     bitmap.font = self.contents.font
  223.     letter.bitmap = bitmap
  224.     letter.x = pos[:x] + self.standard_padding + 9
  225.     letter.y += WiggleText::DROP_HEIGHT if WiggleText::DROP_IN
  226.     letter.y = self.y + standard_padding + pos[:y]
  227.     letter.z = self.z + 10
  228.     letter.anim_offset = @animchars.size
  229.     letter.anim_type = @anim_type
  230.     tuckie_extra(letter)
  231.     letter.update
  232.     bitmap.draw_text(0, 0, 10, pos[:height], c)
  233.     @animchars.push(letter)
  234.     pos[:x] += text_width
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Name Menu Processing | New Method
  238.   #--------------------------------------------------------------------------
  239.   def process_name(c, pos)
  240.     c = WiggleText::NAMES[c]
  241.     text_width = text_size(c).width
  242.     if defined? Graphics.fullscreen #MKXP fix
  243.       text_width += text_width * 0.6
  244.       text_width = text_width.round
  245.     end
  246.  
  247.     letter = Sprite_TextAnim.new(self.viewport)
  248.     bitmap = Bitmap.new(text_width + 4, 20)
  249.     letter.bitmap = bitmap
  250.     bitmap.font = self.contents.font
  251.     letter.x = 23
  252.     letter.y = self.y  + 2
  253.     letter.z = self.z + 10
  254.     letter.anim_offset = @animchars.size
  255.     letter.anim_type = 10 #@anim_type
  256.     tuckie_extra(letter)
  257.     letter.update
  258.     bitmap.draw_text(0, 0, 10, 16, c)
  259.  
  260.     tag = Sprite_TextAnim.new(self.viewport)
  261.     tag.bitmap = Cache.system(WiggleText::NAME_SPRITE)
  262.     tag.x = 14
  263.     tag.y = self.y - 8
  264.     tag.z = self.z + 9
  265.     tag.anim_offset = @animchars.size
  266.     tag.anim_type = 10
  267.     tuckie_extra(tag)
  268.     tag.drop = 0
  269.     tag.update
  270.  
  271.     @animchars.push(tag)
  272.     @animchars.push(letter)
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # * Animated Emoji Processing | New Method
  276.   #--------------------------------------------------------------------------
  277.   def process_anim_emoji(c, pos)
  278.     text_width = 24
  279.     letter = Sprite_TextAnim.new(self.viewport)
  280.     icon_bitmap = Cache.system("Emoji")
  281.     bitmap = Bitmap.new(24, pos[:height])
  282.     rect = Rect.new(c % 16 * 24, c / 16 * 24, 24, 24)
  283.     bitmap.blt(0, 0, icon_bitmap, rect)
  284.     letter.bitmap = bitmap
  285.     letter.x = pos[:x] + self.standard_padding + 9
  286.     letter.y += WiggleText::DROP_HEIGHT if WiggleText::DROP_IN
  287.     letter.y = self.y + standard_padding + pos[:y]
  288.     letter.z = self.z + 10
  289.     letter.anim_offset = @animchars.size
  290.     letter.anim_type = @anim_type
  291.     tuckie_extra(letter)
  292.     letter.update
  293.     #bitmap.draw_text(0, 0, text_width * 2, pos[:height], c)
  294.     @animchars.push(letter)
  295.     pos[:x] += text_width
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # * Animated Character Extra Conditions | New Method
  299.   #--------------------------------------------------------------------------
  300.   def tuckie_extra(letter)
  301.     if WiggleText::DROP_IN
  302.       letter.drop = WiggleText::DROP_HEIGHT
  303.     else
  304.       letter.drop = 0
  305.     end
  306.     if @anim_type == 5
  307.       letter.anim_offset = 0
  308.     end
  309.     letter.galv_ani = get_galvani
  310.     if @rainbow
  311.       letter.rainbow = true
  312.       letter.rainbow_offset = @animchars.size * 0.5
  313.     end
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # * Control Character Processing | Alias
  317.   #     code : the core of the control character
  318.   #            e.g. "C" in the case of the control character \C[1].
  319.   #--------------------------------------------------------------------------
  320.   alias tuckie_wiggly_process_escape_character process_escape_character
  321.   def process_escape_character(code, text, pos)
  322.     case code.upcase
  323.     when 'ANI' # Text Animation (by number)
  324.       @anim_type = obtain_escape_param(text)
  325.     when 'OFF' # No Text Animation
  326.       @anim_type = 7 if WiggleText::DROP_IN
  327.       @rainbow = false
  328.     when 'WAV' # Wave animation
  329.       @anim_type = 1
  330.     when 'SHK' # Shake Screen
  331.       $game_map.screen.start_shake(obtain_escape_param(text), 15, 10)
  332.     when 'RAN'
  333.       @rainbow = true
  334.     when 'BLN'
  335.       @rainbow = false
  336.     when 'MOJ'
  337.       process_anim_emoji(obtain_escape_param(text), pos)
  338.     when 'NAM'
  339.       process_name(obtain_escape_param(text), pos)
  340.     when 'LIN'
  341.       pos[:y] -= WiggleText::LINE_HEIGHT
  342.     end
  343.     tuckie_wiggly_process_escape_character(code, text, pos)
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # * Close Window and Wait for It to Fully Close | Alias
  347.   #--------------------------------------------------------------------------
  348.   alias tuckie_wiggly_close_wait close_and_wait
  349.   def close_and_wait
  350.     dispose_text_animation()
  351.     tuckie_wiggly_close_wait()
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # * Close Window and Wait for It to Fully Close | Alias
  355.   #--------------------------------------------------------------------------
  356.   alias tuckie_wiggly_dispose dispose
  357.   def dispose
  358.     dispose_text_animation()
  359.     tuckie_wiggly_dispose()
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # * New Page | Alias
  363.   #--------------------------------------------------------------------------
  364.   alias tuckie_wiggly_new_page new_page
  365.   def new_page(*args)
  366.     dispose_text_animation()
  367.     tuckie_wiggly_new_page(*args)
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # * Free animated text | New Method
  371.   #--------------------------------------------------------------------------
  372.   def dispose_text_animation
  373.     @animchars.each do |letter|
  374.       letter.dispose
  375.     end
  376.     @animchars = []
  377.     @anim_type = 7
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # * Update Fast Forward Flag | Alias
  381.   #--------------------------------------------------------------------------
  382.   alias tuckie_wiggle_update_show_fast update_show_fast
  383.   def update_show_fast
  384.     tuckie_wiggle_update_show_fast()
  385.     @show_fast = false if !WiggleText::SKIP_CHAR
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * Galv Animated Textbox | Alias
  389.   #--------------------------------------------------------------------------
  390.   def get_galvani # new method
  391.     return @anim_offset
  392.   end
  393.  
  394.   def tuckie_update # new method
  395.     @anim_offset += 0.015
  396.   end
  397.  
  398.   #--------------------------------------------------------------------------
  399.   # * Window Update | Alias
  400.   #--------------------------------------------------------------------------
  401.   alias tuckie_wiggly_update_base update
  402.   def update
  403.     tuckie_update
  404.     update_text_animation()
  405.     tuckie_wiggly_update_base()
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # * Text Animation Processing | New Method
  409.   #--------------------------------------------------------------------------
  410.   def update_text_animation()
  411.     unless @animchars.empty?
  412.       @animchars.each do |letter|
  413.         letter.update
  414.       end
  415.     end
  416.   end
  417.  
  418. end
  419. # end of script :) have a nice one thankz for looking
Advertisement
Add Comment
Please, Sign In to add comment