幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1765|回复: 6

发一个制作横版过关游戏的脚本

[复制链接]

1

主题

5

帖子

1223

积分

⑥精研

积分
1223
发表于 2005-10-21 09:35:38 | 显示全部楼层 |阅读模式
说明:来自国外的脚本。上行键跳跃,A键跳得更高。

因为当初看到的时候是乱码,怀着资源共享的激动发到幻森,根本没想到别的,所产生的误会请大家谅解。



  1. # ▼▲▼ XRXS50. Action-Maps XC. ▼▲▼ built 033010
  2. # by 桜雅 在土
  3. #==============================================================================
  4. # □ カスタマイズポイント
  5. #==============================================================================
  6. class XRXS50
  7. #
  8. # Action-Maps を稼動させるマップIDの配列
  9. #
  10. ENABLE_FULL_ACTY_MAPS = [1, 2]
  11. #
  12. # 「斜め降下」
  13. #
  14. ENABLE_SLIDE_DESCENT = true
  15. #
  16. # 向きジャンプ(true  : 向いている方向へジャンプ。
  17. #              false : キーが押されている方向へジャンプ。)
  18. #
  19. JUMP_AS_KEY = false
  20. end
  21. #==============================================================================
  22. # ■ Game_Player
  23. #==============================================================================
  24. class Game_Player < Game_Character
  25. #--------------------------------------------------------------------------
  26. # ○ 公開インスタンス変数
  27. #--------------------------------------------------------------------------
  28. # 既存
  29. attr_writer   :direction_fix
  30. attr_accessor :walk_anime
  31. # 新規
  32. attr_accessor :now_jumps
  33. attr_writer   :xrxs50_direction_sidefix
  34. #--------------------------------------------------------------------------
  35. # ○ 最大ジャンプ回数
  36. #--------------------------------------------------------------------------
  37. def max_jumps
  38.    return 1
  39. end
  40. #--------------------------------------------------------------------------
  41. # ● 左を向く
  42. #--------------------------------------------------------------------------
  43. alias xrxs50_turn_left turn_left
  44. def turn_left
  45.    if @xrxs50_direction_sidefix
  46.      @direction = 4
  47.    else
  48.      xrxs50_turn_left
  49.    end
  50. end
  51. #--------------------------------------------------------------------------
  52. # ● 右を向く
  53. #--------------------------------------------------------------------------
  54. alias xrxs50_turn_right turn_right
  55. def turn_right
  56.    if @xrxs50_direction_sidefix
  57.      @direction = 6
  58.    else
  59.      xrxs50_turn_right
  60.    end
  61. end
  62. end
  63. #==============================================================================
  64. # ■ Scene_Map
  65. #==============================================================================
  66. class Scene_Map
  67. #--------------------------------------------------------------------------
  68. # ● メイン処理
  69. #--------------------------------------------------------------------------
  70. alias xrxs50_main main
  71. def main
  72.    # チェック
  73.    xrxs50_enable_check
  74.    # 呼び戻す
  75.    xrxs50_main
  76. end
  77. #--------------------------------------------------------------------------
  78. # ● フレーム更新
  79. #--------------------------------------------------------------------------
  80. alias xrxs50_update update
  81. def update
  82.    # 呼び戻す
  83.    xrxs50_update
  84.    # フレーム更新 (座標系更新)
  85.    if @xrxs50_enable
  86.      update_coordinates
  87.    end
  88. end
  89. #--------------------------------------------------------------------------
  90. # ○ フレーム更新 (座標系更新)
  91. #--------------------------------------------------------------------------
  92. def update_coordinates
  93.    if $game_player.passable?($game_player.x,$game_player.y,2)
  94.      unless $game_player.moving?
  95.        if XRXS50::ENABLE_SLIDE_DESCENT and
  96.           Input.press?(Input::RIGHT) and
  97.           $game_player.passable?($game_player.x,$game_player.y+1,6)
  98.          $game_player.move_lower_right
  99.        elsif XRXS50::ENABLE_SLIDE_DESCENT and
  100.              Input.press?(Input::LEFT) and
  101.              $game_player.passable?($game_player.x,$game_player.y+1,4)
  102.          $game_player.move_lower_left
  103.        else
  104.          $game_player.move_down
  105.        end
  106.      end
  107.    else
  108.      $game_player.move_down
  109.      $game_player.walk_anime = true unless $game_player.walk_anime
  110.      $game_player.now_jumps  = 0
  111.      if Input.trigger?(Input::X) and
  112.         $game_player.now_jumps < $game_player.max_jumps
  113.        if XRXS50::JUMP_AS_KEY
  114.          direction = $game_player.direction == 4 ? -1 : 1
  115.        else
  116.          if Input.press?(Input::RIGHT)
  117.            direction = 1
  118.          elsif Input.press?(Input::LEFT)
  119.            direction = -1
  120.          else
  121.            direction = 0
  122.          end
  123.        end
  124.        $game_player.jump(direction, -2)
  125.        $game_player.now_jumps += 1
  126.        $game_player.walk_anime = false
  127.      end
  128.    end
  129. end
  130. #--------------------------------------------------------------------------
  131. # ● プレイヤーの場所移動
  132. #--------------------------------------------------------------------------
  133. alias xrxs50_transfer_player transfer_player
  134. def transfer_player
  135.    # 呼び戻す
  136.    xrxs50_transfer_player
  137.    # チェック
  138.    xrxs50_enable_check
  139. end
  140. #--------------------------------------------------------------------------
  141. # ○ XRXS50 が稼動するか判定
  142. #--------------------------------------------------------------------------
  143. def xrxs50_enable_check
  144.    if XRXS50::ENABLE_FULL_ACTY_MAPS.include?($game_map.map_id)
  145.      $game_player.now_jumps = 0 if $game_player.now_jumps.nil?
  146.      @xrxs50_enable = true
  147.      $game_player.direction_fix = true
  148.      $game_player.xrxs50_direction_sidefix = true
  149.    else
  150.      @xrxs50_enable = false
  151.      $game_player.direction_fix = false
  152.      $game_player.xrxs50_direction_sidefix = false
  153.    end
  154. end
  155. end
复制代码
回复

使用道具 举报

50

主题

994

帖子

6699

积分

管理员

爱干啥干啥!

Rank: 9Rank: 9Rank: 9

积分
6699
发表于 2005-10-21 15:27:06 | 显示全部楼层
可惜注释都花掉了。

“放下屠刀,立地成佛” 故应先杀生,然后再成佛。

(\\_/) (-_-) ()+() this is bunny priest.
回复 支持 反对

使用道具 举报

1

主题

6

帖子

19

积分

②入门

积分
19
发表于 2005-10-21 15:40:30 | 显示全部楼层
乱码!截个图老看看!
回复 支持 反对

使用道具 举报

1

主题

5

帖子

1223

积分

⑥精研

积分
1223
 楼主| 发表于 2005-10-21 16:36:00 | 显示全部楼层
乱码不影响使用。
回复 支持 反对

使用道具 举报

50

主题

994

帖子

6699

积分

管理员

爱干啥干啥!

Rank: 9Rank: 9Rank: 9

积分
6699
发表于 2005-10-21 20:20:07 | 显示全部楼层
汗……楼上的就没有明白么……注释里面是关于脚本的说明,以及作者的个人信息,这样相当于无端转载了。

虽说不影响使用,但是亦不要作出无所谓的样子。况且,有注释说明的代码更有助于游戏制作……

找了个原本的,方便的话,楼主编辑了你的顶帖吧。而且,代码要放在[code][/code]标签之间,这样才能保证代码中的符号不被论坛错误识别。
  1. # ▼▲▼ XRXS50. Action-Maps XC. ▼▲▼ built 033010
  2. # by 桜雅 在土
  3. #==============================================================================
  4. # □ カスタマイズポイント
  5. #==============================================================================
  6. class XRXS50
  7. #
  8. # Action-Maps を稼動させるマップIDの配列
  9. #
  10. ENABLE_FULL_ACTY_MAPS = [1, 2]
  11. #
  12. # 「斜め降下」
  13. #
  14. ENABLE_SLIDE_DESCENT = true
  15. #
  16. # 向きジャンプ(true  : 向いている方向へジャンプ。
  17. #              false : キーが押されている方向へジャンプ。)
  18. #
  19. JUMP_AS_KEY = false
  20. end
  21. #==============================================================================
  22. # ■ Game_Player
  23. #==============================================================================
  24. class Game_Player < Game_Character
  25. #--------------------------------------------------------------------------
  26. # ○ 公開インスタンス変数
  27. #--------------------------------------------------------------------------
  28. # 既存
  29. attr_writer   :direction_fix
  30. attr_accessor :walk_anime
  31. # 新規
  32. attr_accessor :now_jumps
  33. attr_writer   :xrxs50_direction_sidefix
  34. #--------------------------------------------------------------------------
  35. # ○ 最大ジャンプ回数
  36. #--------------------------------------------------------------------------
  37. def max_jumps
  38.    return 1
  39. end
  40. #--------------------------------------------------------------------------
  41. # ● 左を向く
  42. #--------------------------------------------------------------------------
  43. alias xrxs50_turn_left turn_left
  44. def turn_left
  45.    if @xrxs50_direction_sidefix
  46.      @direction = 4
  47.    else
  48.      xrxs50_turn_left
  49.    end
  50. end
  51. #--------------------------------------------------------------------------
  52. # ● 右を向く
  53. #--------------------------------------------------------------------------
  54. alias xrxs50_turn_right turn_right
  55. def turn_right
  56.    if @xrxs50_direction_sidefix
  57.      @direction = 6
  58.    else
  59.      xrxs50_turn_right
  60.    end
  61. end
  62. end
  63. #==============================================================================
  64. # ■ Scene_Map
  65. #==============================================================================
  66. class Scene_Map
  67. #--------------------------------------------------------------------------
  68. # ● メイン処理
  69. #--------------------------------------------------------------------------
  70. alias xrxs50_main main
  71. def main
  72.    # チェック
  73.    xrxs50_enable_check
  74.    # 呼び戻す
  75.    xrxs50_main
  76. end
  77. #--------------------------------------------------------------------------
  78. # ● フレーム更新
  79. #--------------------------------------------------------------------------
  80. alias xrxs50_update update
  81. def update
  82.    # 呼び戻す
  83.    xrxs50_update
  84.    # フレーム更新 (座標系更新)
  85.    if @xrxs50_enable
  86.      update_coordinates
  87.    end
  88. end
  89. #--------------------------------------------------------------------------
  90. # ○ フレーム更新 (座標系更新)
  91. #--------------------------------------------------------------------------
  92. def update_coordinates
  93.    if $game_player.passable?($game_player.x,$game_player.y,2)
  94.      unless $game_player.moving?
  95.        if XRXS50::ENABLE_SLIDE_DESCENT and
  96.           Input.press?(Input::RIGHT) and
  97.           $game_player.passable?($game_player.x,$game_player.y+1,6)
  98.          $game_player.move_lower_right
  99.        elsif XRXS50::ENABLE_SLIDE_DESCENT and
  100.              Input.press?(Input::LEFT) and
  101.              $game_player.passable?($game_player.x,$game_player.y+1,4)
  102.          $game_player.move_lower_left
  103.        else
  104.          $game_player.move_down
  105.        end
  106.      end
  107.    else
  108.      $game_player.move_down
  109.      $game_player.walk_anime = true unless $game_player.walk_anime
  110.      $game_player.now_jumps  = 0
  111.      if Input.trigger?(Input::X) and
  112.         $game_player.now_jumps < $game_player.max_jumps
  113.        if XRXS50::JUMP_AS_KEY
  114.          direction = $game_player.direction == 4 ? -1 : 1
  115.        else
  116.          if Input.press?(Input::RIGHT)
  117.            direction = 1
  118.          elsif Input.press?(Input::LEFT)
  119.            direction = -1
  120.          else
  121.            direction = 0
  122.          end
  123.        end
  124.        $game_player.jump(direction, -2)
  125.        $game_player.now_jumps += 1
  126.        $game_player.walk_anime = false
  127.      end
  128.    end
  129. end
  130. #--------------------------------------------------------------------------
  131. # ● プレイヤーの場所移動
  132. #--------------------------------------------------------------------------
  133. alias xrxs50_transfer_player transfer_player
  134. def transfer_player
  135.    # 呼び戻す
  136.    xrxs50_transfer_player
  137.    # チェック
  138.    xrxs50_enable_check
  139. end
  140. #--------------------------------------------------------------------------
  141. # ○ XRXS50 が稼動するか判定
  142. #--------------------------------------------------------------------------
  143. def xrxs50_enable_check
  144.    if XRXS50::ENABLE_FULL_ACTY_MAPS.include?($game_map.map_id)
  145.      $game_player.now_jumps = 0 if $game_player.now_jumps.nil?
  146.      @xrxs50_enable = true
  147.      $game_player.direction_fix = true
  148.      $game_player.xrxs50_direction_sidefix = true
  149.    else
  150.      @xrxs50_enable = false
  151.      $game_player.direction_fix = false
  152.      $game_player.xrxs50_direction_sidefix = false
  153.    end
  154. end
  155. end
复制代码

“放下屠刀,立地成佛” 故应先杀生,然后再成佛。

(\\_/) (-_-) ()+() this is bunny priest.
回复 支持 反对

使用道具 举报

洋娃娃 该用户已被删除
发表于 2005-10-21 21:32:09 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

50

主题

994

帖子

6699

积分

管理员

爱干啥干啥!

Rank: 9Rank: 9Rank: 9

积分
6699
发表于 2005-10-22 01:54:28 | 显示全部楼层
没有考虑加速度,所以有点飘的感觉.
斜上跳落地时变成垂直了,有点撞到东西的感觉.

PS:RM是32象素一个格子的吧?

“放下屠刀,立地成佛” 故应先杀生,然后再成佛。

(\\_/) (-_-) ()+() this is bunny priest.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-24 23:23 , Processed in 0.011493 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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