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

Project1

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

[已经过期] 求一个重力弹跳脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
23 小时
注册时间
2012-8-21
帖子
38
跳转到指定楼层
1
 楼主| 发表于 2013-3-2 20:31:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
求一个重力弹跳脚本 ,想马里奥一样的!

Lv2.观梦者 (暗夜天使)

万兽

梦石
0
星屑
597
在线时间
2271 小时
注册时间
2006-11-4
帖子
4868

贵宾

来自 2楼
发表于 2013-3-2 20:37:26 | 只看该作者
  1. $ud_ok = true #上下失效
  2. $airjump = 1  #空中连跳
  3. #==============================================================================
  4. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  5. #==============================================================================

  6. # ————————————————————————————————————
  7. # 全方向ドット移動 Ver ε
  8. # 配布元・サポートURL
  9. # http://members.jcom.home.ne.jp/cogwheel/

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

  1059. #==============================================================================
  1060. # ■ Game_Character (分割定義 1)
  1061. #------------------------------------------------------------------------------
  1062. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  1063. # クラスのスーパークラスとして使用されます。
  1064. #==============================================================================

  1065. class Game_Character
  1066.   #--------------------------------------------------------------------------
  1067.   # ● フレーム更新 (移動)
  1068.   #--------------------------------------------------------------------------
  1069.   def update_move
  1070.     # 移動速度からマップ座標系での移動距離に変換
  1071.     distance = 2 ** @move_speed
  1072.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  1073.       distance /= Math.sqrt(2)
  1074.     end
  1075.     # 論理座標が実座標より下の場合
  1076.     if @y * 128 > @real_y
  1077.       # 下に移動
  1078.       @real_y = [@real_y + distance, @y * 128].min
  1079.     end
  1080.     # 論理座標が実座標より左の場合
  1081.     if @x * 128 < @real_x
  1082.       # 左に移動
  1083.       @real_x = [@real_x - distance, @x * 128].max
  1084.     end
  1085.     # 論理座標が実座標より右の場合
  1086.     if @x * 128 > @real_x
  1087.       # 右に移動
  1088.       @real_x = [@real_x + distance, @x * 128].min
  1089.     end
  1090.     # 論理座標が実座標より上の場合
  1091.     if @y * 128 < @real_y
  1092.       # 上に移動
  1093.       @real_y = [@real_y - distance, @y * 128].max
  1094.     end
  1095.     # 移動時アニメが ON の場合
  1096.     if @walk_anime
  1097.       # アニメカウントを 1.5 増やす
  1098.       @anime_count += 1.5
  1099.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1100.     elsif @step_anime
  1101.       # アニメカウントを 1 増やす
  1102.       @anime_count += 1
  1103.     end
  1104.   end
  1105. end

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

  1112. class Game_Event < Game_Character
  1113.   #--------------------------------------------------------------------------
  1114.   # ● イベント起動
  1115.   #--------------------------------------------------------------------------
  1116.   def start
  1117.     # 実行内容が空でない場合
  1118.     if @list.size > 1
  1119.       # $game_player.event が0でない場合
  1120.       if $game_player.event != 0
  1121.         # 移動速度を $game_player.event にする
  1122.         $game_player.move_speed = $game_player.event
  1123.       end
  1124.       @starting = true
  1125.     end
  1126.   end
  1127. end

  1128. #==============================================================================
  1129. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  1130. #==============================================================================
复制代码
LZ要的是介个?

评分

参与人数 1星屑 +100 收起 理由
hys111111 + 100 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
23 小时
注册时间
2012-8-21
帖子
38
3
 楼主| 发表于 2013-3-7 12:56:50 | 只看该作者
谢谢,请问粘贴在哪,按什么键跳跃
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
23 小时
注册时间
2012-8-21
帖子
38
4
 楼主| 发表于 2013-3-17 10:30:53 | 只看该作者
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
23 小时
注册时间
2012-8-21
帖子
38
5
 楼主| 发表于 2013-3-17 10:32:52 | 只看该作者

点评

在main前面。  发表于 2013-3-17 18:58
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-29 11:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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