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

Project1

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

[已经解决] 怎么制作一个人物跟随的小游戏

[复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2010-8-19
帖子
12
跳转到指定楼层
1
发表于 2010-8-20 08:24:25 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
17 小时
注册时间
2010-8-10
帖子
14
5
发表于 2010-8-20 10:03:21 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

万物创造者

梦石
0
星屑
54
在线时间
352 小时
注册时间
2008-2-15
帖子
2432
4
发表于 2010-8-20 08:57:33 | 只看该作者
本帖最后由 小幽的马甲 于 2010-8-20 10:09 编辑

呃……这个脚本的兼容性不好= =
跟随脚本推荐这个国外的http://www.rpgrevolution.com/forums/?showtopic=8040,兼容性好很多

  1. class Game_Player
  2.   #--------------------------------------------------------------------------
  3.   # * Move Down
  4.   #     turn_enabled : a flag permits direction change on that spot
  5.   #--------------------------------------------------------------------------
  6.   def move_down(turn_enabled = true)   
  7.     super(turn_enabled)
  8.   end
  9.   #--------------------------------------------------------------------------
  10.   # * Move Left
  11.   #     turn_enabled : a flag permits direction change on that spot
  12.   #--------------------------------------------------------------------------
  13.   def move_left(turn_enabled = true)
  14.     super(turn_enabled)
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # * Move Right
  18.   #     turn_enabled : a flag permits direction change on that spot
  19.   #--------------------------------------------------------------------------
  20.   def move_right(turn_enabled = true)
  21.     super(turn_enabled)
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # * Move up
  25.   #     turn_enabled : a flag permits direction change on that spot
  26.   #--------------------------------------------------------------------------
  27.   def move_up(turn_enabled = true)
  28.     super(turn_enabled)
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # * Move Lower Left
  32.   #--------------------------------------------------------------------------
  33.   def move_lower_left
  34.     super
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # * Move Lower Right
  38.   #--------------------------------------------------------------------------
  39.   def move_lower_right
  40.     super
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # * Move Upper Left
  44.   #--------------------------------------------------------------------------
  45.   def move_upper_left
  46.     super
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # * Move Upper Right
  50.   #--------------------------------------------------------------------------
  51.   def move_upper_right
  52.     super
  53.   end
  54. end

  55. class Game_Follower < Game_Character
  56.   #--------------------------------------------------------------------------
  57.   # * Public Instance Variables
  58.   #--------------------------------------------------------------------------
  59.   attr_reader   :actor
  60.   attr_accessor :move_speed
  61.   #--------------------------------------------------------------------------
  62.   # * Object Initialization
  63.   #--------------------------------------------------------------------------
  64.   def initialize(actor)
  65.     super()
  66.     @through = true
  67.     @actor = actor
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * Set Actor
  71.   #--------------------------------------------------------------------------
  72.   def actor=(actor)
  73.     @actor = actor
  74.     setup
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # * Setup
  78.   #--------------------------------------------------------------------------
  79.   def setup
  80.     if @actor != nil      
  81.       @character_name = $game_actors[@actor].character_name
  82.       @character_index = $game_actors[@actor].character_index
  83.     else
  84.       @character_name = ""
  85.       @character_index = 0
  86.     end
  87.     @opacity = 255
  88.     @blend_type = 0
  89.     @priority_type = 0
  90.   end
  91.   
  92.   #--------------------------------------------------------------------------
  93.   # * Screen Z
  94.   #--------------------------------------------------------------------------
  95.   def screen_z
  96.     if $game_player.x == @x and $game_player.y == @y
  97.       return $game_player.screen_z - 1
  98.     end
  99.     super
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # * Same Position Starting Determinant (Disabled)
  103.   #--------------------------------------------------------------------------
  104.   def check_event_trigger_here(triggers)
  105.     result = false
  106.     return result
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # * Front Envent Starting Determinant (Disabled)
  110.   #--------------------------------------------------------------------------
  111.   def check_event_trigger_there(triggers)
  112.     result = false
  113.     return result
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # * Touch Event Starting Determinant (Disabled)
  117.   #--------------------------------------------------------------------------
  118.   def check_event_trigger_touch(x, y)
  119.     result = false
  120.     return result
  121.   end
  122. end

  123. class Spriteset_Map
  124.   alias_method :spriteset_map_create_characters, :create_characters
  125.   def create_characters
  126.     spriteset_map_create_characters
  127.     $game_party.followers.each do |char|
  128.       @character_sprites << Sprite_Character.new(@viewport1, char)
  129.     end
  130.   end
  131. end

  132. class Game_Party
  133.   #--------------------------------------------------------------------------
  134.   # * Constants
  135.   #--------------------------------------------------------------------------
  136.   MAX_SIZE = 8
  137.   CATERPILLAR = 2
  138.   #--------------------------------------------------------------------------
  139.   # * Public Instance Variables
  140.   #--------------------------------------------------------------------------
  141.   attr_reader :followers
  142.   #--------------------------------------------------------------------------
  143.   # * Object Initialization
  144.   #--------------------------------------------------------------------------
  145.   alias_method :trick_caterpillar_party_initialize, :initialize
  146.   def initialize
  147.     trick_caterpillar_party_initialize
  148.     @followers = Array.new(MAX_SIZE - 1) {Game_Follower.new(nil)}
  149.     @move_list = []
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * Update Followers
  153.   #--------------------------------------------------------------------------
  154.   def update_followers
  155.     flag = $game_player.transparent || $game_switches[CATERPILLAR]
  156.     @followers.each_with_index do |char, i|
  157.       char.actor = @actors[i + 1]
  158.       char.move_speed = $game_player.move_speed
  159.       if $game_player.dash?
  160.         char.move_speed += 1
  161.       end
  162.       char.update
  163.       char.transparent = flag
  164.     end
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # * Move To Party
  168.   #--------------------------------------------------------------------------
  169.   def moveto_party(x, y)
  170.     @followers.each {|char| char.moveto(x, y)}
  171.     @move_list.clear
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # * Move Party
  175.   #--------------------------------------------------------------------------
  176.   def move_party
  177.     @move_list.each_index do |i|
  178.       if @followers[i] == nil
  179.         @move_list[i...@move_list.size] = nil
  180.         next
  181.       end
  182.       case @move_list[i].type
  183.       when 2
  184.         @followers[i].move_down(*@move_list[i].args)
  185.       when 4
  186.         @followers[i].move_left(*@move_list[i].args)
  187.       when 6
  188.         @followers[i].move_right(*@move_list[i].args)
  189.       when 8
  190.         @followers[i].move_up(*@move_list[i].args)
  191.       when 1
  192.         @followers[i].move_lower_left
  193.       when 3
  194.         @followers[i].move_lower_right
  195.       when 7
  196.         @followers[i].move_upper_left
  197.       when 9
  198.         @followers[i].move_upper_right
  199.       when 5
  200.         @followers[i].jump(*@move_list[i].args)
  201.       end
  202.     end
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # * Add Move List
  206.   #--------------------------------------------------------------------------
  207.   def update_move(type, *args)
  208.     move_party
  209.     @move_list.unshift(Game_MoveListElement.new(type, args))
  210.   end
  211. end

  212. class Game_MoveListElement
  213.   #--------------------------------------------------------------------------
  214.   # * Object Initialization
  215.   #--------------------------------------------------------------------------
  216.   def initialize(type, args)
  217.     @type = type
  218.     @args = args
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # * Type
  222.   #--------------------------------------------------------------------------
  223.   def type
  224.     return @type
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # * Args
  228.   #--------------------------------------------------------------------------
  229.   def args
  230.     return @args
  231.   end
  232. end

  233. class Game_Player
  234.   #--------------------------------------------------------------------------
  235.   # * Public Instance Variables
  236.   #--------------------------------------------------------------------------
  237.   attr_reader :move_speed
  238.   
  239.   #--------------------------------------------------------------------------
  240.   # * Update
  241.   #--------------------------------------------------------------------------
  242.   alias_method :trick_caterpillar_player_update, :update
  243.   def update
  244.     $game_party.update_followers
  245.     trick_caterpillar_player_update
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # * Moveto
  249.   #--------------------------------------------------------------------------
  250.   alias_method :trick_caterpillar_player_moveto, :moveto
  251.   def moveto(x, y)
  252.     $game_party.moveto_party(x, y)
  253.     trick_caterpillar_player_moveto(x, y)
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # * Move Down
  257.   #--------------------------------------------------------------------------
  258.   alias_method :trick_caterpillar_player_move_down, :move_down
  259.   def move_down(turn_enabled = true)
  260.     if passable?(@x, @y+1)
  261.       $game_party.update_move(2, turn_enabled)
  262.     end   
  263.     trick_caterpillar_player_move_down(turn_enabled)   
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # * Move Left
  267.   #--------------------------------------------------------------------------
  268.   alias_method :trick_caterpillar_player_move_left, :move_left
  269.   def move_left(turn_enabled = true)
  270.     if passable?(@x-1, @y)
  271.       $game_party.update_move(4, turn_enabled)
  272.     end
  273.     trick_caterpillar_player_move_left(turn_enabled)
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # * Move Right
  277.   #--------------------------------------------------------------------------
  278.   alias_method :trick_caterpillar_player_move_right, :move_right
  279.   def move_right(turn_enabled = true)
  280.     if passable?(@x+1, @y)
  281.       $game_party.update_move(6, turn_enabled)
  282.     end
  283.     trick_caterpillar_player_move_right(turn_enabled)
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # * Move Up
  287.   #--------------------------------------------------------------------------
  288.   alias_method :trick_caterpillar_player_move_up, :move_up
  289.   def move_up(turn_enabled = true)
  290.     if passable?(@x, @y-1)
  291.       $game_party.update_move(8, turn_enabled)
  292.     end
  293.     trick_caterpillar_player_move_up(turn_enabled)
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # * Move Lower Left
  297.   #--------------------------------------------------------------------------
  298.   alias_method :trick_caterpillar_player_move_lower_left, :move_lower_left
  299.   def move_lower_left
  300.     if passable?(@x - 1, @y) and passable?(@x, @y + 1)
  301.       $game_party.update_move(1)
  302.     end
  303.     trick_caterpillar_player_move_lower_left
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # * Move Lower Right
  307.   #--------------------------------------------------------------------------
  308.   alias_method :trick_caterpillar_player_move_lower_right, :move_lower_right
  309.   def move_lower_right
  310.     if passable?(@x + 1, @y) and passable?(@x, @y + 1)
  311.       $game_party.update_move(3)
  312.     end
  313.     trick_caterpillar_player_move_lower_right
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # * Move Upper Left
  317.   #--------------------------------------------------------------------------
  318.   alias_method :trick_caterpillar_player_move_upper_left, :move_upper_left
  319.   def move_upper_left
  320.     if passable?(@x - 1, @y) and passable?(@x, @y - 1)
  321.       $game_party.update_move(7)
  322.     end
  323.     trick_caterpillar_player_move_upper_left
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # * Move Upper Right
  327.   #--------------------------------------------------------------------------
  328.   alias_method :trick_caterpillar_player_move_upper_right, :move_upper_right
  329.   def move_upper_right
  330.     if passable?(@x + 1, @y) and passable?(@x, @y - 1)
  331.       $game_party.update_move(9)
  332.     end
  333.     trick_caterpillar_player_move_upper_right
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # * Jump
  337.   #--------------------------------------------------------------------------
  338.   alias_method :trick_caterpillar_player_jump, :jump
  339.   def jump(x_plus, y_plus)
  340.     new_x = @x + x_plus
  341.     new_y = @y + y_plus
  342.     if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y)
  343.       $game_party.update_move(5, x_plus, y_plus)
  344.     end
  345.     trick_caterpillar_player_jump(x_plus, y_plus)
  346.   end
  347. end###########
  348. ###########
  349. ###########
复制代码
From mortal hope immortal power springs.
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2010-8-19
帖子
12
3
 楼主| 发表于 2010-8-20 08:39:01 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
90
在线时间
308 小时
注册时间
2010-8-10
帖子
794
2
发表于 2010-8-20 08:31:10 | 只看该作者
本帖最后由 不是马甲 于 2010-8-20 08:33 编辑

人物跟随脚本http://rpg.blue/forum.php?mod=vi ... 9%E8%B7%9F%E9%9A%8F

是  ONEWateR   编写的   具体在下面
  1. #==============================================================================
  2. # ■ 人物跟随
  3. #------------------------------------------------------------------------------
  4. #
  5. #   本脚本来自www.66RPG.com,使用和转载请保留此信息
  6. #
  7. #   作者:fukuyama   
  8. #
  9. #   移植:ONEWateR
  10. #
  11. #==============================================================================
  12. module Train_Actor

  13. #是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX
  14. #开关打开,跟随的人物就消失了(其实只是变成透明而已)

  15. TRANSPARENT_SWITCH = true
  16. TRANSPARENT_SWITCHES_INDEX = 1
  17. #举例:第一个为true,第二个为20,则打开20号开关,后面的人都没了。

  18. #跟随人数的最大数目,可以更改为2、3什么的。
  19. TRAIN_ACTOR_SIZE_MAX = 4

  20. # 定数
  21. DOWN_LEFT = 1
  22. DOWN_RIGHT = 3
  23. UP_LEFT = 7
  24. UP_RIGHT = 9
  25. JUMP = 5

  26. class Game_Party_Actor < Game_Character
  27. def initialize
  28. super()
  29. @through = true
  30. end
  31. def setup(actor)
  32. if actor != nil
  33. @character_index = actor.character_index
  34. @character_name = actor.character_name
  35. @priority_type = 1
  36. else
  37. @character_name = ""
  38. @character_index = 0
  39. @priority_type = 1
  40. end
  41. # 不透明度と合成方法を初期化
  42. @opacity = 255
  43. @blend_type = 0
  44. end
  45. #--------------------------------------------------------------------------
  46. # ● 下に移動
  47. # turn_enabled : その場での向き変更を許可するフラグ
  48. #--------------------------------------------------------------------------
  49. def move_down(turn_enabled = true)
  50. # 下を向く
  51. if turn_enabled
  52. turn_down
  53. end
  54. # 通行可能な場合
  55. if new_passable?(@x, @y, Input::DOWN)
  56. # 下を向く
  57. turn_down
  58. # 座標を更新
  59. @y += 1
  60. end
  61. end
  62. #--------------------------------------------------------------------------
  63. # ● 左に移動
  64. # turn_enabled : その場での向き変更を許可するフラグ
  65. #--------------------------------------------------------------------------
  66. def move_left(turn_enabled = true)
  67. # 左を向く
  68. if turn_enabled
  69. turn_left
  70. end
  71. # 通行可能な場合
  72. if new_passable?(@x, @y, Input::LEFT)
  73. # 左を向く
  74. turn_left
  75. # 座標を更新
  76. @x -= 1
  77. end
  78. end
  79. #--------------------------------------------------------------------------
  80. # ● 右に移動
  81. # turn_enabled : その場での向き変更を許可するフラグ
  82. #--------------------------------------------------------------------------
  83. def move_right(turn_enabled = true)
  84. # 右を向く
  85. if turn_enabled
  86. turn_right
  87. end
  88. # 通行可能な場合
  89. if new_passable?(@x, @y, Input::RIGHT)
  90. # 右を向く
  91. turn_right
  92. # 座標を更新
  93. @x += 1
  94. end
  95. end
  96. #--------------------------------------------------------------------------
  97. # ● 上に移動
  98. # turn_enabled : その場での向き変更を許可するフラグ
  99. #--------------------------------------------------------------------------
  100. def move_up(turn_enabled = true)
  101. # 上を向く
  102. if turn_enabled
  103. turn_up
  104. end
  105. # 通行可能な場合
  106. if new_passable?(@x, @y, Input::UP)
  107. # 上を向く
  108. turn_up
  109. # 座標を更新
  110. @y -= 1
  111. end
  112. end
  113. #--------------------------------------------------------------------------
  114. # ● 左下に移動
  115. #--------------------------------------------------------------------------
  116. def move_lower_left
  117. # 向き固定でない場合
  118. unless @direction_fix
  119. # 右向きだった場合は左を、上向きだった場合は下を向く
  120. @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  121. end
  122. # 下→左、左→下 のどちらかのコースが通行可能な場合
  123. if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
  124. (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
  125. # 座標を更新
  126. @x -= 1
  127. @y += 1
  128. end
  129. end
  130. #--------------------------------------------------------------------------
  131. # ● 右下に移動
  132. #--------------------------------------------------------------------------
  133. def move_lower_right
  134. # 向き固定でない場合
  135. unless @direction_fix
  136. # 左向きだった場合は右を、上向きだった場合は下を向く
  137. @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  138. end
  139. # 下→右、右→下 のどちらかのコースが通行可能な場合
  140. if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
  141. (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
  142. # 座標を更新
  143. @x += 1
  144. @y += 1
  145. end
  146. end
  147. #--------------------------------------------------------------------------
  148. # ● 左上に移動
  149. #--------------------------------------------------------------------------
  150. def move_upper_left
  151. # 向き固定でない場合
  152. unless @direction_fix
  153. # 右向きだった場合は左を、下向きだった場合は上を向く
  154. @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  155. end
  156. # 上→左、左→上 のどちらかのコースが通行可能な場合
  157. if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
  158. (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
  159. # 座標を更新
  160. @x -= 1
  161. @y -= 1
  162. end
  163. end
  164. #--------------------------------------------------------------------------
  165. # ● 右上に移動
  166. #--------------------------------------------------------------------------
  167. def move_upper_right
  168. # 向き固定でない場合
  169. unless @direction_fix
  170. # 左向きだった場合は右を、下向きだった場合は上を向く
  171. @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  172. end
  173. # 上→右、右→上 のどちらかのコースが通行可能な場合
  174. if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
  175. (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
  176. # 座標を更新
  177. @x += 1
  178. @y -= 1
  179. end
  180. end
  181. attr_writer :move_speed
  182. attr_writer :step_anime
  183. end
  184. module Spriteset_Map_Module
  185. def setup_actor_character_sprites?
  186. return @setup_actor_character_sprites_flag != nil
  187. end
  188. def setup_actor_character_sprites(characters)
  189. if !setup_actor_character_sprites?
  190. index_game_player = 0
  191. @character_sprites.each_index do |i|
  192. if @character_sprites[i].character.instance_of?(Game_Player)
  193. index_game_player = i
  194. break
  195. end
  196. end
  197. for character in characters.reverse
  198. @character_sprites.unshift(
  199. Sprite_Character.new(@viewport1, character)
  200. )
  201. end
  202. @setup_actor_character_sprites_flag = true
  203. end
  204. end
  205. end
  206. module Scene_Map_Module
  207. def setup_actor_character_sprites(characters)
  208. @spriteset.setup_actor_character_sprites(characters)
  209. end
  210. end
  211. module Game_Party_Module
  212. def set_transparent_actors(transparent)
  213. @transparent = transparent
  214. end
  215. def setup_actor_character_sprites
  216. if @characters == nil
  217. @characters = []

  218. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  219. @characters.push(Game_Party_Actor.new)
  220. end
  221. end
  222. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  223. @characters[i - 1].setup($game_party.members[i])
  224. end

  225. if $scene.class.method_defined?('setup_actor_character_sprites')
  226. $scene.setup_actor_character_sprites(@characters)
  227. end
  228. end
  229. def update_party_actors
  230. setup_actor_character_sprites
  231. transparent = $game_player.transparent
  232. if transparent == false
  233. if TRANSPARENT_SWITCH
  234. transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  235. end
  236. end
  237. for character in @characters
  238. character.transparent = transparent
  239. if $game_player.dash?
  240. character.move_speed = $game_player.move_speed*1.25
  241. else
  242. character.move_speed = $game_player.move_speed
  243. end
  244. character.step_anime = $game_player.step_anime
  245. character.update
  246. end
  247. end
  248. def moveto_party_actors( x, y )
  249. setup_actor_character_sprites
  250. for character in @characters
  251. character.moveto( x, y )
  252. end
  253. if @move_list == nil
  254. @move_list = []
  255. end
  256. move_list_setup
  257. end
  258. def move_party_actors
  259. if @move_list == nil
  260. @move_list = []
  261. move_list_setup
  262. end
  263. @move_list.each_index do |i|
  264. if @characters[i] != nil
  265. case @move_list[i].type
  266. when Input::DOWN
  267. @characters[i].move_down(@move_list[i].args[0])
  268. when Input::LEFT
  269. @characters[i].move_left(@move_list[i].args[0])
  270. when Input::RIGHT
  271. @characters[i].move_right(@move_list[i].args[0])
  272. when Input::UP
  273. @characters[i].move_up(@move_list[i].args[0])
  274. when DOWN_LEFT
  275. @characters[i].move_lower_left
  276. when DOWN_RIGHT
  277. @characters[i].move_lower_right
  278. when UP_LEFT
  279. @characters[i].move_upper_left
  280. when UP_RIGHT
  281. @characters[i].move_upper_right
  282. when JUMP
  283. @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  284. end
  285. end
  286. end
  287. end
  288. class Move_List_Element
  289. def initialize(type,args)
  290. @type = type
  291. @args = args
  292. end
  293. def type() return @type end
  294. def args() return @args end
  295. end
  296. def move_list_setup
  297. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  298. @move_list[i] = nil
  299. end
  300. end
  301. def add_move_list(type,*args)
  302. @move_list.unshift(Move_List_Element.new(type,args)).pop
  303. end
  304. def move_down_party_actors(turn_enabled = true)
  305. move_party_actors
  306. add_move_list(Input::DOWN,turn_enabled)
  307. end
  308. def move_left_party_actors(turn_enabled = true)
  309. move_party_actors
  310. add_move_list(Input::LEFT,turn_enabled)
  311. end
  312. def move_right_party_actors(turn_enabled = true)
  313. move_party_actors
  314. add_move_list(Input::RIGHT,turn_enabled)
  315. end
  316. def move_up_party_actors(turn_enabled = true)
  317. move_party_actors
  318. add_move_list(Input::UP,turn_enabled)
  319. end
  320. def move_lower_left_party_actors
  321. move_party_actors
  322. add_move_list(DOWN_LEFT)
  323. end
  324. def move_lower_right_party_actors
  325. move_party_actors
  326. add_move_list(DOWN_RIGHT)
  327. end
  328. def move_upper_left_party_actors
  329. move_party_actors
  330. add_move_list(UP_LEFT)
  331. end
  332. def move_upper_right_party_actors
  333. move_party_actors
  334. add_move_list(UP_RIGHT)
  335. end
  336. def jump_party_actors(x_plus, y_plus)
  337. move_party_actors
  338. add_move_list(JUMP,x_plus, y_plus)
  339. end
  340. end
  341. module Game_Player_Module
  342. def update
  343. $game_party.update_party_actors
  344. super
  345. end
  346. def moveto( x, y )
  347. $game_party.moveto_party_actors( x, y )
  348. super( x, y )
  349. end
  350. def move_down(turn_enabled = true)
  351. if new_passable?(@x, @y, Input::DOWN)
  352. $game_party.move_down_party_actors(turn_enabled)
  353. end
  354. super(turn_enabled)
  355. end
  356. def move_left(turn_enabled = true)
  357. if new_passable?(@x, @y, Input::LEFT)
  358. $game_party.move_left_party_actors(turn_enabled)
  359. end
  360. super(turn_enabled)
  361. end
  362. def move_right(turn_enabled = true)
  363. if new_passable?(@x, @y, Input::RIGHT)
  364. $game_party.move_right_party_actors(turn_enabled)
  365. end
  366. super(turn_enabled)
  367. end
  368. def move_up(turn_enabled = true)
  369. if new_passable?(@x, @y, Input::UP)
  370. $game_party.move_up_party_actors(turn_enabled)
  371. end
  372. super(turn_enabled)
  373. end
  374. def move_lower_left
  375. # 下→左、左→下 のどちらかのコースが通行可能な場合
  376. if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
  377. (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
  378. $game_party.move_lower_left_party_actors
  379. end
  380. super
  381. end
  382. def move_lower_right
  383. # 下→右、右→下 のどちらかのコースが通行可能な場合
  384. if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
  385. (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
  386. $game_party.move_lower_right_party_actors
  387. end
  388. super
  389. end
  390. def move_upper_left
  391. # 上→左、左→上 のどちらかのコースが通行可能な場合
  392. if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
  393. (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
  394. $game_party.move_upper_left_party_actors
  395. end
  396. super
  397. end
  398. def move_upper_right
  399. # 上→右、右→上 のどちらかのコースが通行可能な場合
  400. if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
  401. (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
  402. $game_party.move_upper_right_party_actors
  403. end
  404. super
  405. end
  406. def jump(x_plus, y_plus)
  407. # 新しい座標を計算
  408. new_x = @x + x_plus
  409. new_y = @y + y_plus
  410. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  411. if (x_plus == 0 and y_plus == 0) or new_passable?(new_x, new_y, 0)
  412. $game_party.jump_party_actors(x_plus, y_plus)
  413. end
  414. super(x_plus, y_plus)
  415. end
  416. attr_accessor :move_speed
  417. attr_accessor :step_anime
  418. end
  419. end # module Train_Actor
  420. class Game_Party
  421. include Train_Actor::Game_Party_Module
  422. end
  423. class Game_Player
  424. include Train_Actor::Game_Player_Module
  425. end
  426. class Spriteset_Map
  427. include Train_Actor::Spriteset_Map_Module
  428. end
  429. class Scene_Map
  430. include Train_Actor::Scene_Map_Module
  431. end
  432. class Game_Character
  433. def new_passable?(x, y, d)
  434. new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  435. new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  436. unless $game_map.valid?(new_x, new_y)
  437. return false
  438. end
  439. x = $game_map.round_x(x)                        # 横方向循环修正
  440. y = $game_map.round_y(y)                        # 纵方向循环修正
  441. return false unless $game_map.valid?(x, y)      # 地图外?
  442. return true if @through or debug_through?       # 穿越 ON?
  443. return false unless map_passable?(new_x, new_y)         # 地图不能通行?
  444. return false if collide_with_characters?(new_x, new_y)  # 与角色冲突?
  445. return true                                     # 可以通行
  446. end
  447. end
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 00:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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