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

Project1

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

[已经过期] 重力系统的穿透问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
968
在线时间
246 小时
注册时间
2008-7-11
帖子
651
跳转到指定楼层
1
 楼主| 发表于 2013-2-7 12:56:25 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x



怎么让人物从下往上跳的时候穿透,然后落到上面一层?而不是被挡回来?

试了改图块通行啥的木有成功,求大神解

附上我使用的重力脚本

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

本版积分规则

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

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

GMT+8, 2024-4-29 17:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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