设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 793|回复: 1
打印 上一主题 下一主题

[已经过期] 关于重力脚本,求大神帮忙

[复制链接]

Lv2.观梦者

梦石
0
星屑
265
在线时间
286 小时
注册时间
2009-11-7
帖子
55

开拓者

跳转到指定楼层
1
发表于 2015-2-8 18:02:27 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
新人想做一个马里奥 ,如何实现跳跃时暂时改变行走图为“跳跃行走图“?
RUBY 代码复制
  1. $ud_ok = false #上下失效
  2. $airjump = 0  #空中连跳
  3. #==============================================================================
  4. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  5. #==============================================================================
  6.  
  7. # ————————————————————————————————————
  8. # 全方向ドット移動 Ver ε
  9. # 配布元・サポートURL
  10. # [url]http://members.jcom.home.ne.jp/cogwheel/[/url]$game_system.se_play($data_system.cancel_se)
  11.  
  12. #==============================================================================
  13. # ■ Game_Player
  14. #------------------------------------------------------------------------------
  15. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  16. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  17. #==============================================================================
  18. class Game_Player < Game_Character
  19.   #--------------------------------------------------------------------------
  20.   # ● 定数
  21.   #--------------------------------------------------------------------------
  22.   UP    = 48                  # 上方向の余裕(0 < UP < 63)
  23.   DOWN  = 16                  # 下方向の余裕(0 < DOWN <63)
  24.   SIDE  = 32                  # 左右方向の余裕(0 < SIDE <63)
  25.   SLANT = false               # 移動ルートの斜め移動時、速度修正
  26.   JUMPMAX = 100              
  27.   JUMPADD = 10              
  28.   #--------------------------------------------------------------------------
  29.   # ● 公開インスタンス変数
  30.   #--------------------------------------------------------------------------
  31.   attr_reader   :event                    # イベント時移動速度
  32.   attr_accessor :move_speed               # 移動速度
  33.   #--------------------------------------------------------------------------
  34.   # ● フレーム更新
  35.   #--------------------------------------------------------------------------
  36.   alias :update_original :update
  37.   def update
  38.     # @walk:歩行速度 @dash:ダッシュ時移動速度
  39.     # @event:イベント時移動速度(0の時は、イベント時に速度変更をしない)
  40.     @walk  = $game_variables[52]
  41.     @dash  = $game_variables[52]+1
  42.     @event = 4
  43.     @dot_m = true
  44.     #ダッシュ機能。エンターキーが押されている間、移動速度を変更する。
  45.     unless moving? or $game_system.map_interpreter.running? or
  46.             @move_route_forcing or $game_temp.message_window_showing
  47.       if @walk != @dash
  48.         if Input.press?(Input::C)
  49.           if @move_speed != @dash
  50.             @move_speed = @dash
  51.           end
  52.         else
  53.           if @move_speed != @walk
  54.             @move_speed = @walk
  55.           end
  56.         end
  57.       end
  58.     end
  59.     if @revise_x == nil and @revise_y == nil
  60.       @revise_x = 0
  61.       @revise_y = 0
  62.     end
  63.     unless @dot_m
  64.       update_original
  65.       return
  66.     end
  67.     if @move_route_forcing
  68.       # ローカル変数に移動中かどうかを記憶
  69.       last_moving = moving?
  70.       # ローカル変数に座標を記憶
  71.       last_real_x = @real_x
  72.       last_real_y = @real_y
  73.       # 座標がずれている場合
  74.       if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
  75.         if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
  76.           @revise_x = @real_x - @x * 128
  77.           @revise_y = @real_y - @y * 128
  78.         end
  79.         # 移動距離distance1と目標距離distance2を設定
  80.         distance1 = 2 ** @move_speed
  81.         distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
  82.         # 移動距離が目標距離を越えた場合
  83.         if distance1 > distance2
  84.           # 強制的に補正座標を零にする
  85.           @real_x = @real_x - @revise_x
  86.           @real_y = @real_y - @revise_y
  87.           @revise_x = 0
  88.           @revise_y = 0
  89.           anime_update
  90.         # 移動距離が目標距離に達しない場合
  91.         else
  92.           # 移動距離分目標距離に近づく
  93.           @real_x -= (distance1 * @revise_x / distance2).round
  94.           @real_y -= (distance1 * @revise_y / distance2).round
  95.           @revise_x = @real_x - @x * 128
  96.           @revise_y = @real_y - @y * 128
  97.           anime_update
  98.         end
  99.       else
  100.         super
  101.       end
  102.     else
  103.       @move = false
  104.       # 移動中、イベント実行中、移動ルート強制中、
  105.       # メッセージウィンドウ表示中のいずれでもない場合
  106.       unless moving? or $game_system.map_interpreter.running? or
  107.              @move_route_forcing or $game_temp.message_window_showing
  108.         @event_run = false
  109.         # 方向ボタンが押されていれば、その方向へプレイヤーを移動
  110. #---------------------------上下失效-----------------------------------------
  111.       case Input.dir8
  112.         when 1
  113.           $ud_ok ? move_lower_left_p : move_left_p
  114.         when 2
  115. #          $ud_ok ? move_down_p : move_down_aaaagq
  116.           move_down_p if $ud_ok
  117.         when 3
  118.          $ud_ok ? move_lower_right_p : move_right_p
  119.         when 4
  120.           move_left_p
  121.         when 6
  122.           move_right_p
  123.         when 7
  124.          $ud_ok ? move_upper_left_p : move_left_p
  125.         when 8
  126. #         $ud_ok ? move_up_p : move_up_aaaagq
  127.          move_up_p if $ud_ok
  128.         when 9
  129.          $ud_ok ? move_upper_right_p : move_right_p
  130.         end
  131.       end
  132.       # ローカル変数に座標を記憶
  133.       last_real_x = @real_x
  134.       last_real_y = @real_y
  135.       # 移動処理
  136.       @real_x = @x * 128 + @revise_x
  137.       @real_y = @y * 128 + @revise_y
  138.       # ローカル変数に移動中かどうかを記憶
  139.       last_moving = moving?
  140.       # 座標更新
  141.       move_on
  142.       # 現在の座標と以前の座標が異なる場合
  143.       if (last_real_x != @real_x or last_real_y != @real_y)
  144.         @move_distance = 0 if @move_distance == nil
  145.         @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
  146.                                       (last_real_y - @real_y) ** 2)
  147.         if @move_distance >= 128
  148.           @move_distance %= 128
  149.           increase_steps
  150.         end
  151.         # アニメーションを更新
  152.         anime_update
  153.       else
  154.         @pattern = 0
  155.       end
  156.     end
  157.     # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合
  158.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  159.       # マップを下にスクロール
  160.       $game_map.scroll_down(@real_y - last_real_y)
  161.     end
  162.     # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合
  163.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  164.       # マップを左にスクロール
  165.       $game_map.scroll_left(last_real_x - @real_x)
  166.     end
  167.     # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合
  168.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  169.       # マップを右にスクロール
  170.       $game_map.scroll_right(@real_x - last_real_x)
  171.     end
  172.     # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合
  173.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  174.       # マップを上にスクロール
  175.       $game_map.scroll_up(last_real_y - @real_y)
  176.     end
  177.     # 前回プレイヤーが移動中だった場合
  178.     if last_moving
  179.       # 同位置のイベントとの接触によるイベント起動判定
  180.       result = check_event_trigger_here([1,2])
  181.       if result == true
  182.         if (last_real_x / 128.0).round != @x and
  183.             (last_real_y / 128.0).round != @y
  184.           if @direction == 2 or @direction == 8
  185.             if (last_real_x / 128.0).round > @x
  186.               turn_left
  187.             else
  188.               turn_right
  189.             end
  190.           else
  191.             if (last_real_y / 128.0).round > @y
  192.               turn_up
  193.             else
  194.               turn_down
  195.             end
  196.           end
  197.         elsif (last_real_x / 128.0).round > @x
  198.           turn_left
  199.         elsif (last_real_x / 128.0).round < @x
  200.           turn_right
  201.         elsif (last_real_y / 128.0).round > @y
  202.           turn_up
  203.         elsif (last_real_y / 128.0).round < @y
  204.           turn_down
  205.         end
  206.       end
  207.       # 起動したイベントがない場合
  208.       if result == false
  209.         # デバッグモードが ON かつ CTRL キーが押されている場合を除き
  210.         unless $DEBUG and Input.press?(Input::CTRL)
  211.           # エンカウント カウントダウン
  212.           if @encounter_count > 0
  213.             @encounter_count -= 1
  214.           end
  215.         end
  216.       end
  217.     end
  218. #-----------------------按跳跃-----------------------------------------------
  219. # A ボタンが押された場合
  220.     if Input.press?(Input::A) and not $ud_ok
  221.       @twojump = 1 if @twojump == 0 and down1(((@x * 128 + @revise_x) / 128.0).round,
  222.           ((@y * 128 + @revise_y) / 128.0).round, 5, true)
  223.       if (not @apassed) and @twojump <= $airjump
  224.         @apassed = true
  225.         $game_system.se_play($data_system.cancel_se)
  226.         @jumpnow = JUMPMAX
  227.         @twojump += 1
  228.       else
  229.         @jumpnow += 3        
  230.       end
  231.     else
  232.       @apassed = false
  233.     end
  234. #----------------------自由落体--------------------------------
  235.     if not $ud_ok
  236.       @jumpnow -= 10
  237.       if @jumpnow < 0
  238.         @jumpnow = [@jumpnow, -JUMPMAX].max
  239.         if not down1(((@x * 128 + @revise_x) / 128.0).round,
  240.           ((@y * 128 + @revise_y) / 128.0).round, -@jumpnow, true)
  241.           @jumpnow = 0
  242.           @twojump = 0
  243.         end
  244.       elsif @jumpnow > 0
  245.         @jumpnow = [@jumpnow, JUMPMAX].min
  246.         if not up1(((@x * 128 + @revise_x) / 128.0).round,
  247.           ((@y * 128 + @revise_y) / 128.0).round, @jumpnow, true)
  248.           @jumpnow = 0
  249.         end
  250.       end
  251.     end
  252.     if Input.trigger?(Input::C)
  253.       # 同位置および正面のイベント起動判定
  254.       check_event_trigger_here([0])
  255.       check_event_trigger_there([0,1,2])
  256.     end
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● オブジェクト初期化
  260.   #--------------------------------------------------------------------------
  261.   def initialize
  262.     @jumpnow = 0
  263.     @twojump = 0
  264.     @apassed = false
  265.     @revise_x = 0
  266.     @revise_y = 0
  267.     @move == false
  268.     super
  269.   end
  270.   #--------------------------------------------------------------------------
  271.   # ● 移動判定
  272.   #--------------------------------------------------------------------------
  273.   def moving?
  274.     unless @dot_m
  275.       result = super
  276.       return result
  277.     end
  278.     # 強制移動の場合オリジナルの判定をさせる
  279.     if @move_route_forcing
  280.       if @move == false
  281.         return false
  282.       end
  283.       super
  284.     # 通常時は現座標が実座標と異なる場合のみ移動中と判定
  285.     else
  286.       return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  287.     end
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # ● 移動判定
  291.   #--------------------------------------------------------------------------
  292.   def moving_a?
  293.     if @move == false
  294.       if (@move_route.list[@move_route_index].code <= 14 or
  295.           @move_route.list[@move_route_index].code == 25)
  296.         @move = true
  297.       end
  298.       return false
  299.     end
  300.     moving?
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● フレーム更新 (ジャンプ)
  304.   #--------------------------------------------------------------------------
  305.   def update_jump
  306.     # ジャンプカウントを 1 減らす
  307.     @jump_count -= 1
  308.     # 新しい座標を計算
  309.     @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  310.     @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  311.     if @jump_count == 0
  312.       @revise_x = 0
  313.       @revise_y = 0
  314.     end
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● 移動タイプ : カスタム
  318.   #--------------------------------------------------------------------------
  319.   def move_type_custom
  320.     unless @dot_m
  321.       super
  322.       return
  323.     end
  324.     # 停止中でなければ中断
  325.     if jumping? or moving_a?
  326.       return
  327.     end
  328.     # 移動コマンドのリストの最後に到達するまでループ
  329.     while @move_route_index < @move_route.list.size
  330.       # 移動コマンドを取得
  331.       command = @move_route.list[@move_route_index]
  332.       # コマンドコード 0 番 (リストの最後) の場合
  333.       if command.code == 0
  334.         # オプション [動作を繰り返す] が ON の場合
  335.         if @move_route.repeat
  336.           # 移動ルートのインデックスを最初に戻す
  337.           @move_route_index = 0
  338.         end
  339.         # オプション [動作を繰り返す] が OFF の場合
  340.         unless @move_route.repeat
  341.           # 移動ルート強制中の場合
  342.           if @move_route_forcing and not @move_route.repeat
  343.             # 移動ルートの強制を解除
  344.             @move_route_forcing = false
  345.             # オリジナルの移動ルートを復帰
  346.             @move_route = @original_move_route
  347.             @move_route_index = @original_move_route_index
  348.             @original_move_route = nil
  349.           end
  350.           # 停止カウントをクリア
  351.           @stop_count = 0
  352.         end
  353.         return
  354.       end
  355.       # 移動系コマンド (下に移動~ジャンプ) の場合
  356.       if command.code <= 14
  357.         # コマンドコードで分岐
  358.         case command.code
  359.         when 1  # 下に移動
  360.           move_down
  361.         when 2  # 左に移動
  362.           move_left
  363.         when 3  # 右に移動
  364.           move_right
  365.         when 4  # 上に移動
  366.           move_up
  367.         when 5  # 左下に移動
  368.           move_lower_left
  369.         when 6  # 右下に移動
  370.           move_lower_right
  371.         when 7  # 左上に移動
  372.           move_upper_left
  373.         when 8  # 右上に移動
  374.           move_upper_right
  375.         when 9  # ランダムに移動
  376.           move_random
  377.         when 10  # プレイヤーに近づく
  378.           move_toward_player
  379.         when 11  # プレイヤーから遠ざかる
  380.           move_away_from_player
  381.         when 12  # 一歩前進
  382.           move_forward
  383.         when 13  # 一歩後退
  384.           move_backward
  385.         when 14  # ジャンプ
  386.           jump(command.parameters[0], command.parameters[1])
  387.         end
  388.         # オプション [移動できない場合は無視] が OFF で、移動失敗の場合
  389.         if not @move_route.skippable and not moving? and not jumping?
  390.           return
  391.         end
  392.         @move_route_index += 1
  393.         return
  394.       end
  395.       # ウェイトの場合
  396.       if command.code == 15
  397.         # ウェイトカウントを設定
  398.         @wait_count = command.parameters[0] * 2 - 1
  399.         @move_route_index += 1
  400.         return
  401.       end
  402.       # 向き変更系のコマンドの場合
  403.       if command.code >= 16 and command.code <= 26
  404.         # コマンドコードで分岐
  405.         case command.code
  406.         when 16  # 下を向く
  407.           turn_down
  408.         when 17  # 左を向く
  409.           turn_left
  410.         when 18  # 右を向く
  411.           turn_right
  412.         when 19  # 上を向く
  413.           turn_up
  414.         when 20  # 右に 90 度回転
  415.           turn_right_90
  416.         when 21  # 左に 90 度回転
  417.           turn_left_90
  418.         when 22  # 180 度回転
  419.           turn_180
  420.         when 23  # 右か左に 90 度回転
  421.           turn_right_or_left_90
  422.         when 24  # ランダムに方向転換
  423.           turn_random
  424.         when 25  # プレイヤーの方を向く
  425.           turn_toward_player
  426.         when 26  # プレイヤーの逆を向く
  427.           turn_away_from_player
  428.         end
  429.         @move_route_index += 1
  430.         return
  431.       end
  432.       # その他のコマンドの場合
  433.       if command.code >= 27
  434.         # コマンドコードで分岐
  435.         case command.code
  436.         when 27  # スイッチ ON
  437.           $game_switches[command.parameters[0]] = true
  438.           $game_map.need_refresh = true
  439.         when 28  # スイッチ OFF
  440.           $game_switches[command.parameters[0]] = false
  441.           $game_map.need_refresh = true
  442.         when 29  # 移動速度の変更
  443.           @move_speed = command.parameters[0]
  444.         when 30  # 移動頻度の変更
  445.           @move_frequency = command.parameters[0]
  446.         when 31  # 移動時アニメ ON
  447.           @walk_anime = true
  448.         when 32  # 移動時アニメ OFF
  449.           @walk_anime = false
  450.         when 33  # 停止時アニメ ON
  451.           @step_anime = true
  452.         when 34  # 停止時アニメ OFF
  453.           @step_anime = false
  454.         when 35  # 向き固定 ON
  455.           @direction_fix = true
  456.         when 36  # 向き固定 OFF
  457.           @direction_fix = false
  458.         when 37  # すり抜け ON
  459.           @through = true
  460.         when 38  # すり抜け OFF
  461.           @through = false
  462.         when 39  # 最前面に表示 ON
  463.           @always_on_top = true
  464.         when 40  # 最前面に表示 OFF
  465.           @always_on_top = false
  466.         when 41  # グラフィック変更
  467.           @tile_id = 0
  468.           @character_name = command.parameters[0]
  469.           @character_hue = command.parameters[1]
  470.           if @original_direction != command.parameters[2]
  471.             @direction = command.parameters[2]
  472.             @original_direction = @direction
  473.             @prelock_direction = 0
  474.           end
  475.           if @original_pattern != command.parameters[3]
  476.             @pattern = command.parameters[3]
  477.             @original_pattern = @pattern
  478.           end
  479.         when 42  # 不透明度の変更
  480.           @opacity = command.parameters[0]
  481.         when 43  # 合成方法の変更
  482.           @blend_type = command.parameters[0]
  483.         when 44  # SE の演奏
  484.           $game_system.se_play(command.parameters[0])
  485.         when 45  # スクリプト
  486.           result = eval(command.parameters[0])
  487.         end
  488.         @move_route_index += 1
  489.         return
  490.       end
  491.     end
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 下に移動
  495.   #--------------------------------------------------------------------------
  496.   def move_down_p
  497.     # 下を向く
  498.     turn_down
  499.     # 移動距離を算出
  500.     distance = 2 ** @move_speed
  501.     down1(((@x * 128 + @revise_x) / 128.0).round,
  502.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  503.   end
  504.   def move_down_aaaagq
  505.     distance = 2 ** @move_speed
  506.     down1(((@x * 128 + @revise_x) / 128.0).round,
  507.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # ● 下に移動可能かどうかの判定1
  511.   #--------------------------------------------------------------------------
  512.   def down1(x, y, distance, down = false)
  513.     result = down2(x, y, distance)
  514.     if result == false
  515.       @event_run = check_event_trigger_touch(x, y+1)
  516.       return result
  517.     end
  518.     if @revise_x < -SIDE
  519.       result = down2(x, y + 1, distance, 4)
  520.       result &= down2(x - 1, y, distance)
  521.       if result == false
  522.         if down
  523.           move_lower_right_p
  524.           if @revise_x > SIDE
  525.             @revise_x = SIDE
  526.           end
  527.         end
  528.         return result
  529.       end
  530.     elsif @revise_x > SIDE
  531.       result = down2(x, y + 1, distance, 6)
  532.       result &= down2(x + 1, y, distance)
  533.       if result == false
  534.         if down
  535.           move_lower_left_p
  536.           if @revise_x < -SIDE
  537.             @revise_x = -SIDE
  538.           end
  539.         end
  540.         return result
  541.       end
  542.     end
  543.     # 下に移動可能ならば距離分移動
  544.     @revise_y += distance
  545.     return result
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # ● 下に移動可能かどうかの判定2
  549.   #--------------------------------------------------------------------------
  550.   def down2(x, y, distance, d = 2)
  551.     if @revise_y + distance > DOWN
  552.       unless passable?(x, y, d)
  553.         if @revise_y < DOWN
  554.           @revise_y = DOWN
  555.         end
  556.         return false
  557.       end
  558.     end
  559.     return true
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # ● 左に移動
  563.   #--------------------------------------------------------------------------
  564.   def move_left_p
  565.     # 左を向く
  566.     turn_left
  567.     distance = 2 ** @move_speed
  568.     left1(((@x * 128 + @revise_x) / 128.0).round,
  569.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  570.   end
  571.   #--------------------------------------------------------------------------
  572.   # ● 左に移動可能かどうかの判定1
  573.   #--------------------------------------------------------------------------
  574.   def left1(x, y, distance, left = false)
  575.     result = left2(x, y, distance)
  576.     if result == false
  577.       @event_run = check_event_trigger_touch(x-1, y)
  578.       return result
  579.     end
  580.     if @revise_y < -UP and $ud_ok
  581.       result = left2(x - 1, y, distance, 8)
  582.       result &= left2(x, y - 1, distance)
  583.       if result == false
  584.         if left
  585.           move_lower_left_p
  586.           if @revise_y > DOWN
  587.             @revise_y = DOWN
  588.           end
  589.         end
  590.         return result
  591.       end
  592.     elsif @revise_y > DOWN and $ud_ok
  593.       result = left2(x - 1, y, distance, 2)
  594.       result &= left2(x, y + 1, distance)
  595.       if result == false
  596.         if left
  597.           move_upper_left_p
  598.           if @revise_y < -UP
  599.             @revise_y = -UP
  600.           end
  601.         end
  602.         return result
  603.       end
  604.     end
  605.     @revise_x -= distance
  606.     return result
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ● 左に移動可能かどうかの判定2
  610.   #--------------------------------------------------------------------------
  611.   def left2(x, y, distance, d = 4)
  612.     if @revise_x - distance < -SIDE
  613.       unless passable?(x, y, d)
  614.         if @revise_x > -SIDE
  615.           @revise_x = -SIDE
  616.         end
  617.         return false
  618.       end
  619.     end
  620.     return true
  621.   end
  622.   #--------------------------------------------------------------------------
  623.   # ● 右に移動
  624.   #--------------------------------------------------------------------------
  625.   def move_right_p
  626.       # 右を向く
  627.       turn_right
  628.     distance = 2 ** @move_speed
  629.     right1(((@x * 128 + @revise_x) / 128.0).round,
  630.             ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  631.   end
  632.   #--------------------------------------------------------------------------
  633.   # ● 右に移動可能かどうかの判定1
  634.   #--------------------------------------------------------------------------
  635.   def right1(x, y, distance, right = false)
  636.     result = right2(x, y, distance)
  637.     if result == false
  638.       @event_run = check_event_trigger_touch(x+1, y)
  639.       return result
  640.     end
  641.     if @revise_y < -UP and $ud_ok
  642.       result = right2(x + 1, y, distance, 8)
  643.       result &= right2(x, y - 1, distance)
  644.       if result == false
  645.         if right
  646.           move_lower_right_p
  647.           if @revise_y > DOWN
  648.             @revise_y = DOWN
  649.           end
  650.         end
  651.         return result
  652.       end
  653.     elsif @revise_y > DOWN and $ud_ok
  654.       result = right2(x + 1, y, distance, 2)
  655.       result &= right2(x, y + 1, distance)
  656.       if result == false
  657.         if right
  658.           move_upper_right_p
  659.           if @revise_y < -UP
  660.             @revise_y = -UP
  661.           end
  662.         end
  663.         return result
  664.       end
  665.     end
  666.     @revise_x += distance
  667.     return result
  668.   end
  669.   #--------------------------------------------------------------------------
  670.   # ● 右に移動可能かどうかの判定2
  671.   #--------------------------------------------------------------------------
  672.   def right2(x, y, distance, d = 6)
  673.     if @revise_x + distance > SIDE
  674.       unless passable?(x, y, d)
  675.         if @revise_x < SIDE
  676.           @revise_x = SIDE
  677.         end
  678.         return false
  679.       end
  680.     end
  681.     return true
  682.   end
  683.   #--------------------------------------------------------------------------
  684.   # ● 上に移動
  685.   #--------------------------------------------------------------------------
  686.   def move_up_p
  687.     # 上を向く
  688.     turn_up
  689.     # 下に移動
  690.     distance = 2 ** @move_speed
  691.     up1(((@x * 128 + @revise_x) / 128.0).round,
  692.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  693.   end
  694.   def move_up_aaaagq
  695.     distance = 2 ** @move_speed
  696.     up1(((@x * 128 + @revise_x) / 128.0).round,
  697.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  698.   end
  699.   #--------------------------------------------------------------------------
  700.   # ● 上に移動可能かどうかの判定1
  701.   #--------------------------------------------------------------------------
  702.   def up1(x, y, distance, up = false)
  703.     result = up2(x, y, distance)
  704.     if result == false
  705.       @event_run = check_event_trigger_touch(x, y-1)
  706.       return result
  707.     end
  708.     if @revise_x < -SIDE
  709.       result = up2(x, y - 1, distance, 4)
  710.       result &= up2(x - 1, y, distance)
  711.       if result == false
  712.         if up
  713.           move_upper_right_p
  714.           if @revise_x > SIDE
  715.             @revise_x = SIDE
  716.           end
  717.         end
  718.         return result
  719.       end
  720.     elsif @revise_x > SIDE
  721.       result = up2(x, y - 1, distance, 6)
  722.       result &= up2(x + 1, y, distance)
  723.       if result == false
  724.         if up
  725.           move_upper_left_p
  726.           if @revise_x < -SIDE
  727.             @revise_x = -SIDE
  728.           end
  729.         end
  730.         return result
  731.       end
  732.     end
  733.     @revise_y -= distance
  734.     return result
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # ● 上に移動可能かどうかの判定2
  738.   #--------------------------------------------------------------------------
  739.   def up2(x, y, distance, d = 8)
  740.     if @revise_y - distance < -UP
  741.       unless passable?(x, y, d)
  742.         if @revise_y > -UP
  743.           @revise_y = -UP
  744.         end
  745.         return false
  746.       end
  747.     end
  748.     return true
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ● 左下に移動
  752.   #--------------------------------------------------------------------------
  753.   def move_lower_left_p
  754.     # 向き固定でない場合
  755.     unless @direction_fix
  756.       # 右向きだった場合は左を、上向きだった場合は下を向く
  757.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  758.     end
  759.     # 左下に移動
  760.     distance = (2 ** @move_speed) / Math.sqrt(2)
  761.     if @direction == 2
  762.       turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  763.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  764.       turn_down if @event_run
  765.       unless @event_run
  766.         if last_move?(@real_x, @real_y, 2, distance)
  767.           result = check_event_trigger_here([1,2], false)
  768.           if result == true
  769.             return
  770.           end
  771.         end
  772.         move_on
  773.         if @revise_y > DOWN and -UP > @revise_y - distance
  774.           @revise_y = DOWN
  775.         end
  776.         turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  777.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  778.         turn_left if @event_run
  779.       end
  780.     else
  781.       turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  782.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  783.       turn_left if @event_run
  784.       unless @event_run
  785.         if last_move?(@real_x, @real_y, 4, distance)
  786.           result = check_event_trigger_here([1,2], false)
  787.           if result == true
  788.             return
  789.           end
  790.         end
  791.         move_on
  792.         if  @revise_x + distance> SIDE and -SIDE > @revise_x
  793.           @revise_x = -SIDE
  794.         end
  795.         turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  796.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  797.         turn_down if @event_run
  798.       end
  799.     end
  800.   end
  801.   #--------------------------------------------------------------------------
  802.   # ● 右下に移動
  803.   #--------------------------------------------------------------------------
  804.   def move_lower_right_p
  805.     # 向き固定でない場合
  806.     unless @direction_fix
  807.       # 左向きだった場合は右を、上向きだった場合は下を向く
  808.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  809.     end
  810.     # 右下に移動
  811.     distance = (2 ** @move_speed) / Math.sqrt(2)
  812.     if @direction == 2
  813.       turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  814.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  815.       turn_down if @event_run
  816.       unless @event_run
  817.         if last_move?(@real_x, @real_y, 2, distance)
  818.           result = check_event_trigger_here([1,2], false)
  819.           if result == true
  820.             return
  821.           end
  822.         end
  823.         move_on
  824.         if @revise_y > DOWN and -UP > @revise_y - distance
  825.           @revise_y = DOWN
  826.         end
  827.         turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  828.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  829.         turn_right if @event_run
  830.       end
  831.     else
  832.       turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  833.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  834.       turn_right if @event_run
  835.       unless @event_run
  836.         if last_move?(@real_x, @real_y, 6, distance)
  837.           result = check_event_trigger_here([1,2], false)
  838.           if result == true
  839.             return
  840.           end
  841.         end
  842.         move_on
  843.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  844.           @revise_x = SIDE
  845.         end
  846.         turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  847.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  848.         turn_down if @event_run
  849.       end
  850.     end
  851.   end
  852.   #--------------------------------------------------------------------------
  853.   # ● 左上に移動
  854.   #--------------------------------------------------------------------------
  855.   def move_upper_left_p
  856.     # 向き固定でない場合
  857.     unless @direction_fix
  858.       # 右向きだった場合は左を、下向きだった場合は上を向く
  859.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  860.     end
  861.     # 左上に移動
  862.     distance = (2 ** @move_speed) / Math.sqrt(2)
  863.     if @direction == 8
  864.       turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  865.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  866.       turn_up if @event_run
  867.       unless @event_run
  868.         if last_move?(@real_x, @real_y, 8, distance)
  869.           result = check_event_trigger_here([1,2], false)
  870.           if result == true
  871.             return
  872.           end
  873.         end
  874.         move_on
  875.         if @revise_y + distance > DOWN and -UP > @revise_y
  876.           @revise_y = -UP
  877.         end
  878.         turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  879.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  880.         turn_left if @event_run
  881.       end
  882.     else
  883.       turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  884.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  885.       turn_left if @event_run
  886.       unless @event_run
  887.         if last_move?(@real_x, @real_y, 4, distance)
  888.           result = check_event_trigger_here([1,2], false)
  889.           if result == true
  890.             return
  891.           end
  892.         end
  893.         move_on
  894.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  895.           @revise_x = SIDE
  896.         end
  897.         turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  898.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  899.         turn_up if @event_run
  900.       end
  901.     end
  902.   end
  903.   #--------------------------------------------------------------------------
  904.   # ● 右上に移動
  905.   #--------------------------------------------------------------------------
  906.   def move_upper_right_p
  907.     # 向き固定でない場合
  908.     unless @direction_fix
  909.       # 左向きだった場合は右を、下向きだった場合は上を向く
  910.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  911.     end
  912.     # 右上に移動
  913.     distance = (2 ** @move_speed) / Math.sqrt(2)
  914.     if @direction == 8
  915.       turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  916.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  917.       turn_up if @event_run
  918.       unless @event_run
  919.         if last_move?(@real_x, @real_y, 8, distance)
  920.           result = check_event_trigger_here([1,2], false)
  921.           if result == true
  922.             return
  923.           end
  924.         end
  925.         move_on
  926.         if @revise_y + distance > DOWN and -UP > @revise_y
  927.           @revise_y = -UP
  928.         end
  929.         turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  930.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  931.         turn_right if @event_run
  932.       end
  933.     else
  934.       turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  935.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  936.       turn_right if @event_run
  937.       unless @event_run
  938.         if last_move?(@real_x, @real_y, 6, distance)
  939.           result = check_event_trigger_here([1,2], false)
  940.           if result == true
  941.             return
  942.           end
  943.         end
  944.         move_on
  945.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  946.           @revise_x = SIDE
  947.         end
  948.         turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  949.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  950.         turn_up if @event_run
  951.       end
  952.     end
  953.   end
  954.   #--------------------------------------------------------------------------
  955.   # ● 同位置のイベント起動判定
  956.   #--------------------------------------------------------------------------
  957.   def check_event_trigger_here(triggers, run = true)
  958.     result = false
  959.     # イベント実行中の場合
  960.     if $game_system.map_interpreter.running?
  961.       return result
  962.     end
  963.     # 全イベントのループ
  964.     for event in $game_map.events.values
  965.       # イベントの座標とトリガーが一致した場合
  966.       if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  967.           event.y == ((@y * 128 + @revise_y) / 128.0).round and
  968.           triggers.include?(event.trigger)
  969.         # ジャンプ中以外で、起動判定が同位置のイベントなら
  970.         if not event.jumping? and event.over_trigger?
  971.           if event.list.size > 1
  972.             if run == true
  973.               event.start
  974.             end
  975.             result = true
  976.           end
  977.         end
  978.       end
  979.     end
  980.     return result
  981.   end
  982.   #--------------------------------------------------------------------------
  983.   # ● 座標修正
  984.   #--------------------------------------------------------------------------
  985.   def move_on
  986.     if @y < (@y + @revise_y / 128.0).round
  987.       @y += 1
  988.       @revise_y -= 128
  989.     end
  990.     if @x > (@x + @revise_x / 128.0).round
  991.       @x -= 1
  992.       @revise_x += 128
  993.     end
  994.     if @x < (@x + @revise_x / 128.0).round
  995.       @x += 1
  996.       @revise_x -= 128
  997.     end
  998.     if @y > (@y + @revise_y / 128.0).round
  999.       @y -= 1
  1000.       @revise_y += 128
  1001.     end
  1002.   end
  1003.   #--------------------------------------------------------------------------
  1004.   # ● アニメーションアップデート
  1005.   #--------------------------------------------------------------------------
  1006.   def anime_update
  1007.     # 移動時アニメが ON の場合
  1008.     if @walk_anime
  1009.       # アニメカウントを 1.5 増やす
  1010.       @anime_count += 1.5
  1011.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1012.     elsif @step_anime
  1013.       # アニメカウントを 1 増やす
  1014.       @anime_count += 1
  1015.     end
  1016.     # アニメカウントが最大値を超えた場合
  1017.     # ※最大値は、基本値 18 から移動速度 * 1 を引いた値
  1018.     if @anime_count > 18 - @move_speed * 2
  1019.       # 停止時アニメが OFF かつ 停止中の場合
  1020.       if not @step_anime and @stop_count > 0
  1021.         # パターンをオリジナルに戻す
  1022.         @pattern = @original_pattern
  1023.       # 停止時アニメが ON または 移動中の場合
  1024.       else
  1025.         # パターンを更新
  1026.         @pattern = (@pattern + 1) % 4
  1027.       end
  1028.       # アニメカウントをクリア
  1029.       @anime_count = 0
  1030.     end
  1031.   end
  1032.   #--------------------------------------------------------------------------
  1033.   # ● 指定位置に移動
  1034.   #--------------------------------------------------------------------------
  1035.   # オリジナルのイベントを改名
  1036.   alias :moveto_original :moveto
  1037.   def moveto(x, y)
  1038.     # 補正座標を初期化
  1039.     @revise_x = 0
  1040.     @revise_y = 0
  1041.     # オリジナルのイベントを呼び出し
  1042.     moveto_original(x, y)
  1043.   end
  1044.   #--------------------------------------------------------------------------
  1045.   # ● 移動したかどうかの判定
  1046.   #--------------------------------------------------------------------------
  1047.   def last_move?(x, y, direction, distance)
  1048.     if direction == 2 or direction == 6
  1049.       distance *= -1
  1050.     end
  1051.     if (direction == 2 or direction == 8) and
  1052.         (y / 128.0).round != ((y - distance) / 128.0).round
  1053.       return true
  1054.     end
  1055.     if (direction == 4 or direction == 6) and
  1056.         (x / 128.0).round != ((x - distance) / 128.0).round
  1057.       return true
  1058.     end
  1059.     return false
  1060.   end
  1061. end
  1062.  
  1063. #==============================================================================
  1064. # ■ Game_Character (分割定義 1)
  1065. #------------------------------------------------------------------------------
  1066. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  1067. # クラスのスーパークラスとして使用されます。
  1068. #==============================================================================
  1069.  
  1070. class Game_Character
  1071.   #--------------------------------------------------------------------------
  1072.   # ● フレーム更新 (移動)
  1073.   #--------------------------------------------------------------------------
  1074.   def update_move
  1075.     # 移動速度からマップ座標系での移動距離に変換
  1076.     distance = 2 ** @move_speed
  1077.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  1078.       distance /= Math.sqrt(2)
  1079.     end
  1080.     # 論理座標が実座標より下の場合
  1081.     if @y * 128 > @real_y
  1082.       # 下に移動
  1083.       @real_y = [@real_y + distance, @y * 128].min
  1084.     end
  1085.     # 論理座標が実座標より左の場合
  1086.     if @x * 128 < @real_x
  1087.       # 左に移動
  1088.       @real_x = [@real_x - distance, @x * 128].max
  1089.     end
  1090.     # 論理座標が実座標より右の場合
  1091.     if @x * 128 > @real_x
  1092.       # 右に移動
  1093.       @real_x = [@real_x + distance, @x * 128].min
  1094.     end
  1095.     # 論理座標が実座標より上の場合
  1096.     if @y * 128 < @real_y
  1097.       # 上に移動
  1098.       @real_y = [@real_y - distance, @y * 128].max
  1099.     end
  1100.     # 移動時アニメが ON の場合
  1101.     if @walk_anime
  1102.       # アニメカウントを 1.5 増やす
  1103.       @anime_count += 1.5
  1104.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1105.     elsif @step_anime
  1106.       # アニメカウントを 1 増やす
  1107.       @anime_count += 1
  1108.     end
  1109.   end
  1110. end
  1111.  
  1112. #==============================================================================
  1113. # ■ Game_Event
  1114. #------------------------------------------------------------------------------
  1115. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  1116. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  1117. #==============================================================================
  1118.  
  1119. class Game_Event < Game_Character
  1120.   #--------------------------------------------------------------------------
  1121.   # ● イベント起動
  1122.   #--------------------------------------------------------------------------
  1123.   def start
  1124.     # 実行内容が空でない場合
  1125.     if @list.size > 1
  1126.       # $game_player.event が0でない場合
  1127.       if $game_player.event != 0
  1128.         # 移動速度を $game_player.event にする
  1129.         $game_player.move_speed = $game_player.event
  1130.       end
  1131.       @starting = true
  1132.     end
  1133.   end
  1134. end
  1135.  
  1136. #==============================================================================
  1137. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1138. #==============================================================================

QQ截图20150208175742.jpg (86.74 KB, 下载次数: 7)

QQ截图20150208175742.jpg

Lv1.梦旅人

梦石
0
星屑
155
在线时间
332 小时
注册时间
2013-7-6
帖子
356
2
发表于 2015-2-11 17:51:36 | 只看该作者
  1. $ud_ok = false #上下失效
  2. $airjump = 0  #空中连跳
  3. #==============================================================================
  4. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  5. #==============================================================================

  6. # ————————————————————————————————————
  7. # 全方向ドット移動 Ver ε
  8. # 配布元・サポートURL
  9. # [url]http://members.jcom.home.ne.jp/cogwheel/[/url]$game_system.se_play($data_system.cancel_se)

  10. #==============================================================================
  11. # ■ Game_Player
  12. #------------------------------------------------------------------------------
  13. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  14. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  15. #==============================================================================
  16. class Game_Player < Game_Character
  17.   #--------------------------------------------------------------------------
  18.   # ● 定数
  19.   #--------------------------------------------------------------------------
  20.   UP    = 48                  # 上方向の余裕(0 < UP < 63)
  21.   DOWN  = 16                  # 下方向の余裕(0 < DOWN <63)
  22.   SIDE  = 32                  # 左右方向の余裕(0 < SIDE <63)
  23.   SLANT = false               # 移動ルートの斜め移動時、速度修正
  24.   JUMPMAX = 100              
  25.   JUMPADD = 10              
  26.   #--------------------------------------------------------------------------
  27.   # ● 公開インスタンス変数
  28.   #--------------------------------------------------------------------------
  29.   attr_reader   :event                    # イベント時移動速度
  30.   attr_accessor :move_speed               # 移動速度
  31.   #--------------------------------------------------------------------------
  32.   # ● フレーム更新
  33.   #--------------------------------------------------------------------------
  34.   alias :update_original :update
  35.   def update
  36.     # @walk:歩行速度 @dash:ダッシュ時移動速度
  37.     # @event:イベント時移動速度(0の時は、イベント時に速度変更をしない)
  38.     @walk  = $game_variables[52]
  39.     @dash  = $game_variables[52]+1
  40.     @event = 4
  41.     @dot_m = true
  42.     #ダッシュ機能。エンターキーが押されている間、移動速度を変更する。
  43.     unless moving? or $game_system.map_interpreter.running? or
  44.             @move_route_forcing or $game_temp.message_window_showing
  45.       if @walk != @dash
  46.         if Input.press?(Input::C)
  47.           if @move_speed != @dash
  48.             @move_speed = @dash
  49.           end
  50.         else
  51.           if @move_speed != @walk
  52.             @move_speed = @walk
  53.           end
  54.         end
  55.       end
  56.     end
  57.     if @revise_x == nil and @revise_y == nil
  58.       @revise_x = 0
  59.       @revise_y = 0
  60.     end
  61.     unless @dot_m
  62.       update_original
  63.       return
  64.     end
  65.     if @move_route_forcing
  66.       # ローカル変数に移動中かどうかを記憶
  67.       last_moving = moving?
  68.       # ローカル変数に座標を記憶
  69.       last_real_x = @real_x
  70.       last_real_y = @real_y
  71.       # 座標がずれている場合
  72.       if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
  73.         if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
  74.           @revise_x = @real_x - @x * 128
  75.           @revise_y = @real_y - @y * 128
  76.         end
  77.         # 移動距離distance1と目標距離distance2を設定
  78.         distance1 = 2 ** @move_speed
  79.         distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
  80.         # 移動距離が目標距離を越えた場合
  81.         if distance1 > distance2
  82.           # 強制的に補正座標を零にする
  83.           @real_x = @real_x - @revise_x
  84.           @real_y = @real_y - @revise_y
  85.           @revise_x = 0
  86.           @revise_y = 0
  87.           anime_update
  88.         # 移動距離が目標距離に達しない場合
  89.         else
  90.           # 移動距離分目標距離に近づく
  91.           @real_x -= (distance1 * @revise_x / distance2).round
  92.           @real_y -= (distance1 * @revise_y / distance2).round
  93.           @revise_x = @real_x - @x * 128
  94.           @revise_y = @real_y - @y * 128
  95.           anime_update
  96.         end
  97.       else
  98.         super
  99.       end
  100.     else
  101.       @move = false
  102.       # 移動中、イベント実行中、移動ルート強制中、
  103.       # メッセージウィンドウ表示中のいずれでもない場合
  104.       unless moving? or $game_system.map_interpreter.running? or
  105.              @move_route_forcing or $game_temp.message_window_showing
  106.         @event_run = false
  107.         # 方向ボタンが押されていれば、その方向へプレイヤーを移動
  108. #---------------------------上下失效-----------------------------------------
  109.       case Input.dir8
  110.         when 1
  111.           $ud_ok ? move_lower_left_p : move_left_p
  112.         when 2
  113. #          $ud_ok ? move_down_p : move_down_aaaagq
  114.           move_down_p if $ud_ok
  115.         when 3
  116.          $ud_ok ? move_lower_right_p : move_right_p
  117.         when 4
  118.           move_left_p
  119.         when 6
  120.           move_right_p
  121.         when 7
  122.          $ud_ok ? move_upper_left_p : move_left_p
  123.         when 8
  124. #         $ud_ok ? move_up_p : move_up_aaaagq
  125.          move_up_p if $ud_ok
  126.         when 9
  127.          $ud_ok ? move_upper_right_p : move_right_p
  128.         end
  129.       end
  130.       # ローカル変数に座標を記憶
  131.       last_real_x = @real_x
  132.       last_real_y = @real_y
  133.       # 移動処理
  134.       @real_x = @x * 128 + @revise_x
  135.       @real_y = @y * 128 + @revise_y
  136.       # ローカル変数に移動中かどうかを記憶
  137.       last_moving = moving?
  138.       # 座標更新
  139.       move_on
  140.       # 現在の座標と以前の座標が異なる場合
  141.       if (last_real_x != @real_x or last_real_y != @real_y)
  142.         @move_distance = 0 if @move_distance == nil
  143.         @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
  144.                                       (last_real_y - @real_y) ** 2)
  145.         if @move_distance >= 128
  146.           @move_distance %= 128
  147.           increase_steps
  148.         end
  149.         # アニメーションを更新
  150.         anime_update
  151.       else
  152.         @pattern = 0
  153.       end
  154.     end
  155.     # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合
  156.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  157.       # マップを下にスクロール
  158.       $game_map.scroll_down(@real_y - last_real_y)
  159.     end
  160.     # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合
  161.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  162.       # マップを左にスクロール
  163.       $game_map.scroll_left(last_real_x - @real_x)
  164.     end
  165.     # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合
  166.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  167.       # マップを右にスクロール
  168.       $game_map.scroll_right(@real_x - last_real_x)
  169.     end
  170.     # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合
  171.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  172.       # マップを上にスクロール
  173.       $game_map.scroll_up(last_real_y - @real_y)
  174.     end
  175.     # 前回プレイヤーが移動中だった場合
  176.     if last_moving
  177.       # 同位置のイベントとの接触によるイベント起動判定
  178.       result = check_event_trigger_here([1,2])
  179.       if result == true
  180.         if (last_real_x / 128.0).round != @x and
  181.             (last_real_y / 128.0).round != @y
  182.           if @direction == 2 or @direction == 8
  183.             if (last_real_x / 128.0).round > @x
  184.               turn_left
  185.             else
  186.               turn_right
  187.             end
  188.           else
  189.             if (last_real_y / 128.0).round > @y
  190.               turn_up
  191.             else
  192.               turn_down
  193.             end
  194.           end
  195.         elsif (last_real_x / 128.0).round > @x
  196.           turn_left
  197.         elsif (last_real_x / 128.0).round < @x
  198.           turn_right
  199.         elsif (last_real_y / 128.0).round > @y
  200.           turn_up
  201.         elsif (last_real_y / 128.0).round < @y
  202.           turn_down
  203.         end
  204.       end
  205.       # 起動したイベントがない場合
  206.       if result == false
  207.         # デバッグモードが ON かつ CTRL キーが押されている場合を除き
  208.         unless $DEBUG and Input.press?(Input::CTRL)
  209.           # エンカウント カウントダウン
  210.           if @encounter_count > 0
  211.             @encounter_count -= 1
  212.           end
  213.         end
  214.       end
  215.     end
  216. #-----------------------按跳跃-----------------------------------------------
  217. # A ボタンが押された場合
  218.     if Input.press?(Input::A) and not $ud_ok
  219.     # 获取角色
  220.     actor = $game_actors[1]
  221.     # 更改图形
  222.     if actor != nil
  223.       actor.set_graphic("jump.png", 0, "", 0)
  224.     end
  225.     # 刷新角色
  226.     $game_player.refresh
  227.    
  228.    
  229.       @twojump = 1 if @twojump == 0 and down1(((@x * 128 + @revise_x) / 128.0).round,
  230.           ((@y * 128 + @revise_y) / 128.0).round, 5, true)
  231.       if (not @apassed) and @twojump <= $airjump
  232.         @apassed = true
  233.         $game_system.se_play($data_system.cancel_se)
  234.         @jumpnow = JUMPMAX
  235.         @twojump += 1
  236.       else
  237.         @jumpnow += 3
  238.       end
  239.     else
  240.       @apassed = false
  241.     end
  242. #----------------------自由落体--------------------------------
  243.     if not $ud_ok
  244.       @jumpnow -= 10
  245.       if @jumpnow < 0
  246.         @jumpnow = [@jumpnow, -JUMPMAX].max
  247.         if not down1(((@x * 128 + @revise_x) / 128.0).round,
  248.           ((@y * 128 + @revise_y) / 128.0).round, -@jumpnow, true)
  249.           @jumpnow = 0
  250.           @twojump = 0
  251.          
  252.           $game_character_temp = $game_actors[1].character_name if $game_character_temp.nil?
  253.           if !$game_character_temp.nil?
  254.             # 获取角色
  255.             actor = $game_actors[1]
  256.             # 更改图形
  257.             if actor != nil
  258.               actor.set_graphic($game_character_temp, 0, "", 0)
  259.             end
  260.             # 刷新角色
  261.             $game_player.refresh
  262.           end
  263.         end
  264.       elsif @jumpnow > 0
  265.         @jumpnow = [@jumpnow, JUMPMAX].min
  266.         if not up1(((@x * 128 + @revise_x) / 128.0).round,
  267.           ((@y * 128 + @revise_y) / 128.0).round, @jumpnow, true)
  268.           @jumpnow = 0
  269.         end
  270.       end
  271.     end
  272.     if Input.trigger?(Input::C)
  273.       # 同位置および正面のイベント起動判定
  274.       check_event_trigger_here([0])
  275.       check_event_trigger_there([0,1,2])
  276.     end
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● オブジェクト初期化
  280.   #--------------------------------------------------------------------------
  281.   def initialize
  282.     @jumpnow = 0
  283.     @twojump = 0
  284.     @apassed = false
  285.     @revise_x = 0
  286.     @revise_y = 0
  287.     @move == false
  288.     super
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 移動判定
  292.   #--------------------------------------------------------------------------
  293.   def moving?
  294.     unless @dot_m
  295.       result = super
  296.       return result
  297.     end
  298.     # 強制移動の場合オリジナルの判定をさせる
  299.     if @move_route_forcing
  300.       if @move == false
  301.         return false
  302.       end
  303.       super
  304.     # 通常時は現座標が実座標と異なる場合のみ移動中と判定
  305.     else
  306.       return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  307.     end
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 移動判定
  311.   #--------------------------------------------------------------------------
  312.   def moving_a?
  313.     if @move == false
  314.       if (@move_route.list[@move_route_index].code <= 14 or
  315.           @move_route.list[@move_route_index].code == 25)
  316.         @move = true
  317.       end
  318.       return false
  319.     end
  320.     moving?
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● フレーム更新 (ジャンプ)
  324.   #--------------------------------------------------------------------------
  325.   def update_jump
  326.     # ジャンプカウントを 1 減らす
  327.     @jump_count -= 1
  328.     # 新しい座標を計算
  329.     @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  330.     @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  331.     if @jump_count == 0
  332.       @revise_x = 0
  333.       @revise_y = 0
  334.     end
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 移動タイプ : カスタム
  338.   #--------------------------------------------------------------------------
  339.   def move_type_custom
  340.     unless @dot_m
  341.       super
  342.       return
  343.     end
  344.     # 停止中でなければ中断
  345.     if jumping? or moving_a?
  346.       return
  347.     end
  348.     # 移動コマンドのリストの最後に到達するまでループ
  349.     while @move_route_index < @move_route.list.size
  350.       # 移動コマンドを取得
  351.       command = @move_route.list[@move_route_index]
  352.       # コマンドコード 0 番 (リストの最後) の場合
  353.       if command.code == 0
  354.         # オプション [動作を繰り返す] が ON の場合
  355.         if @move_route.repeat
  356.           # 移動ルートのインデックスを最初に戻す
  357.           @move_route_index = 0
  358.         end
  359.         # オプション [動作を繰り返す] が OFF の場合
  360.         unless @move_route.repeat
  361.           # 移動ルート強制中の場合
  362.           if @move_route_forcing and not @move_route.repeat
  363.             # 移動ルートの強制を解除
  364.             @move_route_forcing = false
  365.             # オリジナルの移動ルートを復帰
  366.             @move_route = @original_move_route
  367.             @move_route_index = @original_move_route_index
  368.             @original_move_route = nil
  369.           end
  370.           # 停止カウントをクリア
  371.           @stop_count = 0
  372.         end
  373.         return
  374.       end
  375.       # 移動系コマンド (下に移動~ジャンプ) の場合
  376.       if command.code <= 14
  377.         # コマンドコードで分岐
  378.         case command.code
  379.         when 1  # 下に移動
  380.           move_down
  381.         when 2  # 左に移動
  382.           move_left
  383.         when 3  # 右に移動
  384.           move_right
  385.         when 4  # 上に移動
  386.           move_up
  387.         when 5  # 左下に移動
  388.           move_lower_left
  389.         when 6  # 右下に移動
  390.           move_lower_right
  391.         when 7  # 左上に移動
  392.           move_upper_left
  393.         when 8  # 右上に移動
  394.           move_upper_right
  395.         when 9  # ランダムに移動
  396.           move_random
  397.         when 10  # プレイヤーに近づく
  398.           move_toward_player
  399.         when 11  # プレイヤーから遠ざかる
  400.           move_away_from_player
  401.         when 12  # 一歩前進
  402.           move_forward
  403.         when 13  # 一歩後退
  404.           move_backward
  405.         when 14  # ジャンプ
  406.           jump(command.parameters[0], command.parameters[1])
  407.         end
  408.         # オプション [移動できない場合は無視] が OFF で、移動失敗の場合
  409.         if not @move_route.skippable and not moving? and not jumping?
  410.           return
  411.         end
  412.         @move_route_index += 1
  413.         return
  414.       end
  415.       # ウェイトの場合
  416.       if command.code == 15
  417.         # ウェイトカウントを設定
  418.         @wait_count = command.parameters[0] * 2 - 1
  419.         @move_route_index += 1
  420.         return
  421.       end
  422.       # 向き変更系のコマンドの場合
  423.       if command.code >= 16 and command.code <= 26
  424.         # コマンドコードで分岐
  425.         case command.code
  426.         when 16  # 下を向く
  427.           turn_down
  428.         when 17  # 左を向く
  429.           turn_left
  430.         when 18  # 右を向く
  431.           turn_right
  432.         when 19  # 上を向く
  433.           turn_up
  434.         when 20  # 右に 90 度回転
  435.           turn_right_90
  436.         when 21  # 左に 90 度回転
  437.           turn_left_90
  438.         when 22  # 180 度回転
  439.           turn_180
  440.         when 23  # 右か左に 90 度回転
  441.           turn_right_or_left_90
  442.         when 24  # ランダムに方向転換
  443.           turn_random
  444.         when 25  # プレイヤーの方を向く
  445.           turn_toward_player
  446.         when 26  # プレイヤーの逆を向く
  447.           turn_away_from_player
  448.         end
  449.         @move_route_index += 1
  450.         return
  451.       end
  452.       # その他のコマンドの場合
  453.       if command.code >= 27
  454.         # コマンドコードで分岐
  455.         case command.code
  456.         when 27  # スイッチ ON
  457.           $game_switches[command.parameters[0]] = true
  458.           $game_map.need_refresh = true
  459.         when 28  # スイッチ OFF
  460.           $game_switches[command.parameters[0]] = false
  461.           $game_map.need_refresh = true
  462.         when 29  # 移動速度の変更
  463.           @move_speed = command.parameters[0]
  464.         when 30  # 移動頻度の変更
  465.           @move_frequency = command.parameters[0]
  466.         when 31  # 移動時アニメ ON
  467.           @walk_anime = true
  468.         when 32  # 移動時アニメ OFF
  469.           @walk_anime = false
  470.         when 33  # 停止時アニメ ON
  471.           @step_anime = true
  472.         when 34  # 停止時アニメ OFF
  473.           @step_anime = false
  474.         when 35  # 向き固定 ON
  475.           @direction_fix = true
  476.         when 36  # 向き固定 OFF
  477.           @direction_fix = false
  478.         when 37  # すり抜け ON
  479.           @through = true
  480.         when 38  # すり抜け OFF
  481.           @through = false
  482.         when 39  # 最前面に表示 ON
  483.           @always_on_top = true
  484.         when 40  # 最前面に表示 OFF
  485.           @always_on_top = false
  486.         when 41  # グラフィック変更
  487.           @tile_id = 0
  488.           @character_name = command.parameters[0]
  489.           @character_hue = command.parameters[1]
  490.           if @original_direction != command.parameters[2]
  491.             @direction = command.parameters[2]
  492.             @original_direction = @direction
  493.             @prelock_direction = 0
  494.           end
  495.           if @original_pattern != command.parameters[3]
  496.             @pattern = command.parameters[3]
  497.             @original_pattern = @pattern
  498.           end
  499.         when 42  # 不透明度の変更
  500.           @opacity = command.parameters[0]
  501.         when 43  # 合成方法の変更
  502.           @blend_type = command.parameters[0]
  503.         when 44  # SE の演奏
  504.           $game_system.se_play(command.parameters[0])
  505.         when 45  # スクリプト
  506.           result = eval(command.parameters[0])
  507.         end
  508.         @move_route_index += 1
  509.         return
  510.       end
  511.     end
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ● 下に移動
  515.   #--------------------------------------------------------------------------
  516.   def move_down_p
  517.     # 下を向く
  518.     turn_down
  519.     # 移動距離を算出
  520.     distance = 2 ** @move_speed
  521.     down1(((@x * 128 + @revise_x) / 128.0).round,
  522.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  523.   end
  524.   def move_down_aaaagq
  525.     distance = 2 ** @move_speed
  526.     down1(((@x * 128 + @revise_x) / 128.0).round,
  527.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # ● 下に移動可能かどうかの判定1
  531.   #--------------------------------------------------------------------------
  532.   def down1(x, y, distance, down = false)
  533.     result = down2(x, y, distance)
  534.     if result == false
  535.       @event_run = check_event_trigger_touch(x, y+1)
  536.       return result
  537.     end
  538.     if @revise_x < -SIDE
  539.       result = down2(x, y + 1, distance, 4)
  540.       result &= down2(x - 1, y, distance)
  541.       if result == false
  542.         if down
  543.           move_lower_right_p
  544.           if @revise_x > SIDE
  545.             @revise_x = SIDE
  546.           end
  547.         end
  548.         return result
  549.       end
  550.     elsif @revise_x > SIDE
  551.       result = down2(x, y + 1, distance, 6)
  552.       result &= down2(x + 1, y, distance)
  553.       if result == false
  554.         if down
  555.           move_lower_left_p
  556.           if @revise_x < -SIDE
  557.             @revise_x = -SIDE
  558.           end
  559.         end
  560.         return result
  561.       end
  562.     end
  563.     # 下に移動可能ならば距離分移動
  564.     @revise_y += distance
  565.     return result
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ● 下に移動可能かどうかの判定2
  569.   #--------------------------------------------------------------------------
  570.   def down2(x, y, distance, d = 2)
  571.     if @revise_y + distance > DOWN
  572.       unless passable?(x, y, d)
  573.         if @revise_y < DOWN
  574.           @revise_y = DOWN
  575.         end
  576.         return false
  577.       end
  578.     end
  579.     return true
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # ● 左に移動
  583.   #--------------------------------------------------------------------------
  584.   def move_left_p
  585.     # 左を向く
  586.     turn_left
  587.     distance = 2 ** @move_speed
  588.     left1(((@x * 128 + @revise_x) / 128.0).round,
  589.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # ● 左に移動可能かどうかの判定1
  593.   #--------------------------------------------------------------------------
  594.   def left1(x, y, distance, left = false)
  595.     result = left2(x, y, distance)
  596.     if result == false
  597.       @event_run = check_event_trigger_touch(x-1, y)
  598.       return result
  599.     end
  600.     if @revise_y < -UP and $ud_ok
  601.       result = left2(x - 1, y, distance, 8)
  602.       result &= left2(x, y - 1, distance)
  603.       if result == false
  604.         if left
  605.           move_lower_left_p
  606.           if @revise_y > DOWN
  607.             @revise_y = DOWN
  608.           end
  609.         end
  610.         return result
  611.       end
  612.     elsif @revise_y > DOWN and $ud_ok
  613.       result = left2(x - 1, y, distance, 2)
  614.       result &= left2(x, y + 1, distance)
  615.       if result == false
  616.         if left
  617.           move_upper_left_p
  618.           if @revise_y < -UP
  619.             @revise_y = -UP
  620.           end
  621.         end
  622.         return result
  623.       end
  624.     end
  625.     @revise_x -= distance
  626.     return result
  627.   end
  628.   #--------------------------------------------------------------------------
  629.   # ● 左に移動可能かどうかの判定2
  630.   #--------------------------------------------------------------------------
  631.   def left2(x, y, distance, d = 4)
  632.     if @revise_x - distance < -SIDE
  633.       unless passable?(x, y, d)
  634.         if @revise_x > -SIDE
  635.           @revise_x = -SIDE
  636.         end
  637.         return false
  638.       end
  639.     end
  640.     return true
  641.   end
  642.   #--------------------------------------------------------------------------
  643.   # ● 右に移動
  644.   #--------------------------------------------------------------------------
  645.   def move_right_p
  646.       # 右を向く
  647.       turn_right
  648.     distance = 2 ** @move_speed
  649.     right1(((@x * 128 + @revise_x) / 128.0).round,
  650.             ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  651.   end
  652.   #--------------------------------------------------------------------------
  653.   # ● 右に移動可能かどうかの判定1
  654.   #--------------------------------------------------------------------------
  655.   def right1(x, y, distance, right = false)
  656.     result = right2(x, y, distance)
  657.     if result == false
  658.       @event_run = check_event_trigger_touch(x+1, y)
  659.       return result
  660.     end
  661.     if @revise_y < -UP and $ud_ok
  662.       result = right2(x + 1, y, distance, 8)
  663.       result &= right2(x, y - 1, distance)
  664.       if result == false
  665.         if right
  666.           move_lower_right_p
  667.           if @revise_y > DOWN
  668.             @revise_y = DOWN
  669.           end
  670.         end
  671.         return result
  672.       end
  673.     elsif @revise_y > DOWN and $ud_ok
  674.       result = right2(x + 1, y, distance, 2)
  675.       result &= right2(x, y + 1, distance)
  676.       if result == false
  677.         if right
  678.           move_upper_right_p
  679.           if @revise_y < -UP
  680.             @revise_y = -UP
  681.           end
  682.         end
  683.         return result
  684.       end
  685.     end
  686.     @revise_x += distance
  687.     return result
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # ● 右に移動可能かどうかの判定2
  691.   #--------------------------------------------------------------------------
  692.   def right2(x, y, distance, d = 6)
  693.     if @revise_x + distance > SIDE
  694.       unless passable?(x, y, d)
  695.         if @revise_x < SIDE
  696.           @revise_x = SIDE
  697.         end
  698.         return false
  699.       end
  700.     end
  701.     return true
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # ● 上に移動
  705.   #--------------------------------------------------------------------------
  706.   def move_up_p
  707.     # 上を向く
  708.     turn_up
  709.     # 下に移動
  710.     distance = 2 ** @move_speed
  711.     up1(((@x * 128 + @revise_x) / 128.0).round,
  712.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  713.   end
  714.   def move_up_aaaagq
  715.     distance = 2 ** @move_speed
  716.     up1(((@x * 128 + @revise_x) / 128.0).round,
  717.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ● 上に移動可能かどうかの判定1
  721.   #--------------------------------------------------------------------------
  722.   def up1(x, y, distance, up = false)
  723.     result = up2(x, y, distance)
  724.     if result == false
  725.       @event_run = check_event_trigger_touch(x, y-1)
  726.       return result
  727.     end
  728.     if @revise_x < -SIDE
  729.       result = up2(x, y - 1, distance, 4)
  730.       result &= up2(x - 1, y, distance)
  731.       if result == false
  732.         if up
  733.           move_upper_right_p
  734.           if @revise_x > SIDE
  735.             @revise_x = SIDE
  736.           end
  737.         end
  738.         return result
  739.       end
  740.     elsif @revise_x > SIDE
  741.       result = up2(x, y - 1, distance, 6)
  742.       result &= up2(x + 1, y, distance)
  743.       if result == false
  744.         if up
  745.           move_upper_left_p
  746.           if @revise_x < -SIDE
  747.             @revise_x = -SIDE
  748.           end
  749.         end
  750.         return result
  751.       end
  752.     end
  753.     @revise_y -= distance
  754.     return result
  755.   end
  756.   #--------------------------------------------------------------------------
  757.   # ● 上に移動可能かどうかの判定2
  758.   #--------------------------------------------------------------------------
  759.   def up2(x, y, distance, d = 8)
  760.     if @revise_y - distance < -UP
  761.       unless passable?(x, y, d)
  762.         if @revise_y > -UP
  763.           @revise_y = -UP
  764.         end
  765.         return false
  766.       end
  767.     end
  768.     return true
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # ● 左下に移動
  772.   #--------------------------------------------------------------------------
  773.   def move_lower_left_p
  774.     # 向き固定でない場合
  775.     unless @direction_fix
  776.       # 右向きだった場合は左を、上向きだった場合は下を向く
  777.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  778.     end
  779.     # 左下に移動
  780.     distance = (2 ** @move_speed) / Math.sqrt(2)
  781.     if @direction == 2
  782.       turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  783.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  784.       turn_down if @event_run
  785.       unless @event_run
  786.         if last_move?(@real_x, @real_y, 2, distance)
  787.           result = check_event_trigger_here([1,2], false)
  788.           if result == true
  789.             return
  790.           end
  791.         end
  792.         move_on
  793.         if @revise_y > DOWN and -UP > @revise_y - distance
  794.           @revise_y = DOWN
  795.         end
  796.         turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  797.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  798.         turn_left if @event_run
  799.       end
  800.     else
  801.       turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  802.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  803.       turn_left if @event_run
  804.       unless @event_run
  805.         if last_move?(@real_x, @real_y, 4, distance)
  806.           result = check_event_trigger_here([1,2], false)
  807.           if result == true
  808.             return
  809.           end
  810.         end
  811.         move_on
  812.         if  @revise_x + distance> SIDE and -SIDE > @revise_x
  813.           @revise_x = -SIDE
  814.         end
  815.         turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  816.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  817.         turn_down if @event_run
  818.       end
  819.     end
  820.   end
  821.   #--------------------------------------------------------------------------
  822.   # ● 右下に移動
  823.   #--------------------------------------------------------------------------
  824.   def move_lower_right_p
  825.     # 向き固定でない場合
  826.     unless @direction_fix
  827.       # 左向きだった場合は右を、上向きだった場合は下を向く
  828.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  829.     end
  830.     # 右下に移動
  831.     distance = (2 ** @move_speed) / Math.sqrt(2)
  832.     if @direction == 2
  833.       turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  834.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  835.       turn_down if @event_run
  836.       unless @event_run
  837.         if last_move?(@real_x, @real_y, 2, distance)
  838.           result = check_event_trigger_here([1,2], false)
  839.           if result == true
  840.             return
  841.           end
  842.         end
  843.         move_on
  844.         if @revise_y > DOWN and -UP > @revise_y - distance
  845.           @revise_y = DOWN
  846.         end
  847.         turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  848.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  849.         turn_right if @event_run
  850.       end
  851.     else
  852.       turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  853.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  854.       turn_right if @event_run
  855.       unless @event_run
  856.         if last_move?(@real_x, @real_y, 6, distance)
  857.           result = check_event_trigger_here([1,2], false)
  858.           if result == true
  859.             return
  860.           end
  861.         end
  862.         move_on
  863.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  864.           @revise_x = SIDE
  865.         end
  866.         turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  867.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  868.         turn_down if @event_run
  869.       end
  870.     end
  871.   end
  872.   #--------------------------------------------------------------------------
  873.   # ● 左上に移動
  874.   #--------------------------------------------------------------------------
  875.   def move_upper_left_p
  876.     # 向き固定でない場合
  877.     unless @direction_fix
  878.       # 右向きだった場合は左を、下向きだった場合は上を向く
  879.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  880.     end
  881.     # 左上に移動
  882.     distance = (2 ** @move_speed) / Math.sqrt(2)
  883.     if @direction == 8
  884.       turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  885.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  886.       turn_up if @event_run
  887.       unless @event_run
  888.         if last_move?(@real_x, @real_y, 8, distance)
  889.           result = check_event_trigger_here([1,2], false)
  890.           if result == true
  891.             return
  892.           end
  893.         end
  894.         move_on
  895.         if @revise_y + distance > DOWN and -UP > @revise_y
  896.           @revise_y = -UP
  897.         end
  898.         turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  899.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  900.         turn_left if @event_run
  901.       end
  902.     else
  903.       turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  904.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  905.       turn_left if @event_run
  906.       unless @event_run
  907.         if last_move?(@real_x, @real_y, 4, distance)
  908.           result = check_event_trigger_here([1,2], false)
  909.           if result == true
  910.             return
  911.           end
  912.         end
  913.         move_on
  914.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  915.           @revise_x = SIDE
  916.         end
  917.         turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  918.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  919.         turn_up if @event_run
  920.       end
  921.     end
  922.   end
  923.   #--------------------------------------------------------------------------
  924.   # ● 右上に移動
  925.   #--------------------------------------------------------------------------
  926.   def move_upper_right_p
  927.     # 向き固定でない場合
  928.     unless @direction_fix
  929.       # 左向きだった場合は右を、下向きだった場合は上を向く
  930.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  931.     end
  932.     # 右上に移動
  933.     distance = (2 ** @move_speed) / Math.sqrt(2)
  934.     if @direction == 8
  935.       turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  936.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  937.       turn_up if @event_run
  938.       unless @event_run
  939.         if last_move?(@real_x, @real_y, 8, distance)
  940.           result = check_event_trigger_here([1,2], false)
  941.           if result == true
  942.             return
  943.           end
  944.         end
  945.         move_on
  946.         if @revise_y + distance > DOWN and -UP > @revise_y
  947.           @revise_y = -UP
  948.         end
  949.         turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  950.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  951.         turn_right if @event_run
  952.       end
  953.     else
  954.       turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  955.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  956.       turn_right if @event_run
  957.       unless @event_run
  958.         if last_move?(@real_x, @real_y, 6, distance)
  959.           result = check_event_trigger_here([1,2], false)
  960.           if result == true
  961.             return
  962.           end
  963.         end
  964.         move_on
  965.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  966.           @revise_x = SIDE
  967.         end
  968.         turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  969.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  970.         turn_up if @event_run
  971.       end
  972.     end
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # ● 同位置のイベント起動判定
  976.   #--------------------------------------------------------------------------
  977.   def check_event_trigger_here(triggers, run = true)
  978.     result = false
  979.     # イベント実行中の場合
  980.     if $game_system.map_interpreter.running?
  981.       return result
  982.     end
  983.     # 全イベントのループ
  984.     for event in $game_map.events.values
  985.       # イベントの座標とトリガーが一致した場合
  986.       if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  987.           event.y == ((@y * 128 + @revise_y) / 128.0).round and
  988.           triggers.include?(event.trigger)
  989.         # ジャンプ中以外で、起動判定が同位置のイベントなら
  990.         if not event.jumping? and event.over_trigger?
  991.           if event.list.size > 1
  992.             if run == true
  993.               event.start
  994.             end
  995.             result = true
  996.           end
  997.         end
  998.       end
  999.     end
  1000.     return result
  1001.   end
  1002.   #--------------------------------------------------------------------------
  1003.   # ● 座標修正
  1004.   #--------------------------------------------------------------------------
  1005.   def move_on
  1006.     if @y < (@y + @revise_y / 128.0).round
  1007.       @y += 1
  1008.       @revise_y -= 128
  1009.     end
  1010.     if @x > (@x + @revise_x / 128.0).round
  1011.       @x -= 1
  1012.       @revise_x += 128
  1013.     end
  1014.     if @x < (@x + @revise_x / 128.0).round
  1015.       @x += 1
  1016.       @revise_x -= 128
  1017.     end
  1018.     if @y > (@y + @revise_y / 128.0).round
  1019.       @y -= 1
  1020.       @revise_y += 128
  1021.     end
  1022.   end
  1023.   #--------------------------------------------------------------------------
  1024.   # ● アニメーションアップデート
  1025.   #--------------------------------------------------------------------------
  1026.   def anime_update
  1027.     # 移動時アニメが ON の場合
  1028.     if @walk_anime
  1029.       # アニメカウントを 1.5 増やす
  1030.       @anime_count += 1.5
  1031.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1032.     elsif @step_anime
  1033.       # アニメカウントを 1 増やす
  1034.       @anime_count += 1
  1035.     end
  1036.     # アニメカウントが最大値を超えた場合
  1037.     # ※最大値は、基本値 18 から移動速度 * 1 を引いた値
  1038.     if @anime_count > 18 - @move_speed * 2
  1039.       # 停止時アニメが OFF かつ 停止中の場合
  1040.       if not @step_anime and @stop_count > 0
  1041.         # パターンをオリジナルに戻す
  1042.         @pattern = @original_pattern
  1043.       # 停止時アニメが ON または 移動中の場合
  1044.       else
  1045.         # パターンを更新
  1046.         @pattern = (@pattern + 1) % 4
  1047.       end
  1048.       # アニメカウントをクリア
  1049.       @anime_count = 0
  1050.     end
  1051.   end
  1052.   #--------------------------------------------------------------------------
  1053.   # ● 指定位置に移動
  1054.   #--------------------------------------------------------------------------
  1055.   # オリジナルのイベントを改名
  1056.   alias :moveto_original :moveto
  1057.   def moveto(x, y)
  1058.     # 補正座標を初期化
  1059.     @revise_x = 0
  1060.     @revise_y = 0
  1061.     # オリジナルのイベントを呼び出し
  1062.     moveto_original(x, y)
  1063.   end
  1064.   #--------------------------------------------------------------------------
  1065.   # ● 移動したかどうかの判定
  1066.   #--------------------------------------------------------------------------
  1067.   def last_move?(x, y, direction, distance)
  1068.     if direction == 2 or direction == 6
  1069.       distance *= -1
  1070.     end
  1071.     if (direction == 2 or direction == 8) and
  1072.         (y / 128.0).round != ((y - distance) / 128.0).round
  1073.       return true
  1074.     end
  1075.     if (direction == 4 or direction == 6) and
  1076.         (x / 128.0).round != ((x - distance) / 128.0).round
  1077.       return true
  1078.     end
  1079.     return false
  1080.   end
  1081. end

  1082. #==============================================================================
  1083. # ■ Game_Character (分割定義 1)
  1084. #------------------------------------------------------------------------------
  1085. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  1086. # クラスのスーパークラスとして使用されます。
  1087. #==============================================================================

  1088. class Game_Character
  1089.   #--------------------------------------------------------------------------
  1090.   # ● フレーム更新 (移動)
  1091.   #--------------------------------------------------------------------------
  1092.   def update_move
  1093.     # 移動速度からマップ座標系での移動距離に変換
  1094.     distance = 2 ** @move_speed
  1095.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  1096.       distance /= Math.sqrt(2)
  1097.     end
  1098.     # 論理座標が実座標より下の場合
  1099.     if @y * 128 > @real_y
  1100.       # 下に移動
  1101.       @real_y = [@real_y + distance, @y * 128].min
  1102.     end
  1103.     # 論理座標が実座標より左の場合
  1104.     if @x * 128 < @real_x
  1105.       # 左に移動
  1106.       @real_x = [@real_x - distance, @x * 128].max
  1107.     end
  1108.     # 論理座標が実座標より右の場合
  1109.     if @x * 128 > @real_x
  1110.       # 右に移動
  1111.       @real_x = [@real_x + distance, @x * 128].min
  1112.     end
  1113.     # 論理座標が実座標より上の場合
  1114.     if @y * 128 < @real_y
  1115.       # 上に移動
  1116.       @real_y = [@real_y - distance, @y * 128].max
  1117.     end
  1118.     # 移動時アニメが ON の場合
  1119.     if @walk_anime
  1120.       # アニメカウントを 1.5 増やす
  1121.       @anime_count += 1.5
  1122.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1123.     elsif @step_anime
  1124.       # アニメカウントを 1 増やす
  1125.       @anime_count += 1
  1126.     end
  1127.   end
  1128. end

  1129. #==============================================================================
  1130. # ■ Game_Event
  1131. #------------------------------------------------------------------------------
  1132. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  1133. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  1134. #==============================================================================

  1135. class Game_Event < Game_Character
  1136.   #--------------------------------------------------------------------------
  1137.   # ● イベント起動
  1138.   #--------------------------------------------------------------------------
  1139.   def start
  1140.     # 実行内容が空でない場合
  1141.     if @list.size > 1
  1142.       # $game_player.event が0でない場合
  1143.       if $game_player.event != 0
  1144.         # 移動速度を $game_player.event にする
  1145.         $game_player.move_speed = $game_player.event
  1146.       end
  1147.       @starting = true
  1148.     end
  1149.   end
  1150. end

  1151. #==============================================================================
  1152. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1153. #==============================================================================
复制代码
把跳跃图改为jump.png放在character文件夹里,角色设置默认行走图就行了。
偶是熬夜学编程的傻子
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-22 17:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表