#=========================================================================== # ◆ A1 Scripts ◆ # スクロール拡張(RGSS3) # # バージョン : 1.10 (2012/01/02) # 作者 : A1 # URL     : http://a1tktk.web.fc2.com/ #--------------------------------------------------------------------------- # 機能: # ・8方向スクロール # ・指定する座標へのスクロール # ・指定するイベントの座標へのスクロール # ・プレイヤーの座標へのスクロール #--------------------------------------------------------------------------- # 更新履歴   :2011/12/18 Ver1.00 リリース #    :2012/01/02 Ver1.10 A1共通スクリプトVer3.30対応 #--------------------------------------------------------------------------- # 設置場所 #  A1共通スクリプトより下 # # 必要スクリプト # A1共通スクリプトVer3.30以上 #--------------------------------------------------------------------------- # 使い方 # イベントコマンド「注釈」で設定 # #  画面スクロール direction,distance_x,distance_y,speed,wait #  direction :スクロール方向(上/下/左/右/右上/右下/左上/右上) #  distance_x:横方向へのスクロール距離 #  distance_y:縦方向へのスクロール距離 #  speed :スクロール速度 #  wait :w とするとスクロールが終わるまでウェイト # #  指定スクロール event,event_id,speed,wait #  event :イベントの座標へのスクロールの場合 event と記述 #  event_id:イベントID #  speed :スクロール速度 #  wait :w とするとスクロールが終わるまでウェイト # #  指定スクロール player,speed,wait #  player :プレイヤーの座標へのスクロールの場合 player と記述 #  speed :スクロール速度 #  wait :w とするとスクロールが終わるまでウェイト # #  指定スクロール x,y,speed,wait #  x :スクロール先のx座標 #  y :スクロール先のy座標 #  speed :スクロール速度 #  wait :w とするとスクロールが終わるまでウェイト #============================================================================== $imported ||= {} $imported["A1_Ex_scroll"] = true if $imported["A1_Common_Script"] old_common_script("拡張スクロール", "3.30") if common_version < 3.30 #============================================================================== # ■ Game_Map #------------------------------------------------------------------------------ #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。 # このクラスのインスタンスは $game_map で参照されます。 #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ☆ スクロールのセットアップ #-------------------------------------------------------------------------- alias a1_scroll8_gm_setup_scroll setup_scroll def setup_scroll a1_scroll8_gm_setup_scroll @scroll_rest_x = 0 @scroll_rest_y = 0 end #-------------------------------------------------------------------------- # ○ 右下にスクロール #-------------------------------------------------------------------------- def scroll_down_right(distance) scroll_down(distance) scroll_right(distance) end #-------------------------------------------------------------------------- # ○ 左下にスクロール #-------------------------------------------------------------------------- def scroll_down_left(distance) scroll_down(distance) scroll_left(distance) end #-------------------------------------------------------------------------- # ○ 右上にスクロール #-------------------------------------------------------------------------- def scroll_up_right(distance) scroll_up(distance) scroll_right(distance) end #-------------------------------------------------------------------------- # ○ 左上にスクロール #-------------------------------------------------------------------------- def scroll_up_left(distance) scroll_up(distance) scroll_left(distance) end #-------------------------------------------------------------------------- # ○ 斜めスクロールの開始 #-------------------------------------------------------------------------- def start_scroll8(direction, distance_x, distance_y, speed) @scroll_direction = direction @scroll_rest_x = distance_x @scroll_rest_y = distance_y @scroll_speed = speed end #-------------------------------------------------------------------------- # ☆ スクロール中判定 #-------------------------------------------------------------------------- alias a1_scroll8_gm_scrolling? scrolling? def scrolling? return true if a1_scroll8_gm_scrolling? return (@scroll_rest_x > 0 or @scroll_rest_y > 0) end #-------------------------------------------------------------------------- # ☆ スクロールの更新 #-------------------------------------------------------------------------- alias a1_scroll8_gm_update_scroll update_scroll def update_scroll return unless scrolling? return a1_scroll8_gm_update_scroll if @scroll_rest > 0 last_x = @display_x last_y = @display_y do_scroll(@scroll_direction, scroll_distance) if @display_x == last_x && @display_y == last_y @scroll_rest_x = 0 @scroll_rest_y = 0 else @scroll_rest_x -= scroll_distance @scroll_rest_y -= scroll_distance end @scroll_rest_x = 0 if @display_x == last_x @scroll_rest_y = 0 if @display_y == last_y if @scroll_rest_x <= 0 and @scroll_rest_y > 0 @scroll_rest = @scroll_rest_y @scroll_rest_x = 0 @scroll_rest_y = 0 @scroll_direction = 2 if @scroll_direction == 10 or @scroll_direction == 14 @scroll_direction = 8 if @scroll_direction == 12 or @scroll_direction == 16 elsif @scroll_rest_y <= 0 and @scroll_rest_x > 0 @scroll_rest = @scroll_rest_x @scroll_rest_x = 0 @scroll_rest_y = 0 @scroll_direction = 4 if @scroll_direction == 10 or @scroll_direction == 12 @scroll_direction = 6 if @scroll_direction == 14 or @scroll_direction == 16 end end #-------------------------------------------------------------------------- # ☆ スクロールの実行 #-------------------------------------------------------------------------- alias a1_scroll8_gm_do_scroll do_scroll def do_scroll(direction, distance) return a1_scroll8_gm_do_scroll(direction, distance) if direction <= 8 case direction when 10; scroll_down_left (distance) when 12; scroll_up_left (distance) when 14; scroll_down_right(distance) when 16; scroll_up_right (distance) end end end #============================================================================== # ■ A1_System::CommonModule #============================================================================== class A1_System::CommonModule #-------------------------------------------------------------------------- # ☆ 注釈コマンド定義 #-------------------------------------------------------------------------- alias a1_scroll_8_pos_define_command define_command def define_command a1_scroll_8_pos_define_command @cmd_108["画面スクロール"] = :scroll_screen @cmd_108["指定スクロール"] = :scroll_pos end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- DIRECTION = { "下" => 2, "左" => 4, "右" => 6, "上" => 8, "左下" => 10, "左上" => 12, "右下" => 14, "右上" => 16 } #-------------------------------------------------------------------------- # ○ マップのスクロール #-------------------------------------------------------------------------- def map_scroll(direction, distance_x, distance_y, speed, wait) return if $game_party.in_battle Fiber.yield while $game_map.scrolling? return $game_map.start_scroll(direction, distance_y, speed) if distance_x == 0 return $game_map.start_scroll(direction, distance_x, speed) if distance_y == 0 $game_map.start_scroll8(direction, distance_x, distance_y, speed) Fiber.yield while $game_map.scrolling? if wait end #-------------------------------------------------------------------------- # ○ 指定イベントの座標へスクロール #-------------------------------------------------------------------------- def map_scroll_to_event(event_id, speed, wait) event = $game_map.events[event_id] map_scroll_to_pos(event.x, event.y, speed, wait) end #-------------------------------------------------------------------------- # ○ プレイヤーの座標へスクロール #-------------------------------------------------------------------------- def map_scroll_to_player(speed, wait) map_scroll_to_pos($game_player.x, $game_player.y, speed, wait) end #-------------------------------------------------------------------------- # ○ 指定位置の座標へスクロール #-------------------------------------------------------------------------- def map_scroll_to_pos(x, y, speed, wait) distance_x = $game_player.center_x + $game_map.display_x - x distance_y = $game_player.center_y + $game_map.display_y - y direction = 2 if distance_x == 0 and distance_y < 0 direction = 4 if distance_x > 0 and distance_y == 0 direction = 6 if distance_x < 0 and distance_y == 0 direction = 8 if distance_x == 0 and distance_y > 0 direction = 10 if distance_x > 0 and distance_y < 0 direction = 12 if distance_x > 0 and distance_y > 0 direction = 14 if distance_x < 0 and distance_y < 0 direction = 16 if distance_x < 0 and distance_y > 0 map_scroll(direction, distance_x.abs, distance_y.abs, speed, wait == "w" ? true : false) end #-------------------------------------------------------------------------- # ○ 画面スクロール #-------------------------------------------------------------------------- def scroll_screen(params) direction = DIRECTION[params[0]] distance_x = params[1].to_i distance_y = params[2].to_i speed = params[3].to_i map_scroll(direction, distance_x, distance_y, speed, params[4] == "w" ? true : false) end #-------------------------------------------------------------------------- # ○ 指定スクロール #-------------------------------------------------------------------------- def scroll_pos(params) return map_scroll_to_event(params[1].to_i, params[2].to_i, params[3]) if params[0] == "event" return map_scroll_to_player(params[1].to_i, params[2]) if params[0] == "player" map_scroll_to_pos(params[0].to_i, params[1].to_i, params[2].to_i, params[3]) end end end