#==============================================================================
# ■ P叔的恐怖死亡系统(转载什么的请注明此脚本来自[url]www.66rpg.com[/url])
#------------------------------------------------------------------------------
# ●切换画面滚动模式:
# $game_map.scr_roll(滚动方向,滚动距离,滚动速度,缩进格数)
# 滚动方向:2、4、6、8分别对应下、左、右、上
# 滚动距离:地图有多宽或者有多高就写多少吧。
# 滚动速度:范围1-5,数字越大滚动越快。
# 缩进格数:默认为0,若要距离屏幕边缘n格就判定死亡则写n。
# ●停止画面滚动模式:
# $game_map.stop_roll
#==============================================================================
class Game_Map
COMMON_EV = 2 # 被屏幕压死后执行的公共事件ID
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
@screen = Game_Screen.new
@interpreter = Game_Interpreter.new(0, true)
@map_id = 0
@display_x = 0
@display_y = 0
@scene_mode = DEFAULT_MAP_MODE # 0为正常模式 1为重力模式
create_vehicles
@scroll_mode = false #【判定用】false为正常模式 true为画面滚动模式
@scroll_direction = 0 # 地图滚动方向
@indentation = 0 #【判定用】缩进格数
@graphics_width = Graphics.width # 屏幕宽度
@graphics_height = Graphics.height # 屏幕高度
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
refresh if $game_map.need_refresh
update_scroll
update_events
update_vehicles
update_parallax
judge_player_xy if @scroll_mode
@screen.update
end
#--------------------------------------------------------------------------
# ● 画面滚动模式判定
#--------------------------------------------------------------------------
def scroll_mode
return @scroll_mode
end
#--------------------------------------------------------------------------
# ● 画面滚动模式方向判定
#--------------------------------------------------------------------------
def scroll_direction
return @scroll_direction
end
#--------------------------------------------------------------------------
# ● 执行画面滚动模式命令
#--------------------------------------------------------------------------
def scr_roll(direction, distance, speed, indentation = 0)
@scroll_mode = true
@indentation = indentation * 32
start_scroll(direction, distance, speed)
end
#--------------------------------------------------------------------------
# ● 停止画面滚动模式命令
#--------------------------------------------------------------------------
def stop_roll
@scroll_rest = 0
end
#--------------------------------------------------------------------------
# ● 画面滚动模式压死判定
#--------------------------------------------------------------------------
def judge_player_xy
@indentation = 0 if @indentation == nil
if ($game_player.screen_x <= @indentation + 16 and @scroll_direction == 6) or
($game_player.screen_x >= @graphics_width - @indentation - 16 and @scroll_direction == 4) or
($game_player.screen_y <= @indentation + 32 and @scroll_direction == 2) or
($game_player.screen_y >= @graphics_height - @indentation and @scroll_direction == 8)
@scroll_mode = false
$game_temp.common_event_id = COMMON_EV
end
end
end
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ● 处理滚动
#--------------------------------------------------------------------------
def update_scroll(last_real_x, last_real_y)
ax1 = $game_map.adjust_x(last_real_x)
ay1 = $game_map.adjust_y(last_real_y)
ax2 = $game_map.adjust_x(@real_x)
ay2 = $game_map.adjust_y(@real_y)
if ay2 > ay1 and ay2 > CENTER_Y
if $game_map.scroll_mode
$game_map.scroll_down(ay2 - ay1) unless [2,8].include?($game_map.scroll_direction)
else
$game_map.scroll_down(ay2 - ay1)
end
end
if ax2 < ax1 and ax2 < CENTER_X
if $game_map.scroll_mode
$game_map.scroll_left(ax1 - ax2) unless [4,6].include?($game_map.scroll_direction)
else
$game_map.scroll_left(ax1 - ax2)
end
end
if ax2 > ax1 and ax2 > CENTER_X
if $game_map.scroll_mode
$game_map.scroll_right(ax2 - ax1) unless [4,6].include?($game_map.scroll_direction)
else
$game_map.scroll_right(ax2 - ax1)
end
end
if ay2 < ay1 and ay2 < CENTER_Y
if $game_map.scroll_mode
$game_map.scroll_up(ay1 - ay2) unless [2,8].include?($game_map.scroll_direction)
else
$game_map.scroll_up(ay1 - ay2)
end
end
end
end