#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :initialize_before_loop, :initialize
def initialize
initialize_before_loop
@display_loop_h = true
@display_loop_v = true
end
#--------------------------------------------------------------------------
# * Loop horizontally ?
#--------------------------------------------------------------------------
def display_loop_horizontal?
loop_horizontal? && @display_loop_h
end
#--------------------------------------------------------------------------
# * Loop vertically ?
#--------------------------------------------------------------------------
def display_loop_vertical?
loop_vertical? && @display_loop_v
end
#--------------------------------------------------------------------------
# * Center screen
#--------------------------------------------------------------------------
def center_screen
$game_player.center($game_player.x, $game_player.y)
end
#--------------------------------------------------------------------------
# * Lock / Unlock display loops
#--------------------------------------------------------------------------
def lock_horizontal_loop; @display_loop_h = false; center_screen; end
def lock_vertical_loop; @display_loop_v = false; center_screen; end
def unlock_horizontal_loop; @display_loop_h = true; center_screen; end
def unlock_vertical_loop; @display_loop_v = true; center_screen; end
#--------------------------------------------------------------------------
# * Calculate X Coordinate, Minus Display Coordinate
#--------------------------------------------------------------------------
def adjust_x(x)
if display_loop_horizontal? && x < @display_x - (width - screen_tile_x) / 2
x - @display_x + @map.width
else
x - @display_x
end
end
#--------------------------------------------------------------------------
# * Calculate Y Coordinate, Minus Display Coordinate
#--------------------------------------------------------------------------
def adjust_y(y)
if display_loop_vertical? && y < @display_y - (height - screen_tile_y) / 2
y - @display_y + @map.height
else
y - @display_y
end
end
#--------------------------------------------------------------------------
# * Set Display Position
#--------------------------------------------------------------------------
def set_display_pos(x, y)
x = [0, [x, width - screen_tile_x].min].max unless display_loop_horizontal?
y = [0, [y, height - screen_tile_y].min].max unless display_loop_vertical?
@display_x = (x + width) % width
@display_y = (y + height) % height
@parallax_x = x
@parallax_y = y
end
#--------------------------------------------------------------------------
# * Scroll Down
#--------------------------------------------------------------------------
def scroll_down(distance)
if display_loop_vertical?
@display_y += distance
@display_y %= @map.height
@parallax_y += distance if @parallax_loop_y
else
last_y = @display_y
@display_y = [@display_y + distance, height - screen_tile_y].min
@parallax_y += @display_y - last_y
end
end
#--------------------------------------------------------------------------
# * Scroll Left
#--------------------------------------------------------------------------
def scroll_left(distance)
if display_loop_horizontal?
@display_x += @map.width - distance
@display_x %= @map.width
@parallax_x -= distance if @parallax_loop_x
else
last_x = @display_x
@display_x = [@display_x - distance, 0].max
@parallax_x += @display_x - last_x
end
end
#--------------------------------------------------------------------------
# * Scroll Right
#--------------------------------------------------------------------------
def scroll_right(distance)
if display_loop_horizontal?
@display_x += distance
@display_x %= @map.width
@parallax_x += distance if @parallax_loop_x
else
last_x = @display_x
@display_x = [@display_x + distance, (width - screen_tile_x)].min
@parallax_x += @display_x - last_x
end
end
#--------------------------------------------------------------------------
# * Scroll Up
#--------------------------------------------------------------------------
def scroll_up(distance)
if display_loop_vertical?
@display_y += @map.height - distance
@display_y %= @map.height
@parallax_y -= distance if @parallax_loop_y
else
last_y = @display_y
@display_y = [@display_y - distance, 0].max
@parallax_y += @display_y - last_y
end
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# - command_354
# Return to title now return to profile screen
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Lock / Unlock display loops
#--------------------------------------------------------------------------
def lock_horizontal_loop; $game_map.lock_horizontal_loop; end
def lock_vertical_loop; $game_map.lock_vertical_loop; end
def unlock_horizontal_loop; $game_map.unlock_horizontal_loop; end
def unlock_vertical_loop; $game_map.unlock_vertical_loop; end
end