Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Map_Zoom
- #------------------------------------------------------------------------------
- # Trebor777
- # Version 1.1s
- # 14/06/2007
- #
- # Heavily Edited by LiTTleDRAgo (Simplified)
- #
- # * Description:
- #
- # This script allow you to zoom in or out on a specific map location.
- #
- #------------------------------------------------------------------------------
- #* Instructions
- #
- # Place The Script Above Main.
- # Use this command in a script or with the event command "Call a script":
- # . $game_map.zoom(x,y,coef)
- #
- # x & y: Target Location(not inpixel)to zoom in/out
- # coef : Zoom value to reach from 0.1, to infinite
- #
- # Version 1.1s
- # Code adapted to the new tilemap class.
- # ==============================================================================
- #==============================================================================
- # ** Sprite_Character
- #------------------------------------------------------------------------------
- # This sprite is used to display the character.It observes the Game_Character
- # class and automatically changes sprite conditions.
- #==============================================================================
- class Sprite_Character
- #--------------------------------------------------------------------------
- # * Alias Listing
- #--------------------------------------------------------------------------
- $@ || alias_method(:zoom_update_scrolling, :update)
- #--------------------------------------------------------------------------
- # * Aliased method: update
- #--------------------------------------------------------------------------
- def update(*args)
- zoom_update_scrolling(*args)
- # Update character sprites
- self.zoom_x = $game_map.zoom_x
- self.zoom_y = $game_map.zoom_y
- end
- end
- #==============================================================================
- # ** Game_Map
- #------------------------------------------------------------------------------
- # This class handles the map. It includes scrolling and passable determining
- # functions. Refer to "$game_map" for the instance of this class.
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # * Script Check
- #--------------------------------------------------------------------------
- unless method_defined?(:zoom_x)
- raise "This script needs Edited King's Tilemap to work"
- end
- #--------------------------------------------------------------------------
- # * New method: zoom
- #--------------------------------------------------------------------------
- def zoom(x,y,zoom)
- @zoom_x = zoom
- @zoom_y = zoom
- $game_player.center(x,y)
- @need_redraw = true
- end
- #--------------------------------------------------------------------------
- # * Overwriten method: scroll_down
- #--------------------------------------------------------------------------
- def scroll_down(distance)
- @display_y = [@display_y + distance, (self.height *
- zoom_y - 15) * 128 / zoom_y].min
- end
- #--------------------------------------------------------------------------
- # * Overwriten method: scroll_right
- #--------------------------------------------------------------------------
- def scroll_right(distance)
- @display_x = [@display_x + distance, (self.width *
- zoom_x - 20) * 128 / zoom_x].min
- end
- end
- #==============================================================================
- # ** Game_Character
- #------------------------------------------------------------------------------
- # This class deals with characters. It's used as a superclass for the
- # determinants and map scrolling. Refer to "$game_player" for the one
- # Game_Player and Game_Event classes.
- #==============================================================================
- class Game_Character
- #--------------------------------------------------------------------------
- # * Overwriten method: screen_x
- #--------------------------------------------------------------------------
- def screen_x
- # Get screen coordinates from real coordinates and map display position
- return (@real_x - $game_map.display_x + 3 * $game_map.zoom_x) / 4 *
- $game_map.zoom_x + 16 * $game_map.zoom_x
- end
- #--------------------------------------------------------------------------
- # * Overwriten method: screen_y
- #--------------------------------------------------------------------------
- def screen_y
- # Get screen coordinates from real coordinates and map display position
- y = (@real_y - $game_map.display_y + 3 * $game_map.zoom_y) / 4 *
- $game_map.zoom_y + 32 * $game_map.zoom_y
- # Make y-coordinate smaller via jump count
- if @jump_count >= @jump_peak
- n = @jump_count - @jump_peak
- else
- n = @jump_peak - @jump_count
- end
- return y - (@jump_peak * @jump_peak - n * n) / 2
- end
- #--------------------------------------------------------------------------
- # * Overwriten method: screen_z
- #--------------------------------------------------------------------------
- def screen_z(height = 0)
- # If display flag on closest surface is ON
- if @always_on_top
- # 999, unconditional
- return 999
- end
- # Get screen coordinates from real coordinates and map display position
- z = (@real_y - $game_map.display_y + 3 * $game_map.zoom_y) / 4 *
- $game_map.zoom_y + 32 * $game_map.zoom_y
- # If tile
- if @tile_id > 0
- # Add tile priority * 32
- return z + $game_map.priorities[@tile_id] * 32 * $game_map.zoom_y
- # If character
- else
- # If height exceeds 32, then add 31
- return z + ((height > 32) ? 31 : 0)
- end
- end
- end
- #==============================================================================
- # ** Game_Player
- #------------------------------------------------------------------------------
- # This class handles the player. Its functions include event starting
- # instance of this class.
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # * Overwriten method: center
- #--------------------------------------------------------------------------
- def center(x, y)
- map = $game_map
- r = Graphics
- r = r.respond_to?(:width) ? [r.width,r.height] : [640,480]
- self.class.const_set(:CENTER_X, (r.at(0)/2 / $game_map.zoom_x - 16) * 4)
- self.class.const_set(:CENTER_Y, (r.at(1)/2 / $game_map.zoom_y - 16) * 4)
- max_x = (map.width * map.zoom_x - 20) * 128 / map.zoom_x
- max_y = (map.height * map.zoom_y - 15) * 128 / map.zoom_y
- $game_map.display_x = ([0, [x * 128 - CENTER_X, max_x].min].max)
- $game_map.display_y = ([0, [y * 128 - CENTER_Y, max_y].min].max)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement