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

Project1

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

怎么让角色行走时候不走一大格而是...(内详)

 关闭 [复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-6-16
帖子
18
跳转到指定楼层
1
发表于 2007-7-3 03:27:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-6-16
帖子
18
2
 楼主| 发表于 2007-7-3 03:27:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽

Lv1.梦旅人

梦石
0
星屑
60
在线时间
61 小时
注册时间
2006-9-15
帖子
946
3
发表于 2007-7-3 05:21:41 | 只看该作者
参看主站的这个教学

http://rpg.blue/web/htm/news696.htm
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
1
星屑
916
在线时间
101 小时
注册时间
2006-3-27
帖子
1081
4
发表于 2007-7-3 05:24:32 | 只看该作者
这个,下面两个帖子的连起来考到一起

,字数太多,我放不到一起


  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.     @dash  = 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.           @opacity = 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
复制代码
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-3-16
帖子
12
5
发表于 2007-7-3 05:27:00 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
1
星屑
916
在线时间
101 小时
注册时间
2006-3-27
帖子
1081
6
发表于 2007-7-3 05:28:20 | 只看该作者
  1. #--------------------------------------------------------------------------
  2.   # ● 上に移動
  3.   #--------------------------------------------------------------------------
  4.   def move_up_p
  5.     # 上を向く
  6.     turn_up
  7.     # 下に移動
  8.     distance = 2 ** @move_speed
  9.     up1(((@x * 128 + @revise_x) / 128.0).round,
  10.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  11.   end
  12.   def move_up_aaaagq
  13.     distance = 2 ** @move_speed
  14.     up1(((@x * 128 + @revise_x) / 128.0).round,
  15.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 上に移動可能かどうかの判定1
  19.   #--------------------------------------------------------------------------
  20.   def up1(x, y, distance, up = false)
  21.     result = up2(x, y, distance)
  22.     if result == false
  23.       @event_run = check_event_trigger_touch(x, y-1)
  24.       return result
  25.     end
  26.     if @revise_x < -SIDE
  27.       result = up2(x, y - 1, distance, 4)
  28.       result &= up2(x - 1, y, distance)
  29.       if result == false
  30.         if up
  31.           move_upper_right_p
  32.           if @revise_x > SIDE
  33.             @revise_x = SIDE
  34.           end
  35.         end
  36.         return result
  37.       end
  38.     elsif @revise_x > SIDE
  39.       result = up2(x, y - 1, distance, 6)
  40.       result &= up2(x + 1, y, distance)
  41.       if result == false
  42.         if up
  43.           move_upper_left_p
  44.           if @revise_x < -SIDE
  45.             @revise_x = -SIDE
  46.           end
  47.         end
  48.         return result
  49.       end
  50.     end
  51.     @revise_y -= distance
  52.     return result
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 上に移動可能かどうかの判定2
  56.   #--------------------------------------------------------------------------
  57.   def up2(x, y, distance, d = 8)
  58.     if @revise_y - distance < -UP
  59.       unless passable?(x, y, d)
  60.         if @revise_y > -UP
  61.           @revise_y = -UP
  62.         end
  63.         return false
  64.       end
  65.     end
  66.     return true
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 左下に移動
  70.   #--------------------------------------------------------------------------
  71.   def move_lower_left_p
  72.     # 向き固定でない場合
  73.     unless @direction_fix
  74.       # 右向きだった場合は左を、上向きだった場合は下を向く
  75.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  76.     end
  77.     # 左下に移動
  78.     distance = (2 ** @move_speed) / Math.sqrt(2)
  79.     if @direction == 2
  80.       turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  81.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  82.       turn_down if @event_run
  83.       unless @event_run
  84.         if last_move?(@real_x, @real_y, 2, distance)
  85.           result = check_event_trigger_here([1,2], false)
  86.           if result == true
  87.             return
  88.           end
  89.         end
  90.         move_on
  91.         if @revise_y > DOWN and -UP > @revise_y - distance
  92.           @revise_y = DOWN
  93.         end
  94.         turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  95.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  96.         turn_left if @event_run
  97.       end
  98.     else
  99.       turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  100.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  101.       turn_left if @event_run
  102.       unless @event_run
  103.         if last_move?(@real_x, @real_y, 4, distance)
  104.           result = check_event_trigger_here([1,2], false)
  105.           if result == true
  106.             return
  107.           end
  108.         end
  109.         move_on
  110.         if  @revise_x + distance> SIDE and -SIDE > @revise_x
  111.           @revise_x = -SIDE
  112.         end
  113.         turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  114.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  115.         turn_down if @event_run
  116.       end
  117.     end
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 右下に移動
  121.   #--------------------------------------------------------------------------
  122.   def move_lower_right_p
  123.     # 向き固定でない場合
  124.     unless @direction_fix
  125.       # 左向きだった場合は右を、上向きだった場合は下を向く
  126.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  127.     end
  128.     # 右下に移動
  129.     distance = (2 ** @move_speed) / Math.sqrt(2)
  130.     if @direction == 2
  131.       turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  132.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  133.       turn_down if @event_run
  134.       unless @event_run
  135.         if last_move?(@real_x, @real_y, 2, distance)
  136.           result = check_event_trigger_here([1,2], false)
  137.           if result == true
  138.             return
  139.           end
  140.         end
  141.         move_on
  142.         if @revise_y > DOWN and -UP > @revise_y - distance
  143.           @revise_y = DOWN
  144.         end
  145.         turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  146.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  147.         turn_right if @event_run
  148.       end
  149.     else
  150.       turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  151.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  152.       turn_right if @event_run
  153.       unless @event_run
  154.         if last_move?(@real_x, @real_y, 6, distance)
  155.           result = check_event_trigger_here([1,2], false)
  156.           if result == true
  157.             return
  158.           end
  159.         end
  160.         move_on
  161.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  162.           @revise_x = SIDE
  163.         end
  164.         turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  165.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  166.         turn_down if @event_run
  167.       end
  168.     end
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 左上に移動
  172.   #--------------------------------------------------------------------------
  173.   def move_upper_left_p
  174.     # 向き固定でない場合
  175.     unless @direction_fix
  176.       # 右向きだった場合は左を、下向きだった場合は上を向く
  177.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  178.     end
  179.     # 左上に移動
  180.     distance = (2 ** @move_speed) / Math.sqrt(2)
  181.     if @direction == 8
  182.       turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  183.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  184.       turn_up if @event_run
  185.       unless @event_run
  186.         if last_move?(@real_x, @real_y, 8, distance)
  187.           result = check_event_trigger_here([1,2], false)
  188.           if result == true
  189.             return
  190.           end
  191.         end
  192.         move_on
  193.         if @revise_y + distance > DOWN and -UP > @revise_y
  194.           @revise_y = -UP
  195.         end
  196.         turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  197.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  198.         turn_left if @event_run
  199.       end
  200.     else
  201.       turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  202.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  203.       turn_left if @event_run
  204.       unless @event_run
  205.         if last_move?(@real_x, @real_y, 4, distance)
  206.           result = check_event_trigger_here([1,2], false)
  207.           if result == true
  208.             return
  209.           end
  210.         end
  211.         move_on
  212.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  213.           @revise_x = SIDE
  214.         end
  215.         turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  216.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  217.         turn_up if @event_run
  218.       end
  219.     end
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 右上に移動
  223.   #--------------------------------------------------------------------------
  224.   def move_upper_right_p
  225.     # 向き固定でない場合
  226.     unless @direction_fix
  227.       # 左向きだった場合は右を、下向きだった場合は上を向く
  228.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  229.     end
  230.     # 右上に移動
  231.     distance = (2 ** @move_speed) / Math.sqrt(2)
  232.     if @direction == 8
  233.       turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  234.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  235.       turn_up if @event_run
  236.       unless @event_run
  237.         if last_move?(@real_x, @real_y, 8, distance)
  238.           result = check_event_trigger_here([1,2], false)
  239.           if result == true
  240.             return
  241.           end
  242.         end
  243.         move_on
  244.         if @revise_y + distance > DOWN and -UP > @revise_y
  245.           @revise_y = -UP
  246.         end
  247.         turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  248.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  249.         turn_right if @event_run
  250.       end
  251.     else
  252.       turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  253.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  254.       turn_right if @event_run
  255.       unless @event_run
  256.         if last_move?(@real_x, @real_y, 6, distance)
  257.           result = check_event_trigger_here([1,2], false)
  258.           if result == true
  259.             return
  260.           end
  261.         end
  262.         move_on
  263.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  264.           @revise_x = SIDE
  265.         end
  266.         turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  267.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  268.         turn_up if @event_run
  269.       end
  270.     end
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ● 同位置のイベント起動判定
  274.   #--------------------------------------------------------------------------
  275.   def check_event_trigger_here(triggers, run = true)
  276.     result = false
  277.     # イベント実行中の場合
  278.     if $game_system.map_interpreter.running?
  279.       return result
  280.     end
  281.     # 全イベントのループ
  282.     for event in $game_map.events.values
  283.       # イベントの座標とトリガーが一致した場合
  284.       if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  285.           event.y == ((@y * 128 + @revise_y) / 128.0).round and
  286.           triggers.include?(event.trigger)
  287.         # ジャンプ中以外で、起動判定が同位置のイベントなら
  288.         if not event.jumping? and event.over_trigger?
  289.           if event.list.size > 1
  290.             if run == true
  291.               event.start
  292.             end
  293.             result = true
  294.           end
  295.         end
  296.       end
  297.     end
  298.     return result
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # ● 座標修正
  302.   #--------------------------------------------------------------------------
  303.   def move_on
  304.     if @y < (@y + @revise_y / 128.0).round
  305.       @y += 1
  306.       @revise_y -= 128
  307.     end
  308.     if @x > (@x + @revise_x / 128.0).round
  309.       @x -= 1
  310.       @revise_x += 128
  311.     end
  312.     if @x < (@x + @revise_x / 128.0).round
  313.       @x += 1
  314.       @revise_x -= 128
  315.     end
  316.     if @y > (@y + @revise_y / 128.0).round
  317.       @y -= 1
  318.       @revise_y += 128
  319.     end
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● アニメーションアップデート
  323.   #--------------------------------------------------------------------------
  324.   def anime_update
  325.     # 移動時アニメが ON の場合
  326.     if @walk_anime
  327.       # アニメカウントを 1.5 増やす
  328.       @anime_count += 1.5
  329.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  330.     elsif @step_anime
  331.       # アニメカウントを 1 増やす
  332.       @anime_count += 1
  333.     end
  334.     # アニメカウントが最大値を超えた場合
  335.     # ※最大値は、基本値 18 から移動速度 * 1 を引いた値
  336.     if @anime_count > 18 - @move_speed * 2
  337.       # 停止時アニメが OFF かつ 停止中の場合
  338.       if not @step_anime and @stop_count > 0
  339.         # パターンをオリジナルに戻す
  340.         @pattern = @original_pattern
  341.       # 停止時アニメが ON または 移動中の場合
  342.       else
  343.         # パターンを更新
  344.         @pattern = (@pattern + 1) % 4
  345.       end
  346.       # アニメカウントをクリア
  347.       @anime_count = 0
  348.     end
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● 指定位置に移動
  352.   #--------------------------------------------------------------------------
  353.   # オリジナルのイベントを改名
  354.   alias :moveto_original :moveto
  355.   def moveto(x, y)
  356.     # 補正座標を初期化
  357.     @revise_x = 0
  358.     @revise_y = 0
  359.     # オリジナルのイベントを呼び出し
  360.     moveto_original(x, y)
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 移動したかどうかの判定
  364.   #--------------------------------------------------------------------------
  365.   def last_move?(x, y, direction, distance)
  366.     if direction == 2 or direction == 6
  367.       distance *= -1
  368.     end
  369.     if (direction == 2 or direction == 8) and
  370.         (y / 128.0).round != ((y - distance) / 128.0).round
  371.       return true
  372.     end
  373.     if (direction == 4 or direction == 6) and
  374.         (x / 128.0).round != ((x - distance) / 128.0).round
  375.       return true
  376.     end
  377.     return false
  378.   end
  379. end

  380. #==============================================================================
  381. # ■ Game_Character (分割定義 1)
  382. #------------------------------------------------------------------------------
  383. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  384. # クラスのスーパークラスとして使用されます。
  385. #==============================================================================

  386. class Game_Character
  387.   #--------------------------------------------------------------------------
  388.   # ● フレーム更新 (移動)
  389.   #--------------------------------------------------------------------------
  390.   def update_move
  391.     # 移動速度からマップ座標系での移動距離に変換
  392.     distance = 2 ** @move_speed
  393.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  394.       distance /= Math.sqrt(2)
  395.     end
  396.     # 論理座標が実座標より下の場合
  397.     if @y * 128 > @real_y
  398.       # 下に移動
  399.       @real_y = [@real_y + distance, @y * 128].min
  400.     end
  401.     # 論理座標が実座標より左の場合
  402.     if @x * 128 < @real_x
  403.       # 左に移動
  404.       @real_x = [@real_x - distance, @x * 128].max
  405.     end
  406.     # 論理座標が実座標より右の場合
  407.     if @x * 128 > @real_x
  408.       # 右に移動
  409.       @real_x = [@real_x + distance, @x * 128].min
  410.     end
  411.     # 論理座標が実座標より上の場合
  412.     if @y * 128 < @real_y
  413.       # 上に移動
  414.       @real_y = [@real_y - distance, @y * 128].max
  415.     end
  416.     # 移動時アニメが ON の場合
  417.     if @walk_anime
  418.       # アニメカウントを 1.5 増やす
  419.       @anime_count += 1.5
  420.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  421.     elsif @step_anime
  422.       # アニメカウントを 1 増やす
  423.       @anime_count += 1
  424.     end
  425.   end
  426. end

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

  433. class Game_Event < Game_Character
  434.   #--------------------------------------------------------------------------
  435.   # ● イベント起動
  436.   #--------------------------------------------------------------------------
  437.   def start
  438.     # 実行内容が空でない場合
  439.     if @list.size > 1
  440.       # $game_player.event が0でない場合
  441.       if $game_player.event != 0
  442.         # 移動速度を $game_player.event にする
  443.         $game_player.move_speed = $game_player.event
  444.       end
  445.       @starting = true
  446.     end
  447.   end
  448. end

  449. #==============================================================================
  450. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  451. #==============================================================================
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-9-21 17:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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