Advertisement
neutale

Character Graphic Extension

Jan 20th, 2020
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.49 KB | None | 0 0
  1. #==============================================================================
  2. # ■ Character Graphic Extension
  3. #------------------------------------------------------------------------------
  4. #  Rotate a character image and adjust the display coordinates in pixels.
  5. #
  6. # ●How to use
  7. # 1. Use "Script" from "Set Move Route..." and put-
  8. #    self.rotate(90, 0, 0) -> rotate 90 degrees clockwise
  9. # 2. Rotation is used ot the origin, adjusts X and Y coordinates
  10. #    self.rotate(90, 16, -16) -> rotate 90 degrees clockwise
  11. #    X coordinate move 16 to the right and the Y coordinate 16 upward.
  12. #
  13. # ●Terms of use
  14. #  It can be modified and redistributed without permission from the author.
  15. #  Free for commercial and non-commercial use.
  16. #-----------------------------------------------------------------------------
  17. # Copyright (c) 2016 Triacontane
  18. # This software is released under the MIT License.
  19. # http://opensource.org/licenses/mit-license.php
  20. #-----------------------------------------------------------------------------
  21. # Version
  22. # 1.0.1 2016/05/05 Fixed an error when loading save data without using a script.
  23. # 1.0.0 2016/05/04 Initial release
  24. # ----------------------------------------------------------------------------
  25. # [Blog]   : http://triacontane.blogspot.jp/
  26. # [Twitter]: https://twitter.com/triacontane/
  27. # [GitHub] : https://github.com/triacontane/
  28. #=============================================================================
  29.  
  30. class Game_CharacterBase
  31.   #--------------------------------------------------------------------------
  32.   # ● Public instance variables
  33.   #--------------------------------------------------------------------------
  34.   attr_accessor :angle                       # Rotation angle
  35.   attr_accessor :adjustment_x                # X coordinate adjuster
  36.   attr_accessor :adjustment_y                # Y coordinate adjuster
  37.   #--------------------------------------------------------------------------
  38.   # ● Initializing public member variables
  39.   #--------------------------------------------------------------------------
  40.   alias cge_init_public_members init_public_members
  41.   def init_public_members
  42.     cge_init_public_members
  43.     @angle = 0
  44.     @adjustment_x = 0
  45.     @adjustment_y = 0
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● Get the screen X coordinate
  49.   #--------------------------------------------------------------------------
  50.   alias cge_screen_x screen_x
  51.   def screen_x
  52.     cge_screen_x + (@adjustment_x ? @adjustment_x : 0)
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● Get the screen Y coordinate
  56.   #--------------------------------------------------------------------------
  57.   alias cge_screen_y screen_y
  58.   def screen_y
  59.     cge_screen_y + (@adjustment_y ? @adjustment_y : 0)
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● Rotation
  63.   #--------------------------------------------------------------------------
  64.   def rotate(angle, adjustment_x, adjustment_y)
  65.     @angle = angle
  66.     @adjustment_x = adjustment_x
  67.     @adjustment_y = adjustment_y
  68.   end
  69. end
  70.  
  71. class Sprite_Character
  72.   #--------------------------------------------------------------------------
  73.   # ● Other updates
  74.   #--------------------------------------------------------------------------
  75.   alias cge_update_other update_other
  76.   def update_other
  77.     cge_update_other
  78.     self.angle = (@character.angle ? @character.angle : 0)
  79.   end
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement