Advertisement
LiTTleDRAgo

[RGSS] Custom Resolution - Map Zoom

Jan 28th, 2014
1,869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.07 KB | None | 0 0
  1. #==============================================================================
  2. # ** Custom Resolution - Map Zoom
  3. # Version : 1.04
  4. # Author : LiTTleDRAgo
  5. #==============================================================================
  6. #
  7. # Introduction :
  8. #
  9. #   As the name stated, this script zooms the map and player in the screen    
  10. #
  11. # How to Use :
  12. #
  13. #   Script :
  14. #      zoom(ZOOM)    # As an Integer (1-12)
  15. #
  16. # Note :
  17. #  
  18. #   Float zoom values will cause some glitch in the map
  19. #
  20. #==============================================================================
  21. ($imported ||= {})[:drg_cr_map_zoom] = 1.04
  22.  
  23. core = "This script needs Drago - Core Engine ver 1.43 or above"
  24. reso = "This script needs F0's Custom Resolution ver 0.97a or above"
  25. rmxp = "This script only for RMXP"
  26.  
  27. ($imported[:drg_core_engine] || 0) >= 1.43   || raise(core)
  28. $resolution &&  $resolution.version >= 0.971 || raise(reso)
  29. LiTTleDRAgo::XP                              || raise(rmxp)
  30. #==============================================================================
  31. # ** Sprite_Character
  32. #------------------------------------------------------------------------------
  33. #  This sprite is used to display the character.It observes the Game_Character
  34. #  class and automatically changes sprite conditions.
  35. #==============================================================================
  36. class Sprite_Character
  37.   #--------------------------------------------------------------------------
  38.   # * Alias Listing
  39.   #--------------------------------------------------------------------------
  40.   alias_sec_method(:zoom_update_scrolling, :update)
  41.   #--------------------------------------------------------------------------
  42.   # * Aliased method: update
  43.   #--------------------------------------------------------------------------
  44.   def update(*args)
  45.     zoom_update_scrolling(*args)
  46.     # Update character sprites
  47.     self.zoom_x = $game_map.zoom_x
  48.     self.zoom_y = $game_map.zoom_y
  49.   end
  50. end
  51.  
  52. #==============================================================================
  53. # ** Game_Map
  54. #------------------------------------------------------------------------------
  55. #  This class handles the map. It includes scrolling and passable determining
  56. #  functions. Refer to "$game_map" for the instance of this class.
  57. #==============================================================================
  58. class Game_Map
  59.   #--------------------------------------------------------------------------
  60.   # * New method: zoom
  61.   #--------------------------------------------------------------------------
  62.   def zoom(zoom=1.0)
  63.     @zoom_x = [[zoom, 1].max,12].min.round
  64.     @zoom_y = [[zoom, 1].max,12].min.round
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # * New method: zoom_in
  68.   #--------------------------------------------------------------------------
  69.   def zoom_in
  70.     zoom(@zoom_x + 1)
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # * New method: zoom_out
  74.   #--------------------------------------------------------------------------
  75.   def zoom_out
  76.     zoom(@zoom_x - 1)
  77.   end
  78. end
  79. #==============================================================================
  80. # ** Interpreter
  81. #------------------------------------------------------------------------------
  82. #  This interpreter runs event commands. This class is used within the
  83. #  Game_System class and the Game_Event class.
  84. #==============================================================================
  85.  
  86. class Interpreter
  87.   #--------------------------------------------------------------------------
  88.   # * Redirect Listing
  89.   #--------------------------------------------------------------------------
  90.   redirect_method :zoom,     '$game_map.zoom'
  91.   redirect_method :zoom_in,  '$game_map.zoom_in'
  92.   redirect_method :zoom_out, '$game_map.zoom_out'
  93. end
  94.  
  95. #==============================================================================
  96. # ** Game_Character
  97. #------------------------------------------------------------------------------
  98. #  This class deals with characters. It's used as a superclass for the
  99. #  determinants and map scrolling. Refer to "$game_player" for the one
  100. #  Game_Player and Game_Event classes.
  101. #==============================================================================
  102. class Game_Character
  103.   #--------------------------------------------------------------------------
  104.   # * Alias Listing
  105.   #--------------------------------------------------------------------------
  106.   alias_sec_method(:screen_x_before_zoom, :screen_x)
  107.   alias_sec_method(:screen_y_before_zoom, :screen_y)
  108.   alias_sec_method(:screen_z_before_zoom, :screen_z)
  109.   #--------------------------------------------------------------------------
  110.   # * Aliased method: screen_x
  111.   #--------------------------------------------------------------------------
  112.   def screen_x(*args)
  113.     # Get screen coordinates from real coordinates and map display position
  114.     screen_x_before_zoom(*args) * $game_map.zoom_x
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * Aliased method: screen_y
  118.   #--------------------------------------------------------------------------
  119.   def screen_y(*args)
  120.     # Get screen coordinates from real coordinates and map display position
  121.     screen_y_before_zoom(*args) * $game_map.zoom_y
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # * Overwriten method: screen_z
  125.   #--------------------------------------------------------------------------
  126.   def screen_z(height = 0)
  127.     # If display flag on closest surface is ON
  128.     if @always_on_top
  129.       # 999, unconditional
  130.       return 999
  131.     end
  132.     # Get screen coordinates from real coordinates and map display position
  133.     z = (@real_y - $game_map.display_y + 3) * $game_map.zoom_y / 4 + 32
  134.     # If tile
  135.     if @tile_id > 0
  136.       # Add tile priority * 32
  137.       return z  + $game_map.priorities[@tile_id] * 32
  138.     # If character
  139.     else
  140.       # If height exceeds 32, then add 31
  141.       return z + ((height > 32) ? 31 : 0)
  142.     end
  143.   end
  144. end
  145. #==============================================================================
  146. # ** Spriteset_Map
  147. #------------------------------------------------------------------------------
  148. #  This class brings together map screen sprites, tilemaps, etc.
  149. #  It's used within the Scene_Map class.
  150. #==============================================================================
  151.  
  152. class Spriteset_Map
  153.   #--------------------------------------------------------------------------
  154.   # * Alias Listing
  155.   #--------------------------------------------------------------------------
  156.   alias_sec_method(:zoom_update_scrolling, :update)
  157.   #--------------------------------------------------------------------------
  158.   # * Aliased method: update
  159.   #--------------------------------------------------------------------------
  160.   def update(*args)
  161.     zoom_update_scrolling(*args)
  162.     @fog.zoom_x *= $game_map.zoom_x
  163.     @fog.zoom_y *= $game_map.zoom_y
  164.     @panorama.zoom_x *= $game_map.zoom_x
  165.     @panorama.zoom_y *= $game_map.zoom_y
  166.   end
  167. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement