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

Project1

 找回密码
 注册会员
搜索
查看: 2643|回复: 3

[已经过期] 求八方向新思路

[复制链接]

Lv2.观梦者

花开堪折直须折

梦石
0
星屑
611
在线时间
943 小时
注册时间
2010-7-17
帖子
4963

贵宾

发表于 2012-12-4 18:16:03 | 显示全部楼层 |阅读模式

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

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

x
铅笔姐那个我用着略有点儿冲突……谁能帮忙把这个vx的转成va?拜托唷~
或者以别的什么思路写也可以,只是在下思量着直接转似乎会快一些……
在下对RGSS3一窍不通什么的,就拜托大家了~事后转账vip过去好了。发帖写好酬劳唷=v=

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Game_Character
  3. #==============================================================================
  4.  
  5. class Game_Character
  6.   #--------------------------------------------------------------------------
  7.   # ● 八方向
  8.   #--------------------------------------------------------------------------
  9.   def direction_8dir
  10.     return @direction
  11.   end
  12.   #--------------------------------------------------------------------------
  13.   # ● 变成指定方向
  14.   #     direction : 方向
  15.   #--------------------------------------------------------------------------
  16.   alias set_direction_8fangxiang set_direction
  17.   def set_direction(direction)
  18.     last_dir = @direction
  19.     set_direction_8fangxiang(direction)
  20.     if !@direction_fix && direction != 0
  21.       @direction_8dir = direction
  22.     end
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 向左下移动
  26.   #--------------------------------------------------------------------------
  27.   alias move_lower_left_8fangxiang move_lower_left
  28.   def move_lower_left
  29.     move_lower_left_8fangxiang
  30.     @direction_8dir = 1 unless @direction_fix
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 向右下移动
  34.   #--------------------------------------------------------------------------
  35.   alias move_lower_right_8fangxiang move_lower_right
  36.   def move_lower_right
  37.     move_lower_right_8fangxiang
  38.     @direction_8dir = 3 unless @direction_fix
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 向左上移动
  42.   #--------------------------------------------------------------------------
  43.   alias move_upper_left_8fangxiang move_upper_left
  44.   def move_upper_left
  45.     move_upper_left_8fangxiang
  46.     @direction_8dir = 7 unless @direction_fix
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ● 向右上移动
  50.   #--------------------------------------------------------------------------
  51.   alias move_upper_right_8fangxiang move_upper_right
  52.   def move_upper_right
  53.     move_upper_right_8fangxiang
  54.     @direction_8dir = 9 unless @direction_fix
  55.   end
  56. end
  57. #==============================================================================
  58. # ■ Game_Party
  59. #==============================================================================
  60.  
  61. class Game_Party < Game_Unit
  62.   def decrease_steps
  63.     @steps -= 1
  64.   end
  65. end
  66.  
  67. #==============================================================================
  68. # ■ Game_Player
  69. #==============================================================================
  70.  
  71. class Game_Player < Game_Character
  72.  
  73.   #--------------------------------------------------------------------------
  74.   # ●八方向
  75.   #--------------------------------------------------------------------------
  76.   def direction_8dir
  77.     @direction_8dir = @direction if @direction_8dir == nil
  78.     return @direction_8dir
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 八方向按键
  82.   #--------------------------------------------------------------------------
  83.   def move_by_input
  84.     return unless movable?
  85.     return if $game_map.interpreter.running?
  86.     last_steps = $game_party.steps
  87.     case Input.dir8
  88.     when 1;  move_down; move_left; @direction = 2
  89.     when 2;  move_down
  90.     when 3;  move_down; move_right; @direction = 6
  91.     when 4;  move_left
  92.     when 6;  move_right
  93.     when 7;  move_up; move_left; @direction = 4
  94.     when 8;  move_up
  95.     when 9;  move_up; move_right; @direction = 8
  96.     else;    return
  97.     end
  98.     @direction_8dir = Input.dir8
  99.     # 斜方向移动正确步数计算
  100.     if $game_party.steps - last_steps == 2
  101.       $game_party.decrease_steps
  102.     end
  103.   end
  104.  
  105.   #--------------------------------------------------------------------------
  106.   # ● 移动更新
  107.   #--------------------------------------------------------------------------
  108.   def update_move
  109.     distance = 2 ** @move_speed   
  110.     if dash?                     
  111.       distance *= 2
  112.     end
  113.     distance = Integer(distance)
  114.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  115.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  116.     @real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
  117.     @real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
  118.     update_bush_depth unless moving?
  119.     if @walk_anime
  120.       @anime_count += 1.5
  121.     elsif @step_anime
  122.       @anime_count += 1
  123.     end
  124.   end
  125. end
  126. #==============================================================================
  127. # ■ Sprite_Character
  128. #==============================================================================
  129. class Sprite_Character < Sprite_Base
  130.  
  131.   ANIME_TABLE = { 1=>2, 3=>6, 7=>4, 9=>8 }
  132.   #--------------------------------------------------------------------------
  133.   # ● 更新位图
  134.   #--------------------------------------------------------------------------
  135.   alias update_bitmap_8fangxiang update_bitmap
  136.   def update_bitmap
  137.     name_changed = (@character_name != @character.character_name)
  138.     update_bitmap_8fangxiang
  139.     if @tile_id > 0            
  140.       @enable_slant = false
  141.       return
  142.     end
  143.     return unless name_changed  
  144.     @enable_slant = true
  145.     begin
  146.       @character_name_slant = @character_name + "#"
  147.       Cache.character(@character_name_slant)
  148.     rescue
  149.       @enable_slant = false
  150.     end
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 更新传送矩形
  154.   #--------------------------------------------------------------------------
  155.   alias update_src_rect_8fangxiang update_src_rect
  156.   def update_src_rect
  157.     return if @tile_id > 0  
  158.     if @enable_slant
  159.       update_src_rect_for_slant
  160.     else
  161.       update_src_rect_8fangxiang
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 更新斜方向传送矩形
  166.   #--------------------------------------------------------------------------
  167.   def update_src_rect_for_slant
  168.     index = @character.character_index
  169.     pattern = @character.pattern < 3 ? @character.pattern : 1
  170.     sx = (index % 4 * 3 + pattern) * @cw
  171.     dir = @character.direction_8dir
  172.     case dir % 2
  173.     when 0  # 上下左右
  174.       if @last_slant
  175.         self.bitmap = Cache.character(@character_name)
  176.         @last_slant = false
  177.       end
  178.     else   
  179.       unless @last_slant
  180.         self.bitmap = Cache.character(@character_name_slant)
  181.         @last_slant = true
  182.       end
  183.       dir = ANIME_TABLE[dir]
  184.     end
  185.     sy = (index / 4 * 4 + (dir - 2) / 2) * @ch
  186.     self.src_rect.set(sx, sy, @cw, @ch)
  187.   end
  188. end

点评

= =||铅笔姐……据我所知他是男的吧~  发表于 2012-12-20 14:05
大家好,我叫节操,有一天,我被吃了。
http://forever-dream.5d6d.com
永恒の梦制作组论坛

129993099
永恒の梦制作组QQ群

Lv5.捕梦者

梦石
0
星屑
21771
在线时间
8545 小时
注册时间
2011-12-31
帖子
3360
发表于 2012-12-4 18:28:41 | 显示全部楼层
本帖最后由 tseyik 于 2012-12-4 18:47 编辑

原網址
http://artificialprovidence.web.fc2.com/

8方向移動

  1. #==============================================================================
  2. # ■ RGSS3 8方向移動スクリプト Ver1.01 by 星潟
  3. #------------------------------------------------------------------------------
  4. #  プレイヤーキャラクターの8方向移動を可能にします。
  5. #   その他、プレイヤーの移動に関する一部機能について設定できます。
  6. #   基本的に機能拡張依頼や競合対応は受け付けておりません。ご了承ください。
  7. #
  8. #   更新履歴
  9. #   Ver1.01 不要な記述一点を削除。
  10. #           スイッチ切り替えによるダッシュ禁止機能を追加。
  11. #==============================================================================

  12. module MOVE_CONTROL
  13.   
  14.   #这个开关on,禁止在八个方向的运动,只可四个方向移动。
  15.   
  16.   FOUR_MOVE_SWITCH = 51
  17.   
  18.   #这个开关on、禁止的操作的玩家角色。
  19.   
  20.   MOVE_SEAL_SWITCH = 52
  21.   
  22.   #这个开关on、短跑判断是相反。
  23.   #(平常時短跑、短跑鍵押下是通常歩行)
  24.   
  25.   DASH_REV = 53
  26.   
  27.   #这个开关on、禁止使用短跑。
  28.   #(通过切换开关,、同一地图上
  29.   #  可分別設定可短跑和禁止短跑的地区)
  30.   
  31.   DASH_SEAL = 54
  32.   
  33.   #当這变量的数値大于零,则短跑速度进一步增加。
  34.   
  35.   DASH_PLUS = 19
  36.   
  37. end

  38. class Game_CharacterBase
  39.   #--------------------------------------------------------------------------
  40.   # ● 移動速度の取得(ダッシュを考慮)
  41.   #--------------------------------------------------------------------------
  42.   alias real_move_speed_8direction real_move_speed
  43.   def real_move_speed
  44.     if $game_variables[MOVE_CONTROL::DASH_PLUS] > 0
  45.       dash_plus = 1 + ($game_variables[MOVE_CONTROL::DASH_PLUS] * 0.1)
  46.       @move_speed + (dash? ? dash_plus : 0)
  47.     else
  48.       real_move_speed_8direction
  49.     end
  50.   end
  51. end

  52. class Game_Player < Game_Character
  53.   #--------------------------------------------------------------------------
  54.   # ● ダッシュ状態判定
  55.   #--------------------------------------------------------------------------
  56.   alias dash_rev? dash?
  57.   def dash?
  58.     return false if $game_switches[MOVE_CONTROL::DASH_SEAL] == true
  59.     if $game_switches[MOVE_CONTROL::DASH_REV] == true
  60.       return false if @move_route_forcing
  61.       return false if $game_map.disable_dash?
  62.       return false if vehicle
  63.       return false if Input.press?(:A)
  64.       return true
  65.     else
  66.       dash_rev?
  67.     end
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 方向ボタン入力による移動処理
  71.   #--------------------------------------------------------------------------
  72.   alias move_by_input_8direction move_by_input
  73.   def move_by_input
  74.     return if $game_switches[MOVE_CONTROL::MOVE_SEAL_SWITCH] == true
  75.     if $game_switches[MOVE_CONTROL::FOUR_MOVE_SWITCH] == true
  76.       move_by_input_8direction
  77.       return
  78.     end
  79.     return if !movable? || $game_map.interpreter.running?
  80.     if Input.press?(:LEFT) && Input.press?(:DOWN)
  81.       if passable?(@x, @y, 4) && passable?(@x, @y, 2) &&
  82.         passable?(@x - 1, @y, 2) && passable?(@x, @y + 1, 4) &&
  83.         passable?(@x - 1, @y + 1, 6) && passable?(@x - 1, @y + 1, 8)
  84.         move_diagonal(4, 2)
  85.       elsif @direction == 4
  86.         if passable?(@x, @y, 2) && passable?(@x, @y + 1, 8)
  87.           move_straight(2)
  88.         elsif passable?(@x, @y, 4) && passable?(@x - 1, @y, 6)
  89.           move_straight(4)
  90.         end
  91.       elsif @direction == 2
  92.         if passable?(@x, @y, 4) && passable?(@x - 1, @y, 6)
  93.           move_straight(4)
  94.         elsif passable?(@x, @y, 2) && passable?(@x, @y + 1, 8)
  95.           move_straight(2)
  96.         else
  97.           move_straight(Input.dir4) if Input.dir4 > 0
  98.         end
  99.       else
  100.         move_straight(Input.dir4) if Input.dir4 > 0
  101.       end
  102.     elsif Input.press?(:RIGHT) && Input.press?(:DOWN)
  103.       if passable?(@x, @y, 6) && passable?(@x, @y, 2) &&
  104.         passable?(@x + 1, @y, 2) && passable?(@x, @y + 1, 6) &&
  105.         passable?(@x + 1, @y + 1, 4) && passable?(@x + 1, @y + 1, 8)
  106.         move_diagonal(6, 2)
  107.       elsif @direction == 6
  108.         if passable?(@x, @y, 2) && passable?(@x, @y + 1, 8)
  109.           move_straight(2)
  110.         elsif passable?(@x, @y, 6) && passable?(@x + 1, @y, 4)
  111.           move_straight(6)
  112.         end
  113.       elsif @direction == 2
  114.         if passable?(@x, @y, 6) && passable?(@x + 1, @y, 4)
  115.           move_straight(6)
  116.         elsif passable?(@x, @y, 2) && passable?(@x, @y + 1, 8)
  117.           move_straight(2)
  118.         else
  119.           move_straight(Input.dir4) if Input.dir4 > 0
  120.         end
  121.       else
  122.         move_straight(Input.dir4) if Input.dir4 > 0
  123.       end
  124.     elsif Input.press?(:LEFT) && Input.press?(:UP)
  125.       if passable?(@x, @y, 4) && passable?(@x, @y, 8) &&
  126.         passable?(@x - 1, @y, 8) && passable?(@x, @y - 1, 4) &&
  127.         passable?(@x - 1, @y - 1, 2) && passable?(@x - 1, @y - 1, 6)
  128.         move_diagonal(4, 8)
  129.       elsif @direction == 4
  130.         if passable?(@x, @y, 8) && passable?(@x, @y - 1, 2)
  131.           move_straight(8)
  132.         elsif passable?(@x, @y, 4) && passable?(@x - 1, @y, 6)
  133.           move_straight(4)
  134.         else
  135.           move_straight(Input.dir4) if Input.dir4 > 0
  136.         end
  137.       elsif @direction == 8
  138.         if passable?(@x, @y, 4) && passable?(@x - 1, @y, 6)
  139.           move_straight(4)
  140.         elsif passable?(@x, @y, 8) && passable?(@x, @y - 1, 2)
  141.           move_straight(8)
  142.         else
  143.           move_straight(Input.dir4) if Input.dir4 > 0
  144.         end
  145.       else
  146.         move_straight(Input.dir4) if Input.dir4 > 0
  147.       end
  148.     elsif Input.press?(:RIGHT) && Input.press?(:UP)
  149.       if passable?(@x, @y, 6) && passable?(@x, @y, 8) &&
  150.         passable?(@x + 1, @y, 8) && passable?(@x, @y - 1, 6) &&
  151.         passable?(@x + 1, @y - 1, 2) && passable?(@x + 1, @y - 1, 4)
  152.         move_diagonal(6, 8)
  153.       elsif @direction == 6
  154.         if passable?(@x, @y, 8) && passable?(@x, @y - 1, 2)
  155.           move_straight(8)
  156.         elsif passable?(@x, @y, 6) && passable?(@x + 1, @y, 4)
  157.           move_straight(6)
  158.         else
  159.           move_straight(Input.dir4) if Input.dir4 > 0
  160.         end
  161.       elsif @direction == 8
  162.         if passable?(@x, @y, 6) && passable?(@x + 1, @y, 4)
  163.           move_straight(6)
  164.         elsif passable?(@x, @y, 8) && passable?(@x, @y - 1, 2)
  165.           move_straight(8)
  166.         else
  167.           move_straight(Input.dir4) if Input.dir4 > 0
  168.         end
  169.       else
  170.         move_straight(Input.dir4) if Input.dir4 > 0
  171.       end
  172.     else
  173.       move_straight(Input.dir4) if Input.dir4 > 0
  174.     end
  175.     unless moving?
  176.       @direction = Input.dir4 unless Input.dir4 == 0
  177.     end
  178.   end
  179. end
复制代码

点评

这个我有了的。我需要的不是伪8方,是真八方,就是用八方行走图的。麻烦了,谢谢~  发表于 2012-12-4 19:15
設定翻譯完了  发表于 2012-12-4 18:45
翻譯中  发表于 2012-12-4 18:35
回复 支持 反对

使用道具 举报

Lv2.观梦者

花开堪折直须折

梦石
0
星屑
611
在线时间
943 小时
注册时间
2010-7-17
帖子
4963

贵宾

 楼主| 发表于 2012-12-5 20:33:51 | 显示全部楼层
自顶成吗?
回复 支持 反对

使用道具 举报

Lv2.观梦者

花开堪折直须折

梦石
0
星屑
611
在线时间
943 小时
注册时间
2010-7-17
帖子
4963

贵宾

 楼主| 发表于 2012-12-20 18:32:08 | 显示全部楼层
再一次的自頂成嗎?
大家好,我叫节操,有一天,我被吃了。
http://forever-dream.5d6d.com
永恒の梦制作组论坛

129993099
永恒の梦制作组QQ群
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-28 20:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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