Advertisement
neutale

Kanji - Simple Dash Effect

Mar 12th, 2020
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.50 KB | None | 0 0
  1. #==============================================================================
  2. # ■ Simple Dash Effect ver.0.00 by Kanji the Grass
  3. # This work is provided under the MTCM Blue License
  4. # https://en.materialcommons.tk/mtcm-b-summary/
  5. # Credits display: Kanji the Grass
  6. #------------------------------------------------------------------------------
  7. #  Character can run at an angle visually while dashing.
  8. # You adjust HORZ_ANGLE if it looks unnatural (default, 7)
  9. #==============================================================================
  10. module KNS
  11.   DASH_SPEED = 1.8  # Dash speed, default is 1
  12.  
  13.   HORZ_ANGLE = 7 # Angle for character sprite when dash to side (left/ right)
  14.  
  15.   VERT_ZOOM_Y = 0.91 # Value of the vertical zoom when dashing.
  16. end
  17.  
  18. class Game_CharacterBase
  19.   include KNS
  20.   attr_accessor :zoom_y, :angle
  21.   #--------------------------------------------------------------------------
  22.   # ● Get move speed
  23.   #--------------------------------------------------------------------------
  24.   def real_move_speed
  25.     @move_speed + (dash? ? DASH_SPEED : 0)
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● Public member variable
  29.   #--------------------------------------------------------------------------
  30.   alias kdash__init_public_members init_public_members
  31.   def init_public_members
  32.     kdash__init_public_members
  33.     @zoom_y, @angle = 1, 0
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● Frame update
  37.   #--------------------------------------------------------------------------
  38.   alias kdash__update update
  39.   def update
  40.     kdash__update
  41.     update_dash
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ☆ Update dash
  45.   #--------------------------------------------------------------------------
  46.   def update_dash
  47.     if $game_player.dash? && moving?
  48.       @zoom_y = @direction % 6 == 2 ? VERT_ZOOM_Y : 1
  49.       @angle = HORZ_ANGLE * case @direction when 4;1 when 6;-1 else 0 end
  50.     else @angle, @zoom_y = 0, 1 end if [Game_Player, Game_Follower].include?(self.class)
  51.   end
  52. end
  53.  
  54. class Sprite_Character
  55.   #--------------------------------------------------------------------------
  56.   # ● Other update
  57.   #--------------------------------------------------------------------------
  58.   alias kdash__update_other update_other
  59.   def update_other
  60.     kdash__update_other
  61.     self.angle, self.zoom_y = @character.angle || 0, @character.zoom_y || 1
  62.   end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement