Advertisement
QuasiXi

Quasi Random Animation Size

Aug 23rd, 2014
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.75 KB | None | 0 0
  1. #==============================================================================
  2. #** Quasi Animation Random +- Size
  3. #==============================================================================
  4.  
  5. module Quasi
  6.   # Change this value to set the amount to + or - it's animation size
  7.   # Default is set in a range (-20..20) if you are to change the values
  8.   # in a range, make sure the smaller number is on the left, and larger on the
  9.   # right Ex: -100..-99 NOT -99..-100
  10.   # You can set this as an interger, such as only -20- this would result in the
  11.   # same as 0..20
  12.   # Positive values make the animation larger, while negative make it smaller.
  13.   ANI_ZOOM = -20..20
  14.  
  15.   # Add the ID of animations you do not want this effect to happen to, in this
  16.   # array.  Example array:
  17.   # ANI_FIXED = [1, 5, 10]
  18.   # Would result in animations 1, 5 and 10 to always have the same size
  19.   ANI_FIXED = []
  20. end
  21. #==============================================================================#
  22. # By Quasi (http://quasixi.wordpress.com/)
  23. #  - 8/23/14
  24. #==============================================================================#
  25. #   ** Stop! Do not edit anything below, unless you know what you      **
  26. #   ** are doing!                                                      **
  27. #==============================================================================#
  28. #==============================================================================
  29. # ** Sprite_Base
  30. #------------------------------------------------------------------------------
  31. #  A sprite class with animation display processing added.
  32. #==============================================================================
  33.  
  34. class Sprite_Base < Sprite
  35.   alias quasi_start_animation start_animation
  36.   alias quasi_animation_set animation_set_sprites
  37.   #--------------------------------------------------------------------------
  38.   # * Start Animation
  39.   #--------------------------------------------------------------------------
  40.   def start_animation(animation, mirror = false)
  41.     quasi_start_animation(animation, mirror)
  42.     if @animation
  43.       @rand = Random.new.rand(Quasi::ANI_ZOOM)
  44.     end
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # * Set Animation Sprite
  48.   #     frame : Frame data (RPG::Animation::Frame)
  49.   #--------------------------------------------------------------------------
  50.   def animation_set_sprites(frame)
  51.     quasi_animation_set(frame)
  52.     return if Quasi::ANI_FIXED.include?(@animation.id)
  53.     cell_data = frame.cell_data
  54.     @ani_sprites.each_with_index do |sprite, i|
  55.       next unless sprite
  56.       pattern = cell_data[i, 0]
  57.       next if !pattern || pattern < 0
  58.       sprite.zoom_x += @rand/100.0
  59.       sprite.zoom_y += @rand/100.0
  60.     end
  61.   end
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement