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

Project1

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

[已经过期] 为什么我的夢子不动了...

[复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
177 小时
注册时间
2011-7-3
帖子
235
跳转到指定楼层
1
发表于 2012-1-22 22:23:46 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
在class中已使用如下脚本:
条件分歧,HP不同时动作不同...
  1. #==============================================================================
  2. # ■ TShoot_Enemy
  3. #------------------------------------------------------------------------------
  4. #  シューティングの敵機クラス
  5. #==============================================================================
  6. class TShoot_Enemy < Sprite
  7.   #--------------------------------------------------------------------------
  8.   # ● 公開インスタンス変数
  9.   #--------------------------------------------------------------------------
  10.   attr_reader :sx
  11.   attr_reader :sy
  12.   #--------------------------------------------------------------------------
  13.   # ● オブジェクト初期化
  14.   #--------------------------------------------------------------------------
  15.   def initialize(x, y, shot, move)
  16.     super(nil)
  17.     self.x = 16
  18.     self.y = 16
  19.     self.z = 100
  20.     @sx = x << 10
  21.     @sy = y << 10
  22.     @sx2 = x << 10
  23.     @sy2 = y << 10
  24.     @vx = 0
  25.     @vy = 0
  26.     @shot = shot            # ショットオプション値
  27.     @move = move            # 移動オプション値
  28.     @cnt_move = 0           # 移動用タイマー
  29.     @cnt_shot = 0           # ショット用タイマー
  30.     @cnt_shot_reset = 180   # ショットのループ間隔
  31.     @angle_shot = 0.0
  32.     @anime = 0              # アニメタイマー
  33.     @dir = 2                # 向き
  34.     @hp = 5
  35.     @hp2 = @hp
  36.     @score = 0              # 所持しているスコアアイテム数
  37.     @power = 0              # 同パワーアイテム数
  38.     @life = 0               # 同ライフアイテム数
  39.     @bomb = 0               # 同ボムアイテム数
  40.     @bigpower = 0
  41.     @money = 0
  42.     @bigmoney = 0
  43.     @damageable = 0
  44.     @boss = 0
  45.     set_type
  46.     self.bitmap = Cache.character(@file_name)
  47.     self.src_rect = Rect.new(@file_index % 4 * 96 + 32,
  48.       @file_index / 4 * 128 + ((@dir - 2) / 2) * 32,32,32)
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 更新
  52.   #--------------------------------------------------------------------------
  53.   def update
  54.     if @hp <= 0
  55.       Audio.se_play("Audio/SE/Killed.wav", 80, 150)
  56.       set_item
  57.       $scene.add_effect(3, self.x, self.y, 0, 0)
  58.       $scene.clear_bullet if @boss == 1
  59.       for i in 0...4 * $game_variables[82]
  60.         $scene.add_effect(4,self.x,self.y,rand(2048) - 1024,rand(2048) - 1024)
  61.       end
  62.       dispose
  63.       return
  64.     end
  65.     action
  66.     @sx += @vx
  67.     @sy += @vy
  68.     @sx2 += @vx
  69.     @sy2 += @vy
  70.     self.x = (@sx >> 10)
  71.     self.y = (@sy >> 10)
  72.     if $scene.player.y - 26 > self.y - 18 and $scene.player.y - 26 < self.y - 14
  73.       if $scene.player.x - 21 > self.x - 18 and $scene.player.x - 21 < self.x - 14
  74.         $scene.player.damage
  75.       end
  76.     end
  77.     update_anime
  78.     if self.x < -68 or self.x > 588 or self.y < -68 or self.y > 520
  79.       dispose
  80.     end
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● 更新(アニメーション)
  84.   #--------------------------------------------------------------------------
  85.   def update_anime
  86.     @anime = (@anime + 1) % 60
  87.     pattern = @anime / 15
  88.     pattern = pattern < 3 ? pattern : 0
  89.     self.src_rect.set((@file_index % 4 * 3 + pattern) * 32,
  90.       @file_index / 4 * 128 + ((@dir - 2) / 2) * 32, 32, 32)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 下を向く
  94.   #--------------------------------------------------------------------------
  95.   def turn_down
  96.     @dir = 2
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # ● 左を向く
  100.   #--------------------------------------------------------------------------
  101.   def turn_right
  102.     @dir = 4
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 右を向く
  106.   #--------------------------------------------------------------------------
  107.   def turn_left
  108.     @dir = 6
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 上を向く
  112.   #--------------------------------------------------------------------------
  113.   def turn_up
  114.     @dir = 8
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● ダメージ
  118.   #--------------------------------------------------------------------------
  119.   def damage
  120.     @hp -= $scene.player.damagevalue
  121.     @hp -= $scene.player.damagevalue * 2 if $doubledamagetime > 0
  122.     $scene.se_flag[1] = true
  123.     $scene.info.add_score(50)
  124.     $scene.info.add_mana(1)
  125.   end
  126.   def damageable?
  127.     @damageable < 1
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 自機のいる角度を取得
  131.   #--------------------------------------------------------------------------
  132.   def get_angle
  133.     return $scene.player.get_angle(@sx, @sy)
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● アイテムセット
  137.   #--------------------------------------------------------------------------
  138.   def set_item
  139.     n = @score + @power + @life + @bomb + @money + @bigmoney + @bigpower
  140.     return if n == 0
  141.       a = -Math::PI / 2
  142.     for i in 1..@score
  143.       d = Math::PI * 2 / @score
  144.       a += d
  145.       $scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 1024).to_i,
  146.         (Math.sin(a) * 768).to_i, 0)
  147.     end
  148.     for i in 1..@power
  149.       d = Math::PI * 2 / @power
  150.       a += d
  151.       $scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 768).to_i,
  152.         (Math.sin(a) * 512).to_i, 1)
  153.     end
  154.     for i in 1..@life
  155.       d = Math::PI * 2 / @life
  156.       a += d
  157.       $scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 256).to_i,
  158.         (Math.sin(a) * 1024).to_i, 2)
  159.     end
  160.     for i in 1..@bomb
  161.       d = Math::PI * 2 / @bomb
  162.       a += d
  163.       $scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 256).to_i,
  164.         (Math.sin(a) * 1024).to_i, 3)
  165.     end
  166.     for i in 1..@money
  167.       d = Math::PI * 2 / @money
  168.       a += d
  169.       $scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 1024).to_i,
  170.         (Math.sin(a) * 512).to_i, 4)
  171.     end
  172.     for i in 1..@bigmoney
  173.       d = Math::PI * 2 / @bigmoney
  174.       a += d
  175.       $scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 768).to_i,
  176.         (Math.sin(a) * 768).to_i, 5)
  177.     end
  178.     for i in 1..@bigpower
  179.       d = Math::PI * 2 / @bigpower
  180.       a += d
  181.       $scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 512).to_i,
  182.         (Math.sin(a) * 768).to_i, 6)
  183.     end
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● n方向ショット
  187.   #--------------------------------------------------------------------------
  188.   def nway_shot(n, space, angle, speed, aim, index, type)
  189.     d = angle
  190.     d += get_angle if aim
  191.            d = d - ( space * ( n - 1 ) / 2 )
  192.     for i in 0...n
  193.       $scene.add_ebullet(@sx2, @sy2, (Math.cos(d) * speed).to_i,
  194.         (Math.sin(d) * speed).to_i, index, type)
  195.       d += space
  196.     end
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 全方位ショット
  200.   #--------------------------------------------------------------------------
  201.   def nall_shot(n, angle, speed, aim, index, type)
  202.     a = angle
  203.     a += get_angle if aim
  204.     d = Math::PI * 2 / n
  205.     for i in 0...n
  206.       $scene.add_ebullet(@sx2, @sy2, (Math.cos(a) * speed).to_i,
  207.         (Math.sin(a) * speed).to_i, index, type)
  208.       a += d
  209.     end
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 行動処理(中身は継承先に)
  213.   #--------------------------------------------------------------------------
  214.   def action
  215.   end
  216. end


复制代码
  1. class TShoot_Enemy13 < TShoot_Enemy
  2.   def set_type
  3.     @hp = 2000
  4.     @file_name = "Boss1.png"
  5.     @file_index = 0
  6.     @vx = 0
  7.     @vy = 0
  8.     @boss = 1
  9.     @dir = 2
  10.     @damageable = 2
  11.     self.x = 23
  12.     self.y = 32
  13.     @sx2 = (x + 3) << 10
  14.     @sy2 = (y + 20) << 10
  15.     self.src_rect = Rect.new((@file_index % 4 * 3) * 45,
  16.     @file_index / 4 * 180 + ((@dir - 2) / 2) * 45,45,64)
  17.     @cnt_shot_reset = 180
  18.     @cnt_shot = 120
  19.   end
  20.   def update_anime
  21.     @anime = (@anime + 1) % 60
  22.     pattern = @anime / 15
  23.     pattern = pattern < 3 ? pattern : 0
  24.     self.src_rect.set((@file_index % 4 * 3 + pattern) * 45,
  25.       @file_index / 4 * 128 + ((@dir - 2) / 2) * 45, 45, 64)
  26.   end
  27.   def action
  28.     if @hp > 1750 and @hp < 2001
  29.       @damageable = 0
  30.       @dir = 4
  31.       @cnt_shot_reset = 300
  32.       chain_shot($difficulty / 2, $difficulty, 1024, 0, 12)
  33.       winder_shot(3,3072,5,1,5)
  34.       basic_move1
  35.       @hp = 1750 if $localtime >= 5000
  36.     elsif @hp == 1750
  37.       @dir = 2
  38.       @damageable = 2
  39.       @cnt_shot = 120
  40.       $scene.clear_bullet
  41.       @hp -= 1 if @cnt_shot == 0
  42.       $localtime = 5000
  43.     elsif @hp > 1450 and @hp < 1750
  44.       @dir = 4
  45.       @damageable = 0
  46.       @cnt_shot_reset = 240
  47.       if @cnt_shot %= (16 / $difficulty) == 0
  48.         for i in 0...13
  49.           $scene.add_ebullet(-32,32 + i * 32,1024,0,4,13)
  50.           $scene.add_ebullet(488,32 + i * 32,-1024,0,4,13)
  51.         end
  52.       end
  53.       basic_move1
  54.       winder_shot(2 + $difficulty,3072,0,1,4)
  55.       @hp = 1450 if $localtime >= 6200
  56.     elsif @hp == 1450
  57.       @dir = 2
  58.       @cnt_shot = 120
  59.       @damageable = 2
  60.       $scene.clear_bullet
  61.       @hp -= 1 if @cnt_shot == 0
  62.       $localtime = 6200
  63.     elsif @hp > 1150 and @hp < 1450
  64.       @dir = 4
  65.       @damageable = 0
  66.       @cnt_shot_reset = 240
  67.       for i in 0...13
  68.         $scene.add_ebullet(-32,32 + i * 32,1024,rand(768) - 384,8,13) if @cnt_shot %= (12 / $difficulty) == 0
  69.         $scene.add_ebullet(488,32 + i * 32,-1024,rand(768) - 384,8,13) if @cnt_shot %= (12 / $difficulty) == 0
  70.       end
  71.       basic_move1
  72.       machine_shot(2 * $difficulty, 1024 + 256 * $difficulty, rand(7), 1, 4)
  73.       @hp = 650 if $localtime >= 7600
  74.     elsif @hp == 1150
  75.       @dir = 2
  76.       @cnt_shot = 120
  77.       @damageable = 2
  78.       $scene.clear_bullet
  79.       @point = 4
  80.       @power = 2
  81.       set_item
  82.       @hp -= 1 if @cnt_shot == 0
  83.       if $localtime < 7600
  84.         $scene.add_popup(160,48,"Spell Bonus!!",Color.new(255,255,255),20)
  85.         $scene.add_popup(184,76,(4800 - $localtime) * 25 + 4000,Color.new(255,255,255),20)
  86.         $scene.add_score((7200 - $localtime) * 10 + 1000)
  87.         Audio.se_play("Audio/SE/Crash.wav", 80, 150)
  88.         $scene.add_effect(3,  @sx, @sy, 0, 0)
  89.         for i in 0...10 *  $game_variables[82]
  90.           $scene.add_effect(4,  @sx, @sy, 0, 0)
  91.         end
  92.       end
  93.       $localtime = 7600
  94.     elsif @hp > 900 and @hp < 1150
  95.       @dir = 4
  96.       @damageable = 0
  97.       @cnt_shot_reset = 120
  98.       nall_shot(8 + 8 * $difficulty, 0.0, 2048, false, 0, 12, 0) if @cnt_shot %= 60 == 0
  99.       if @cnt_shot %= 90 == 0
  100.         self.x = 48 + rand(392)
  101.         self.y = 32 + rand(192)
  102.       end
  103.       @hp = 500 if $localtime = 9400
  104.     elsif @hp == 900
  105.       @dir = 2
  106.       @cnt_shot = 120
  107.       @damageable = 2
  108.       $scene.clear_bullet
  109.       $localtime = 9400
  110.       @hp -= 1 if @cnt_shot == 0
  111.     elsif @hp > 550 and @hp < 900
  112.       @dir = 4
  113.       @damageable = 0
  114.       @cnt_shot_reset = 120
  115.       $scene.add_ebullet(32 + rand(456),32 + rand(224) + 32 * $difficulty,(rand(2) - 1) * 1024 + 512 * $difficulty,(rand(2) - 1) * 1024 + 512 * $difficulty,rand(7) + 1,13) if @cnt_shot_reset %= 4 == 0
  116.       winder_shot(2 + $difficulty,4096,2,2,6 / $difficulty)
  117.       @hp = 250 if $localtime >= 11000
  118.     elsif @hp == 550
  119.       @dir = 2
  120.       @cnt_shot = 120
  121.       @damageable = 2
  122.       $scene.clear_bullet
  123.       $localtime = 11000
  124.       @hp -= 1 if @cnt_shot == 0
  125.     elsif @hp < 550 and @hp > 0
  126.       @dir = 4
  127.       @damageable = 0
  128.       @cnt_shot_reset = 240
  129.       winder_shot(3 + $difficulty,2048 + 512 * $difficulty,0,1,3)
  130.       $scene.add_ebullet(32 + rand(456),32 + rand(224) + 32 * $difficulty,2048,0,rand(7) + 1,13) if @cnt_shot_reset %= 4 == 0
  131.       $scene.add_ebullet(32 + rand(456),32 + rand(224) + 32 * $difficulty,0,2048,rand(7) + 1,13) if @cnt_shot_reset %= 4 == 0
  132.     elsif @hp <= 0
  133.       @dir = 4
  134.       $scene.ground.erase_picture(5999)
  135.       $scene.ground.erase_picture(6000)
  136.       @point = 6
  137.       @power = 3
  138.       @money = 4
  139.       @bomb = 1
  140.       $scene.clear_bullet
  141.       $scene.add_effect(8, @sx, @sy,rand(2048) - 1024,rand(2048) - 1024)
  142.       for i in 0..16 * $game_variables[82]
  143.         $scene.add_effect(4, @sx, @sy,rand(2048) - 1024,rand(2048) - 1024)
  144.       end
  145.       $scene.back_ground.flash
  146.       set_item
  147.       if $localtime < 12500
  148.         $scene.add_popup(160,48,"Spell Bonus!!",Color.new(255,255,255),20)
  149.         $scene.add_popup(184,64,(12800 - $localtime) * 25 + 4000,Color.new(255,255,255),20)
  150.         $scene.add_score((12800 - $localtime) * 10 + 1200)
  151.         Audio.se_play("Audio/SE/Crash.wav", 80, 150)
  152.         for i in 0...10 *  $game_variables[82]
  153.           $scene.add_effect(4, @sx, @sy, 0, 0)
  154.         end
  155.       end
  156.       $localtime = 12500
  157.     else
  158.     end
  159.   end
  160. end
复制代码
但是在以下的图片中,夢子一直没动,只见分在狂涨...

Lv2.观梦者

虚構歪曲

梦石
0
星屑
339
在线时间
1197 小时
注册时间
2010-12-18
帖子
3928

贵宾

2
发表于 2012-1-22 22:38:10 | 只看该作者
看不懂。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
177 小时
注册时间
2011-7-3
帖子
235
3
 楼主| 发表于 2012-1-24 13:03:10 | 只看该作者
难道非得放出该场景的完整脚本吗...被人盗用了咋办...

$scene.add_ebullet 这个估计应该都看得出来,是创建子弹的图片.
basic_move1 是左右以随机速度移动一段距离后停下.
$localtime 是当前时间,以帧数为单位计算,图中应该5000多了.遇上set_stop命令会停下
$scene.clear_bullet 会清除全屏子弹,每个子弹+5分,画面中每1帧都在执行...所以分数就...

必要的说明应该都有了吧...就等所有可能的情况了...
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-21 05:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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