Project1
标题:
为什么我的夢子不动了...
[打印本页]
作者:
TheRebirth
时间:
2012-1-22 22:23
标题:
为什么我的夢子不动了...
在class中已使用如下脚本:
条件分歧,HP不同时动作不同...
#==============================================================================
# ■ TShoot_Enemy
#------------------------------------------------------------------------------
# シューティングの敵機クラス
#==============================================================================
class TShoot_Enemy < Sprite
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :sx
attr_reader :sy
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, shot, move)
super(nil)
self.x = 16
self.y = 16
self.z = 100
@sx = x << 10
@sy = y << 10
@sx2 = x << 10
@sy2 = y << 10
@vx = 0
@vy = 0
@shot = shot # ショットオプション値
@move = move # 移動オプション値
@cnt_move = 0 # 移動用タイマー
@cnt_shot = 0 # ショット用タイマー
@cnt_shot_reset = 180 # ショットのループ間隔
@angle_shot = 0.0
@anime = 0 # アニメタイマー
@dir = 2 # 向き
@hp = 5
@hp2 = @hp
@score = 0 # 所持しているスコアアイテム数
@power = 0 # 同パワーアイテム数
@life = 0 # 同ライフアイテム数
@bomb = 0 # 同ボムアイテム数
@bigpower = 0
@money = 0
@bigmoney = 0
@damageable = 0
@boss = 0
set_type
self.bitmap = Cache.character(@file_name)
self.src_rect = Rect.new(@file_index % 4 * 96 + 32,
@file_index / 4 * 128 + ((@dir - 2) / 2) * 32,32,32)
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def update
if @hp <= 0
Audio.se_play("Audio/SE/Killed.wav", 80, 150)
set_item
$scene.add_effect(3, self.x, self.y, 0, 0)
$scene.clear_bullet if @boss == 1
for i in 0...4 * $game_variables[82]
$scene.add_effect(4,self.x,self.y,rand(2048) - 1024,rand(2048) - 1024)
end
dispose
return
end
action
@sx += @vx
@sy += @vy
@sx2 += @vx
@sy2 += @vy
self.x = (@sx >> 10)
self.y = (@sy >> 10)
if $scene.player.y - 26 > self.y - 18 and $scene.player.y - 26 < self.y - 14
if $scene.player.x - 21 > self.x - 18 and $scene.player.x - 21 < self.x - 14
$scene.player.damage
end
end
update_anime
if self.x < -68 or self.x > 588 or self.y < -68 or self.y > 520
dispose
end
end
#--------------------------------------------------------------------------
# ● 更新(アニメーション)
#--------------------------------------------------------------------------
def update_anime
@anime = (@anime + 1) % 60
pattern = @anime / 15
pattern = pattern < 3 ? pattern : 0
self.src_rect.set((@file_index % 4 * 3 + pattern) * 32,
@file_index / 4 * 128 + ((@dir - 2) / 2) * 32, 32, 32)
end
#--------------------------------------------------------------------------
# ● 下を向く
#--------------------------------------------------------------------------
def turn_down
@dir = 2
end
#--------------------------------------------------------------------------
# ● 左を向く
#--------------------------------------------------------------------------
def turn_right
@dir = 4
end
#--------------------------------------------------------------------------
# ● 右を向く
#--------------------------------------------------------------------------
def turn_left
@dir = 6
end
#--------------------------------------------------------------------------
# ● 上を向く
#--------------------------------------------------------------------------
def turn_up
@dir = 8
end
#--------------------------------------------------------------------------
# ● ダメージ
#--------------------------------------------------------------------------
def damage
@hp -= $scene.player.damagevalue
@hp -= $scene.player.damagevalue * 2 if $doubledamagetime > 0
$scene.se_flag[1] = true
$scene.info.add_score(50)
$scene.info.add_mana(1)
end
def damageable?
@damageable < 1
end
#--------------------------------------------------------------------------
# ● 自機のいる角度を取得
#--------------------------------------------------------------------------
def get_angle
return $scene.player.get_angle(@sx, @sy)
end
#--------------------------------------------------------------------------
# ● アイテムセット
#--------------------------------------------------------------------------
def set_item
n = @score + @power + @life + @bomb + @money + @bigmoney + @bigpower
return if n == 0
a = -Math::PI / 2
for i in 1..@score
d = Math::PI * 2 / @score
a += d
$scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 1024).to_i,
(Math.sin(a) * 768).to_i, 0)
end
for i in 1..@power
d = Math::PI * 2 / @power
a += d
$scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 768).to_i,
(Math.sin(a) * 512).to_i, 1)
end
for i in 1..@life
d = Math::PI * 2 / @life
a += d
$scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 256).to_i,
(Math.sin(a) * 1024).to_i, 2)
end
for i in 1..@bomb
d = Math::PI * 2 / @bomb
a += d
$scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 256).to_i,
(Math.sin(a) * 1024).to_i, 3)
end
for i in 1..@money
d = Math::PI * 2 / @money
a += d
$scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 1024).to_i,
(Math.sin(a) * 512).to_i, 4)
end
for i in 1..@bigmoney
d = Math::PI * 2 / @bigmoney
a += d
$scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 768).to_i,
(Math.sin(a) * 768).to_i, 5)
end
for i in 1..@bigpower
d = Math::PI * 2 / @bigpower
a += d
$scene.add_item((@sx >> 10) + 8, self.y + 8, (Math.cos(a) * 512).to_i,
(Math.sin(a) * 768).to_i, 6)
end
end
#--------------------------------------------------------------------------
# ● n方向ショット
#--------------------------------------------------------------------------
def nway_shot(n, space, angle, speed, aim, index, type)
d = angle
d += get_angle if aim
d = d - ( space * ( n - 1 ) / 2 )
for i in 0...n
$scene.add_ebullet(@sx2, @sy2, (Math.cos(d) * speed).to_i,
(Math.sin(d) * speed).to_i, index, type)
d += space
end
end
#--------------------------------------------------------------------------
# ● 全方位ショット
#--------------------------------------------------------------------------
def nall_shot(n, angle, speed, aim, index, type)
a = angle
a += get_angle if aim
d = Math::PI * 2 / n
for i in 0...n
$scene.add_ebullet(@sx2, @sy2, (Math.cos(a) * speed).to_i,
(Math.sin(a) * speed).to_i, index, type)
a += d
end
end
#--------------------------------------------------------------------------
# ● 行動処理(中身は継承先に)
#--------------------------------------------------------------------------
def action
end
end
复制代码
class TShoot_Enemy13 < TShoot_Enemy
def set_type
@hp = 2000
@file_name = "Boss1.png"
@file_index = 0
@vx = 0
@vy = 0
@boss = 1
@dir = 2
@damageable = 2
self.x = 23
self.y = 32
@sx2 = (x + 3) << 10
@sy2 = (y + 20) << 10
self.src_rect = Rect.new((@file_index % 4 * 3) * 45,
@file_index / 4 * 180 + ((@dir - 2) / 2) * 45,45,64)
@cnt_shot_reset = 180
@cnt_shot = 120
end
def update_anime
@anime = (@anime + 1) % 60
pattern = @anime / 15
pattern = pattern < 3 ? pattern : 0
self.src_rect.set((@file_index % 4 * 3 + pattern) * 45,
@file_index / 4 * 128 + ((@dir - 2) / 2) * 45, 45, 64)
end
def action
if @hp > 1750 and @hp < 2001
@damageable = 0
@dir = 4
@cnt_shot_reset = 300
chain_shot($difficulty / 2, $difficulty, 1024, 0, 12)
winder_shot(3,3072,5,1,5)
basic_move1
@hp = 1750 if $localtime >= 5000
elsif @hp == 1750
@dir = 2
@damageable = 2
@cnt_shot = 120
$scene.clear_bullet
@hp -= 1 if @cnt_shot == 0
$localtime = 5000
elsif @hp > 1450 and @hp < 1750
@dir = 4
@damageable = 0
@cnt_shot_reset = 240
if @cnt_shot %= (16 / $difficulty) == 0
for i in 0...13
$scene.add_ebullet(-32,32 + i * 32,1024,0,4,13)
$scene.add_ebullet(488,32 + i * 32,-1024,0,4,13)
end
end
basic_move1
winder_shot(2 + $difficulty,3072,0,1,4)
@hp = 1450 if $localtime >= 6200
elsif @hp == 1450
@dir = 2
@cnt_shot = 120
@damageable = 2
$scene.clear_bullet
@hp -= 1 if @cnt_shot == 0
$localtime = 6200
elsif @hp > 1150 and @hp < 1450
@dir = 4
@damageable = 0
@cnt_shot_reset = 240
for i in 0...13
$scene.add_ebullet(-32,32 + i * 32,1024,rand(768) - 384,8,13) if @cnt_shot %= (12 / $difficulty) == 0
$scene.add_ebullet(488,32 + i * 32,-1024,rand(768) - 384,8,13) if @cnt_shot %= (12 / $difficulty) == 0
end
basic_move1
machine_shot(2 * $difficulty, 1024 + 256 * $difficulty, rand(7), 1, 4)
@hp = 650 if $localtime >= 7600
elsif @hp == 1150
@dir = 2
@cnt_shot = 120
@damageable = 2
$scene.clear_bullet
@point = 4
@power = 2
set_item
@hp -= 1 if @cnt_shot == 0
if $localtime < 7600
$scene.add_popup(160,48,"Spell Bonus!!",Color.new(255,255,255),20)
$scene.add_popup(184,76,(4800 - $localtime) * 25 + 4000,Color.new(255,255,255),20)
$scene.add_score((7200 - $localtime) * 10 + 1000)
Audio.se_play("Audio/SE/Crash.wav", 80, 150)
$scene.add_effect(3, @sx, @sy, 0, 0)
for i in 0...10 * $game_variables[82]
$scene.add_effect(4, @sx, @sy, 0, 0)
end
end
$localtime = 7600
elsif @hp > 900 and @hp < 1150
@dir = 4
@damageable = 0
@cnt_shot_reset = 120
nall_shot(8 + 8 * $difficulty, 0.0, 2048, false, 0, 12, 0) if @cnt_shot %= 60 == 0
if @cnt_shot %= 90 == 0
self.x = 48 + rand(392)
self.y = 32 + rand(192)
end
@hp = 500 if $localtime = 9400
elsif @hp == 900
@dir = 2
@cnt_shot = 120
@damageable = 2
$scene.clear_bullet
$localtime = 9400
@hp -= 1 if @cnt_shot == 0
elsif @hp > 550 and @hp < 900
@dir = 4
@damageable = 0
@cnt_shot_reset = 120
$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
winder_shot(2 + $difficulty,4096,2,2,6 / $difficulty)
@hp = 250 if $localtime >= 11000
elsif @hp == 550
@dir = 2
@cnt_shot = 120
@damageable = 2
$scene.clear_bullet
$localtime = 11000
@hp -= 1 if @cnt_shot == 0
elsif @hp < 550 and @hp > 0
@dir = 4
@damageable = 0
@cnt_shot_reset = 240
winder_shot(3 + $difficulty,2048 + 512 * $difficulty,0,1,3)
$scene.add_ebullet(32 + rand(456),32 + rand(224) + 32 * $difficulty,2048,0,rand(7) + 1,13) if @cnt_shot_reset %= 4 == 0
$scene.add_ebullet(32 + rand(456),32 + rand(224) + 32 * $difficulty,0,2048,rand(7) + 1,13) if @cnt_shot_reset %= 4 == 0
elsif @hp <= 0
@dir = 4
$scene.ground.erase_picture(5999)
$scene.ground.erase_picture(6000)
@point = 6
@power = 3
@money = 4
@bomb = 1
$scene.clear_bullet
$scene.add_effect(8, @sx, @sy,rand(2048) - 1024,rand(2048) - 1024)
for i in 0..16 * $game_variables[82]
$scene.add_effect(4, @sx, @sy,rand(2048) - 1024,rand(2048) - 1024)
end
$scene.back_ground.flash
set_item
if $localtime < 12500
$scene.add_popup(160,48,"Spell Bonus!!",Color.new(255,255,255),20)
$scene.add_popup(184,64,(12800 - $localtime) * 25 + 4000,Color.new(255,255,255),20)
$scene.add_score((12800 - $localtime) * 10 + 1200)
Audio.se_play("Audio/SE/Crash.wav", 80, 150)
for i in 0...10 * $game_variables[82]
$scene.add_effect(4, @sx, @sy, 0, 0)
end
end
$localtime = 12500
else
end
end
end
复制代码
但是在以下的图片中,夢子一直没动,只见分在狂涨...
Cache1.PNG
(430.42 KB, 下载次数: 14)
下载附件
保存到相册
2012-1-22 22:20 上传
dsu_plus_rewardpost_czw
作者:
忧雪の伤
时间:
2012-1-22 22:38
看不懂。
作者:
TheRebirth
时间:
2012-1-24 13:03
难道非得放出该场景的完整脚本吗...被人盗用了咋办...
$scene.add_ebullet 这个估计应该都看得出来,是创建子弹的图片.
basic_move1 是左右以随机速度移动一段距离后停下.
$localtime 是当前时间,以帧数为单位计算,图中应该5000多了.遇上set_stop命令会停下
$scene.clear_bullet 会清除全屏子弹,每个子弹+5分,画面中每1帧都在执行...
所以分数就...
必要的说明应该都有了吧...就等所有可能的情况了...
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1