#============================================================================== # ■ VXAce-RGSS3-48 画面スクロール拡張 [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # 8方向スクロール, 座標指定スクロールなどができるようになります #============================================================================== # ◆8方向スクロール # $game_map.start_scroll(direction, distance, speed) # - direction : 方向 # 2..下, 4..左, 6..右, 8..上 # 1..左下, 3..右下, 7..左上, 9..右上 # - distance : 移動座標距離 # - speed : 移動速度 # 1..1/8倍速、2..1/4倍速、3..1/2倍速、4..標準速、5..2倍速、6..4倍速 #------------------------------------------------------------------------------ # ◆指定中心座標へのスクロール # $game_map.start_target_scroll(x, y, speed) # - x : X座標 # - y : Y座標 # - speed : 移動速度 # 1..1/8倍速、2..1/4倍速、3..1/2倍速、4..標準速、5..2倍速、6..4倍速 #------------------------------------------------------------------------------ # ◆プレイヤー位置へスクロール # $game_map.start_player_scroll(speed) # - speed : 移動速度 # 1..1/8倍速、2..1/4倍速、3..1/2倍速、4..標準速、5..2倍速、6..4倍速 #------------------------------------------------------------------------------ # ◆イベント位置へスクロール # $game_map.start_event_scroll(ev_id, speed) # - ev_id : イベントID # - speed : 移動速度 # 1..1/8倍速、2..1/4倍速、3..1/2倍速、4..標準速、5..2倍速、6..4倍速 #------------------------------------------------------------------------------ # ◆指定中心座標へ画面設定 # $game_map.set_target_pos(x, y) # - x : X座標 # - y : Y座標 #------------------------------------------------------------------------------ # ◆プレイヤー位置へ画面設定 # $game_map.set_player_pos #------------------------------------------------------------------------------ # ◆イベント位置へ画面設定 # $game_map.set_event_pos(ev_id) # - ev_id : イベントID #============================================================================== #============================================================================== # ■ Game_Map #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ● スクロールのセットアップ #-------------------------------------------------------------------------- alias setup_scroll_ex setup_scroll def setup_scroll setup_scroll_ex @scroll_list = [] end #-------------------------------------------------------------------------- # ● スクロールの開始 [再定義] #-------------------------------------------------------------------------- def start_scroll(direction, distance, speed) start_scroll_list([[direction, distance]], speed) end #-------------------------------------------------------------------------- # ● スクロールの開始 #-------------------------------------------------------------------------- def start_scroll_list(list, speed) @scroll_list = list @scroll_speed = speed end #-------------------------------------------------------------------------- # ● スクロール中判定 [再定義] #-------------------------------------------------------------------------- def scrolling? !@scroll_list.empty? end #-------------------------------------------------------------------------- # ● スクロールの更新 [再定義] #-------------------------------------------------------------------------- def update_scroll return unless scrolling? last_x = @display_x last_y = @display_y do_scroll(@scroll_list[0][0], scroll_distance) if @display_x == last_x && @display_y == last_y @scroll_list.shift else @scroll_list[0][1] -= scroll_distance if @scroll_list[0][1] == 0 @scroll_list.shift end end end #-------------------------------------------------------------------------- # ● スクロールの実行 #-------------------------------------------------------------------------- alias do_scroll_4dir do_scroll def do_scroll(direction, distance) case direction when 1; scroll_left (distance); scroll_down(distance) when 3; scroll_right(distance); scroll_down(distance) when 7; scroll_left (distance); scroll_up (distance) when 9; scroll_right(distance); scroll_up (distance) else; do_scroll_4dir(direction, distance) end end #-------------------------------------------------------------------------- # ● 指定座標にスクロール #-------------------------------------------------------------------------- def start_target_scroll(x, y, speed) x -= $game_player.center_x y -= $game_player.center_y x = [0, [x, width - screen_tile_x].min].max unless loop_horizontal? y = [0, [y, height - screen_tile_y].min].max unless loop_vertical? diff_x = x - @display_x diff_y = y - @display_y list = [] until diff_x == 0.0 and diff_y == 0.0 if diff_x == 0.0 and diff_y == 0.0 return elsif diff_x == 0 and diff_y > 0 list.push([2, diff_y.abs]) diff_y = 0 elsif diff_x < 0 and diff_y == 0.0 list.push([4, diff_x.abs]) diff_x = 0 elsif diff_x > 0 and diff_y == 0.0 list.push([6, diff_x.abs]) diff_x = 0 elsif diff_x == 0.0 and diff_y < 0 list.push([8, diff_y.abs]) diff_y = 0 else # 斜め distance = diff_x.abs < diff_y.abs ? diff_x.abs : diff_y.abs if diff_x < 0 and diff_y > 0 list.push([1, distance]) elsif diff_x > 0 and diff_y > 0 list.push([3, distance]) elsif diff_x < 0 and diff_y < 0 list.push([7, distance]) elsif diff_x > 0 and diff_y < 0 list.push([9, distance]) end diff_x = (diff_x.abs - distance) * (diff_x / diff_x.abs) diff_y = (diff_y.abs - distance) * (diff_y / diff_y.abs) end end start_scroll_list(list, speed) end #-------------------------------------------------------------------------- # ● プレイヤー位置にスクロール #-------------------------------------------------------------------------- def start_player_scroll(speed) start_target_scroll($game_player.x, $game_player.y, speed) end #-------------------------------------------------------------------------- # ● プレイヤー位置にスクロール #-------------------------------------------------------------------------- def start_event_scroll(ev_id, speed) ev = @events[ev_id] return if ev.nil? start_target_scroll(ev.x, ev.y, speed) end #-------------------------------------------------------------------------- # ● 指定座標に設定 #-------------------------------------------------------------------------- def set_target_pos(x, y) set_display_pos(x - $game_player.center_x, y - $game_player.center_y) end #-------------------------------------------------------------------------- # ● プレイヤー位置に設定 #-------------------------------------------------------------------------- def set_player_pos set_target_pos($game_player.x, $game_player.y) end #-------------------------------------------------------------------------- # ● イベント位置に設定 #-------------------------------------------------------------------------- def set_event_pos(ev_id) ev = @events[ev_id] return if ev.nil? set_target_pos(ev.x, ev.y) end end