Vibrating/Trembling Text

Badweather4cast

Master Eventer
Veteran
Joined
Jun 27, 2016
Messages
38
Reaction score
37
First Language
English
Primarily Uses
RMVXA
Hello, all! I know that a script of this sort has been requested before on these forums and others, however, I've yet to find a thread with an actual response, so I thought I'd try reviving the concept here.

I'm currently hunting for a script that can force the individual letters in a text (via a message box) to tremble, with adjustable speed/power if at all possible. I've seen the effect in many different RPG-type games, and I feel like it adds that extra flash of emotion during those angry outbursts, or to unease the player further for horror scenes.

For reference, this JavaScript plugin made for MV pretty much covers what I'm looking for in VXA:


If anyone might be able to help, I'd greatly appreciate it! ^^
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,579
Reaction score
545
First Language
English
Primarily Uses
RMVXA
There was a post on just that a while ago. I can't find it now so here try this
Code:
=begin
 ______________________
<  wiggly text          │
 │ by tuckie            │
 │                      │
 │ 7/7/17 woa lucky     │
 │ Version: pretty done │
 │______________________│

       ______________
(-o-)< hi there!! │
      │_____________│

 __________________________________________
<                                           │
 │ uhh hi this lets you animate text〰️〰️〰️〰️ │
 │                  pretty cool             │
 │ i like credit link to my twitter         │
 │ @plsvotetuckie  in the credit.txt        │
 │ or website(tell ur fans to give me $100) │
 │ tuckie.zone thank you i love yuo ❤️      │
 │__________________________________________│

=end

#==============================================================================
# how2use this scripty boy                                              _ ⬜ ❎
#==============================================================================
# Triggering animations is done via tags in the message window.
#
# Simply add a \ani[0-9] to pick the animation you want, and all text after will
# be animated. If a new text box appears the animation will stop. You can
# manually end animation with a \stop or \ani[7].
#
#-R/-\|NB0\^/-------------------------------------------------------------------
# Much like an animation, you can turn on a rainbow effect with \ran . You can
# turn off the rainbow and animation with \off but \bln will turn off only the
# rainbow effect.
#
#==============================================================================

#==============================================================================
# ** SETTINGS | hi im tuckie please tell your players i made this       _ ⬜ ❎
#==============================================================================

module WiggleText

  # Characters 'drop in' when first drawn.
  DROP_IN     = true
  # Height from where characters drop.
  DROP_HEIGHT = 8

  # Enable or disable hitting a button to skip drawing characters one-by-one.
  # true means players can skip, false means they can't.
  SKIP_CHAR   = true

  # do /nam[number] to make a nametag box with that specific name
  NAMES = [
      "that guy", #0
      "that other guy",   #1
      "a jerk", #2 etc
  ]
  #the filename of the background for the nametag sprite, place in Graphics/System
  NAME_SPRITE = "Nametag"

  # creature comfort feature: If you have a bunch of text codes (nametag, color
  # sound effect, etc) that you need to have at the start of a message make them
  # on line one, and use the text code \lin . this will "reset" the text height
  # so line two is higher up. adjust the height to fit your font with this
  # variable. Measurement in pixels.
  LINE_HEIGHT = 16
end

#==============================================================================
# ** Sprite_TextAnim                                                    _ ⬜ ❎
#------------------------------------------------------------------------------
#  Sprite subclass for text animations.
#==============================================================================

class Sprite_TextAnim < Sprite

  attr_accessor :anim_offset
  attr_accessor :anim_type
  attr_accessor :rainbow
  attr_accessor :rainbow_offset
  attr_accessor :drop
  @timer      = false
  attr_accessor :galv_ani

  def drop()
    if WiggleText::DROP_IN
      @drop -= @drop * 0.1
      if @drop < 0
        @drop = 0
      end
      return @drop
    else
      return 0
    end
  end

  def ani
      @galv_ani += 0.015
  end

  def update
    return unless @anim_offset

    if @rainbow
      @rainbow_offset += 0.03
      self.color = Color.new(128 + Math.sin(@rainbow_offset) * 127,
        128 + Math.sin(@rainbow_offset + 2*Math::PI/3) * 127,
        128 + Math.sin(@rainbow_offset + 4*Math::PI/3) * 127,
        255)
    end
    case @anim_type
      when 1
        @anim_offset += 0.115
        self.oy = Math.sin(@anim_offset) * 3 + drop()
        ani()
      when 2
        @anim_offset += 0.2
        self.ox = Math.sin(@anim_offset) * 3
        self.oy = Math.cos(@anim_offset) * -3 + drop()
        ani()
      when 3
        @anim_offset += 0.15
        self.zoom_x = 1 + Math.sin(@anim_offset) * 0.2
        self.zoom_y = 1 + Math.cos(@anim_offset) * 0.2
        self.oy = drop()
        ani()
      when 4
        @anim_offset += 1
        rand = 0
        if @anim_offset % 8 == 0
          rand = 4
          self.ox = rand(rand) - rand(rand)
          self.oy = rand(rand) - rand(rand) + drop()
        end
        ani()
      when 5
        @anim_offset += 0.1
        sample  = Math.sin(@anim_offset) * 5
        self.oy = sample.abs + drop()
        ani()
      when 6
        @anim_offset += 0.1
        self.ox = Math.sin(@anim_offset) * 3
        self.oy = Math.cos(@anim_offset) * -2 + drop()
        self.angle = Math.sin(@anim_offset * 0.5) * 10
        ani()
      when 7
        #no animation
        self.oy = drop()
        ani()
      when 8
        @anim_offset += 0.1
        self.ox = Math.sin(@anim_offset) * 3
        self.oy = Math.cos(@anim_offset) * -2 + drop()
        self.angle = Math.sin(@anim_offset) * 10
      when 9
        @anim_offset += 0.15
        self.zoom_x = 2
        self.zoom_y = 2
        self.oy = Math.sin(@anim_offset / 2) * -4 + drop()
      when 10
        @anim_offset += 0.085
        self.oy = Math.sin(@anim_offset / 2) * 3 + drop() + 2
      else
        return
    end
  end

end

#==============================================================================
# ** Window_Message                                                     _ ⬜ ❎
#------------------------------------------------------------------------------
#  This message window is used to display text.
#==============================================================================

class Window_Message < Window_Base

  #--------------------------------------------------------------------------
  # * Window_Message Creation | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_initialize initialize
  def initialize
    tuckie_wiggly_initialize
    @animchars = []
    @rainbow = false
    @anim_offset = 0
  end

  #--------------------------------------------------------------------------
  # * Normal Character Processing | Overwrite
  #--------------------------------------------------------------------------
  def process_normal_character(c, pos)
    if @anim_type && @anim_type > 0
      process_anim_character(c, pos)
    else
      if WiggleText::DROP_IN
        @anim_type = 7
        process_anim_character(c, pos)
      else
        super
      end
    end
    wait_for_one_character
  end
  #--------------------------------------------------------------------------
  # * Animated Character Processing | New Method
  #--------------------------------------------------------------------------
  def process_anim_character(c, pos)
    text_width = text_size(c).width
    if defined? Graphics.fullscreen #MKXP fix
      text_width += text_width * 0.6
      text_width = text_width.round
    end
    letter = Sprite_TextAnim.new(self.viewport)
    bitmap = Bitmap.new(text_width, pos[:height])
    bitmap.font = self.contents.font
    letter.bitmap = bitmap
    letter.x = pos[:x] + self.standard_padding + 9
    letter.y += WiggleText::DROP_HEIGHT if WiggleText::DROP_IN
    letter.y = self.y + standard_padding + pos[:y]
    letter.z = self.z + 10
    letter.anim_offset = @animchars.size
    letter.anim_type = @anim_type
    tuckie_extra(letter)
    letter.update
    bitmap.draw_text(0, 0, 10, pos[:height], c)
    @animchars.push(letter)
    pos[:x] += text_width
  end
  #--------------------------------------------------------------------------
  # * Name Menu Processing | New Method
  #--------------------------------------------------------------------------
  def process_name(c, pos)
    c = WiggleText::NAMES[c]
    text_width = text_size(c).width
    if defined? Graphics.fullscreen #MKXP fix
      text_width += text_width * 0.6
      text_width = text_width.round
    end

    letter = Sprite_TextAnim.new(self.viewport)
    bitmap = Bitmap.new(text_width + 4, 20)
    letter.bitmap = bitmap
    bitmap.font = self.contents.font
    letter.x = 23
    letter.y = self.y  + 2
    letter.z = self.z + 10
    letter.anim_offset = @animchars.size
    letter.anim_type = 10 #@anim_type
    tuckie_extra(letter)
    letter.update
    bitmap.draw_text(0, 0, 10, 16, c)

    tag = Sprite_TextAnim.new(self.viewport)
    tag.bitmap = Cache.system(WiggleText::NAME_SPRITE)
    tag.x = 14
    tag.y = self.y - 8
    tag.z = self.z + 9
    tag.anim_offset = @animchars.size
    tag.anim_type = 10
    tuckie_extra(tag)
    tag.drop = 0
    tag.update

    @animchars.push(tag)
    @animchars.push(letter)
  end
  #--------------------------------------------------------------------------
  # * Animated Emoji Processing | New Method
  #--------------------------------------------------------------------------
  def process_anim_emoji(c, pos)
    text_width = 24
    letter = Sprite_TextAnim.new(self.viewport)
    icon_bitmap = Cache.system("Emoji")
    bitmap = Bitmap.new(24, pos[:height])
    rect = Rect.new(c % 16 * 24, c / 16 * 24, 24, 24)
    bitmap.blt(0, 0, icon_bitmap, rect)
    letter.bitmap = bitmap
    letter.x = pos[:x] + self.standard_padding + 9
    letter.y += WiggleText::DROP_HEIGHT if WiggleText::DROP_IN
    letter.y = self.y + standard_padding + pos[:y]
    letter.z = self.z + 10
    letter.anim_offset = @animchars.size
    letter.anim_type = @anim_type
    tuckie_extra(letter)
    letter.update
    #bitmap.draw_text(0, 0, text_width * 2, pos[:height], c)
    @animchars.push(letter)
    pos[:x] += text_width
  end
  #--------------------------------------------------------------------------
  # * Animated Character Extra Conditions | New Method
  #--------------------------------------------------------------------------
  def tuckie_extra(letter)
    if WiggleText::DROP_IN
      letter.drop = WiggleText::DROP_HEIGHT
    else
      letter.drop = 0
    end
    if @anim_type == 5
      letter.anim_offset = 0
    end
    letter.galv_ani = get_galvani
    if @rainbow
      letter.rainbow = true
      letter.rainbow_offset = @animchars.size * 0.5
    end
  end
  #--------------------------------------------------------------------------
  # * Control Character Processing | Alias
  #     code : the core of the control character
  #            e.g. "C" in the case of the control character \C[1].
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_process_escape_character process_escape_character
  def process_escape_character(code, text, pos)
    case code.upcase
    when 'ANI' # Text Animation (by number)
      @anim_type = obtain_escape_param(text)
    when 'OFF' # No Text Animation
      @anim_type = 7 if WiggleText::DROP_IN
      @rainbow = false
    when 'WAV' # Wave animation
      @anim_type = 1
    when 'SHK' # Shake Screen
      $game_map.screen.start_shake(obtain_escape_param(text), 15, 10)
    when 'RAN'
      @rainbow = true
    when 'BLN'
      @rainbow = false
    when 'MOJ'
      process_anim_emoji(obtain_escape_param(text), pos)
    when 'NAM'
      process_name(obtain_escape_param(text), pos)
    when 'LIN'
      pos[:y] -= WiggleText::LINE_HEIGHT
    end
    tuckie_wiggly_process_escape_character(code, text, pos)
  end
  #--------------------------------------------------------------------------
  # * Close Window and Wait for It to Fully Close | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_close_wait close_and_wait
  def close_and_wait
    dispose_text_animation()
    tuckie_wiggly_close_wait()
  end
  #--------------------------------------------------------------------------
  # * Close Window and Wait for It to Fully Close | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_dispose dispose
  def dispose
    dispose_text_animation()
    tuckie_wiggly_dispose()
  end
  #--------------------------------------------------------------------------
  # * New Page | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_new_page new_page
  def new_page(*args)
    dispose_text_animation()
    tuckie_wiggly_new_page(*args)
  end
  #--------------------------------------------------------------------------
  # * Free animated text | New Method
  #--------------------------------------------------------------------------
  def dispose_text_animation
    @animchars.each do |letter|
      letter.dispose
    end
    @animchars = []
    @anim_type = 7
  end
  #--------------------------------------------------------------------------
  # * Update Fast Forward Flag | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggle_update_show_fast update_show_fast
  def update_show_fast
    tuckie_wiggle_update_show_fast()
    @show_fast = false if !WiggleText::SKIP_CHAR
  end
  #--------------------------------------------------------------------------
  # * Galv Animated Textbox | Alias
  #--------------------------------------------------------------------------
  def get_galvani # new method
    return @anim_offset
  end

  def tuckie_update # new method
    @anim_offset += 0.015
  end

  #--------------------------------------------------------------------------
  # * Window Update | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_update_base update
  def update
    tuckie_update
    update_text_animation()
    tuckie_wiggly_update_base()
  end
  #--------------------------------------------------------------------------
  # * Text Animation Processing | New Method
  #--------------------------------------------------------------------------
  def update_text_animation()
    unless @animchars.empty?
      @animchars.each do |letter|
        letter.update
      end
    end
  end

end
# end of script :) have a nice one thankz for looking
 

Badweather4cast

Master Eventer
Veteran
Joined
Jun 27, 2016
Messages
38
Reaction score
37
First Language
English
Primarily Uses
RMVXA
Oh my goodness, thank you so much! That's exactly what I was looking for. I really appreciate it!
 

CuddleFox

Furry
Veteran
Joined
Feb 18, 2017
Messages
116
Reaction score
40
First Language
French
Primarily Uses
RMVXA
I love this script. I'd like to use it, but it changes my font. Is there any way to fix this problem?
Without the script :

With the script :
 

Mhin Ra

Veteran
Veteran
Joined
Aug 17, 2015
Messages
61
Reaction score
18
First Language
English
Primarily Uses
RMVXA
I saw this reported in a different thread first (https://forums.rpgmakerweb.com/index.php?threads/wiggly-shaky-text-help.124077/), but I think if you change
Code:
bitmap.draw_text(0, 0, 10, pos[:height], c)
to
Code:
bitmap.draw_text(0, 0, text_width+2, pos[:height], c)
in process_anim_character and probably in process_name, you will find the text doesn't squish anymore. I explained the reasoning in the other thread I linked to.
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
287
Reaction score
71
First Language
English
Primarily Uses
RMXP
Something similar would happen if you were using italics. text_width returns the actual width of any string aka text without any special effects only. Anything that alters text will trigger the shrinking effect at some point.
As a side note you'd need to increase the +2 fix to +4 or even more if you ever use a larger font size.
 

Mhin Ra

Veteran
Veteran
Joined
Aug 17, 2015
Messages
61
Reaction score
18
First Language
English
Primarily Uses
RMVXA
That might be why I need +2 for everything; I'm using VL Gothic, which isn't the default font (IIRC). So, might be that the size of my font is slightly larger than the engine is expecting, thus the weird extra 2 ;)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts


Finally! I've been puzzling over why it wasn't working for two days now. Turns out all of my calculations were correct, I just forgot to give some events hitboxes. :kaoswt: Now my randomly generated maps check for collision errors, and move stuff around in real time if they finds any. :LZSexcite:
Ami
--- OP Candy ---

Kids: Trick Or Treat!
Hero: Alright,here's the Candies (Give A Bunch Of Candy).
Kids: Thank you,Mister! (Running)
Hero: How cute they are…
F.Archer: Did you give them a OP Candy,accidently?
Hero: Huh?
Halloween, a day where kids are encouraged to take candy from strangers.
Stream will be live shortly with a session of the Interactive Text Adventure! Feel free to drop by!
Took a break from spriting dinosaurs to carve a dinosaur pumpkin.

Forum statistics

Threads
104,673
Messages
1,007,992
Members
136,162
Latest member
Harry90
Top