#============================================================================
# ** Zelda Map Scroll
#----------------------------------------------------------------------------
# Yeyinde
# 1.1.0
# 05/26/07
# SDK Version : (2.2) - Parts: I, II
# Notes:
# Try and get your maps a nice even multiple size of 20x15. It makes the
# scrolling a tad bit better.
#============================================================================
#-----------------------------------------------------------------------------
# SDK Auto-installer
#-----------------------------------------------------------------------------
unless Object.const_defined?(:SDK)
begin
require 'SDK'
rescue LoadError
print 'This script (Zelda Map Scroll) requires the SDK to run.'
exit 1
end
end
#-----------------------------------------------------------------------------
# SDK Log
#-----------------------------------------------------------------------------
SDK.log('Zelda Map Scroll', 'Yeyinde', '1.10', '05/26/07')
#-----------------------------------------------------------------------------
# SDK Check Requirements
#-----------------------------------------------------------------------------
SDK.check_requirements(2.2, [1, 2])
#-----------------------------------------------------------------------------
# SDK Enabled Check
#-----------------------------------------------------------------------------
if SDK.enabled?('Zelda Map Scroll')
#==============================================================================
# ** Zelda_Map_Scroll
#------------------------------------------------------------------------------
# Customization module
#------------------------------------------------------------------------------
module Zelda_Map_Scroll
# How fast the screen will scroll (1 being the slowest, 7 being the fastest)
SCROLL_SPEED = 6
# If the player will wait for the scrolling to finish before moving again
SCROLL_WAIT = true
# How long the player will wait during each scroll (In frames)
SCROLL_WAIT_PERIOD_Y = 10
SCROLL_WAIT_PERIOD_X = 16
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. Its functions include event starting
# determinants and map scrolling. Refer to "$game_player" for the one
# instance of this class.
#==============================================================================
class Game_Player
#---------------------------------------------------------------------------
# * Overwrite methods
#---------------------------------------------------------------------------
SDK.log_overwrite('Game_Player', 'center')
SDK.log_overwrite('Game_Player', 'update_scroll_down')
SDK.log_overwrite('Game_Player', 'update_scroll_left')
SDK.log_overwrite('Game_Player', 'update_scroll_right')
SDK.log_overwrite('Game_Player', 'update_scroll_up')
#---------------------------------------------------------------------------
# * Object Initialization
#---------------------------------------------------------------------------
def initialize
# Call superclass' initialize
super
# Make the wait while scrolling variable (Y)
@scroll_wait_y = RPG::MoveRoute.new
# Make it so it does not repeat
@scroll_wait_y.repeat = false
# Make the wait command
@scroll_wait_y.list[0].code = 15
@scroll_wait_y.list[0].parameters = [Zelda_Map_Scroll::SCROLL_WAIT_PERIOD_Y]
# Add a blank move command to signify the end
@scroll_wait_y.list << RPG::MoveCommand.new
# Make the wait while scrolling variable (X)
@scroll_wait_x = RPG::MoveRoute.new
# Make it so it does not repeat
@scroll_wait_x.repeat = false
# Make the wait command
@scroll_wait_x.list[0].code = 15
@scroll_wait_x.list[0].parameters = [Zelda_Map_Scroll::SCROLL_WAIT_PERIOD_X]
# Add a blank move command to signify the end
@scroll_wait_x.list << RPG::MoveCommand.new
end
#---------------------------------------------------------------------------
# * Set Map Display Position to Center of Screen
#---------------------------------------------------------------------------
def center(x, y)
# Get the maximum distance from the top-left corner
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
# Get the minimum distance to make
min_x = (x - x % 20) * 128
min_y = (y - y % 15) * 128
$game_map.display_x = [0, [min_x, max_x].min].max
$game_map.display_y = [0, [min_y, max_y].min].max
end
#--------------------------------------------------------------------------
# * Frame Update : Scroll Down
#--------------------------------------------------------------------------
def update_scroll_down(last_real_y)
# If character moves down off the display area
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y * 2
# Scroll map down
$game_map.start_scroll(2, 15, Zelda_Map_Scroll::SCROLL_SPEED)
# Wait for scrolling to finish
force_move_route(@scroll_wait_y) if Zelda_Map_Scroll::SCROLL_WAIT
end
end
#--------------------------------------------------------------------------
# * Scroll Left
#--------------------------------------------------------------------------
def update_scroll_left(last_real_x)
# If character moves left off the display area
if @real_x < last_real_x and @real_x < $game_map.display_x
# Scroll map left
$game_map.start_scroll(4, 20, Zelda_Map_Scroll::SCROLL_SPEED)
# Wait for scrolling to finish
force_move_route(@scroll_wait_x) if Zelda_Map_Scroll::SCROLL_WAIT
end
end
#--------------------------------------------------------------------------
# * Scroll Right
#--------------------------------------------------------------------------
def update_scroll_right(last_real_x)
# If character moves right off the display area
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X * 2
# Scroll map right
$game_map.start_scroll(6, 20, Zelda_Map_Scroll::SCROLL_SPEED)
# Wait for scrolling to finish
force_move_route(@scroll_wait_x) if Zelda_Map_Scroll::SCROLL_WAIT
end
end
#--------------------------------------------------------------------------
# * Scroll Up
#--------------------------------------------------------------------------
def update_scroll_up(last_real_y)
# If character moves up off the display area
if @real_y < last_real_y and @real_y < $game_map.display_y
# Scroll map up
$game_map.start_scroll(8, 15, Zelda_Map_Scroll::SCROLL_SPEED)
# Wait for scrolling to finish
force_move_route(@scroll_wait_y) if Zelda_Map_Scroll::SCROLL_WAIT
end
end
end
end
#-----------------------------------------------------------------------------
# End SDK Enabled Check
#-----------------------------------------------------------------------------