#==============================================================================
# ■ 雷霆战机 代码作者:杨峰
#------------------------------------------------------------------------------
# 这个脚本前后花了我一个星期的时间去完成,完全是凭借自己的力量一行一行写的。
# 都大三了,平时还要上学校一堆烂课,伤不起啊!!
# 最后作品还算差强人意,就是由于素材原因飞机和子弹稍微大了点,判定也因此不
# 精准,不过不碍事。希望大家可以借此相互学习。多说一句,面向对象的设计思想
# 实在是太TM重要了!
#==============================================================================
class Scene_Plane
def main
@window_boss = Window_Boss.new
@window_show = Window_Show.new
@result = Window_Result.new
@fly_pattern = Fly_Pattern.new
@attack_pattern = Attack_Pattern.new
@bg = Plane.new
@bg.bitmap = RPG::Cache.picture("bg")
@me = My_Plane.new
@enemy_num = 0
@count = 0
@record = 0
@bomb_num = 3
@score = 0
[url=home.php?mod=space&uid=1208434]@destroy[/url] = 0
@score = 0
@destroy = 0
@speed = 0
@process = 0
@bg.zoom_x = 1.2
@bomb_ctrl = true
@judge_over = true
@victory = false
@level_switch = false
@power_switch = false
@bomb_switch = false
@food_switch = false
@my_blast_switch = false
@my_blast_hit_switch = false
@boss_switch = false
@bomb_blast_switch = []
@bomb_blast = []
@enemy_switch= []
@bullet_switch = []
@blast_switch = []
@blast_hit_switch = []
@blast = []
@blast_hit = []
@enemy = []
Audio.bgm_play("Audio/BGM/chuaiji")
for i in 0..100
@bomb_blast_switch = []
@enemy_switch[i] = false
@bullet_switch[i] = false
@blast_switch[i] = false
@blast_hit_switch[i] = false
end
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@bg.dispose
@result.dispose
@window_boss.dispose
@window_show.dispose
for i in 0..@enemy_num
if @enemy_switch[i]
@enemy[i].dispose
end
end
Audio.bgm_stop
end
def update
@bg.oy -= 5
@speed +=1
@process +=1
back_menu
shooting
pl_move
my_bullet_move
game_process
enemy_pattern
eat_items
bomb_blast
move_items
hit_you_me
enemy_animation
enemy_leave
me_animation
boss_info
my_death
end
def shooting
if Input.trigger?(Input::C) or Input.repeat?(Input::C)
@me.shotn_spread
end
end
def back_menu
if Input.trigger?(Input::F5)
$scene = Scene_Map.new
end
end
def boss_info
if @boss_switch
@window_boss.refresh(@enemy[70].hp)
if @enemy[70].mode_switch
@enemy[70].attack_mode
end
end
end
def my_death
if @me.hp <=0 and @judge_over
game_over
end
end
def hit_you_me
for i in 0..@enemy_num
if @enemy_switch[i]
hit_enemy(i)
end
hit_myself(i)
enemy_bullet_move(i)
end
end
def enemy_animation
for i in 0..@enemy_num
if @blast_switch[i]
@blast[i].animation
if @blast[i].control == -1
@blast[i].dispose
@enemy[i].dispose
@blast_switch[i] = false
end
end
end
for i in 0..@enemy_num
if @blast_hit_switch[i]
@blast_hit[i].animation
if @blast_hit[i].control == -1
@blast_hit[i].dispose
@blast_hit_switch[i] = false
end
end
end
end
def me_animation
if @my_blast_hit_switch
@my_blast_hit.animation
if @my_blast_hit.control == -1
@my_blast_hit.dispose
@my_blast_hit_switch = false
end
end
if @my_blast_switch
@my_blast.animation
if @my_blast.control == -1
@me.dispose
$scene = Scene_Gameover.new
end
end
end
def move_items
if @bomb_switch
@bomb.move
if @bomb.pic.y >= 600
@bomb.dispose
@bomb_switch = false
end
end
if @level_switch
@level.move
if @level.pic.y >= 600
@level.dispose
@level_switch = false
end
end
if @power_switch
@power.move
if @power.pic.y >= 600
@power.dispose
@power_switch = false
end
end
if @food_switch
@food.move
if @food.pic.y >= 600
@food.dispose
@food_switch = false
end
end
end
def bomb_blast
if Input.trigger?(Input::A)
if @bomb_num > 0 and @bomb_ctrl == true
Audio.se_play("Audio/SE/Explosion02")
@bomb_ctrl = false
@bomb_num -= 1
for i in 0..@enemy_num
if @enemy_switch[i]
@enemy[i].hp -= 10
end
end
for i in 0..5
@bomb_blast_switch[i] = true
case i
when 0..2
@bomb_blast[i] = Blast_Explosion2.new( i * 200,50)
when 3..5
@bomb_blast[i] = Blast_Explosion2.new( (i - 3) * 200,220)
end
end
end
end
for i in 0..5
if @bomb_blast_switch[i]
@bomb_blast[i].animation
if @bomb_blast[i].control == -1
@bomb_blast[i].dispose
@bomb_blast_switch[i] = false
@bomb_ctrl = true
end
end
end
end
def eat_items
if @bomb_switch
if @me.eat_bomb(@bomb.pic.x,@bomb.pic.y)
@bomb_num += 1
@bomb.dispose
@bomb_switch = false
end
end
if @level_switch
if @me.eat_level(@level.pic.x,@level.pic.y)
@level.dispose
@level_switch = false
if @me.level < 4
@me.level += 2
end
end
end
if @power_switch
if @me.eat_power(@power.pic.x,@power.pic.y)
@me.power += 1
@power.dispose
@power_switch = false
end
end
if @food_switch
if @me.eat_food(@food.pic.x,@food.pic.y)
@me.hp += 50
if @me.hp >=200
@me.hp = 200
end
@food.dispose
@food_switch = false
end
end
end
def enemy_leave
for i in 0..@enemy_num
if @enemy_switch[i]
if @enemy[i].pic.x < -100 or @enemy[i].pic.x > 700 or @enemy[i].pic.y > 500 or @enemy[i].pic.y < -150
@enemy[i].dispose
@enemy_switch[i] = false
end
end
end
end
def enemy_pattern
if @speed == 5
@result.refresh(@me.hp,@score,@destroy,@bomb_num)
for i in 0..@enemy_num
if @enemy_switch[i]
@fly_pattern.pattern(@enemy[i],i)
@attack_pattern.pattern(@me,i,@enemy[i])
end
end
@speed = 0
end
end
def game_process
if @process < 100
@window_show.refresh(0)
elsif @process == 100
@window_show.contents.clear
Audio.se_play("Audio/SE/start")
end
if @process <= 250 and @process >= 50 and @process % 50 == 0
@enemy[@enemy_num] = Enemy_Li.new(-80,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Li.new(640,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 500
@enemy[@enemy_num] = Enemy_Green.new(500,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 550
@enemy[@enemy_num] = Enemy_Green.new(400,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 600
@enemy[@enemy_num] = Enemy_Green.new(300,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Toon.new(-80,150)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Toon.new(640,150)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 650
@enemy[@enemy_num] = Enemy_Green.new(200,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 700
@enemy[@enemy_num] = Enemy_Green.new(100,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process <= 900 and @process >= 800 and @process % 100 == 0
@enemy[@enemy_num] = Enemy_Li.new(-80,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Li.new(640,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 920
@enemy[@enemy_num] = Enemy_Jit.new(100,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Jit.new(500,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 950
@enemy[@enemy_num] = Enemy_God.new(-80,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_God.new(640,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 1100
@enemy[@enemy_num] = Enemy_X.new(100,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_X.new(500,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process <= 1350 and @process >= 1250 and @process % 50 == 0
@enemy[@enemy_num] = Enemy_Green.new(-80,200)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Green.new(640,200)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process <= 1450 and @process >= 1400 and @process % 50 == 0
@enemy[@enemy_num] = Enemy_Li.new(-80,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Li.new(640,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 1600
@enemy[@enemy_num] = Enemy_Red.new(-80,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Red.new(640,100)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process <= 1750 and @process >= 1650 and @process % 50 == 0
@enemy[@enemy_num] = Enemy_Ye.new(-80,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Ye.new(640,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 1900
@enemy[@enemy_num] = Enemy_Jp.new(-80,50)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Jp.new(640,50)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 2000
@enemy[@enemy_num] = Enemy_Red.new(100,500)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Red.new(400,500)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process <= 2100 and @process >= 2000 and @process % 100 == 0
@enemy[@enemy_num] = Enemy_God.new(-80,150)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_God.new(640,250)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 2200
@enemy[@enemy_num] = Enemy_LX.new(250,-80)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process <= 2350 and @process >= 2250 and @process % 50 == 0
@enemy[@enemy_num] = Enemy_Green.new(-80,200)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Green.new(640,200)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process <= 2600 and @process >= 2500 and @process % 100 == 0
@enemy[@enemy_num] = Enemy_Li.new(-80,200)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Li.new(640,200)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process == 2700
@enemy[@enemy_num] = Enemy_LX.new(-80,50)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_LX.new(640,50)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process <= 2800 and @process >= 2750 and @process % 50 == 0
@enemy[@enemy_num] = Enemy_Toon.new(-80,250)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
@enemy[@enemy_num] = Enemy_Toon.new(640,250)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@enemy_num += 1
end
if @process < 3100 and @process>= 3000
@window_show.refresh(1)
elsif @process == 3100
@window_show.contents.clear
Audio.bgm_stop
Audio.se_play("Audio/SE/warning")
end
if @process == 3200
@enemy[@enemy_num] = Enemy_Boss.new(150,-120)
@enemy_switch[@enemy_num] = true
@bullet_switch[@enemy_num] = true
@boss_switch = true
@enemy_num += 1
Audio.bgm_play("Audio/BGM/action_world2")
end
if @victory and @record == 0
Audio.me_play("Audio/ME/victory")
@record = @process
end
if @victory
if @process != @record + 100
@window_show.refresh(2)
else
$scene = Scene_Map.new
end
end
end
def hit_myself(turn)
if @bullet_switch[turn]
for i in 0..@enemy[turn].bullet_num
if @enemy[turn].attack[i]
if(@me.hit(@enemy[turn].bullet[i].pic.x,@enemy[turn].bullet[i].pic.y,@enemy[turn].bullet[i].power))
if @me.hp > 0 and @my_blast_hit_switch == false
@my_blast_hit_switch = true
@my_blast_hit = Blast_Hit.new(@me.pic.x - 30 ,@me.pic.y - 30)
end
@enemy[turn].bullet[i].dispose
@enemy[turn].attack[i] = false
end
end
end
end
end
def game_over
Audio.se_play("Audio/SE/Explosion04")
@my_blast = Blast_Explosion.new(@me.pic.x - 25,@me.pic.y - 25)
@my_blast_switch = true
@judge_over = false
end
def hit_enemy(turn)
for i in [email]0..@me.bullet_num[/email]
if @me.attack[i]
if(@enemy[turn].hit(@me.bullet[i].pic.x,@me.bullet[i].pic.y,@me.power))
if @enemy[turn].hp > 0 and @blast_hit_switch[turn] == false
@blast_hit[turn] = Blast_Hit.new(@enemy[turn].pic.x- 20 ,@enemy[turn].pic.y)
@blast_hit_switch[turn] = true
end
@me.bullet[i].dispose
@me.attack[i] = false
end
end
end
if @enemy[turn].hp <= 0
@score += 10 * @enemy[turn].level
@destroy += 1
Audio.se_play("Audio/SE/Explosion01")
@blast[turn] = Blast_Explosion.new(@enemy[turn].pic.x - 30,@enemy[turn].pic.y)
@blast_switch[turn] = true
@enemy_switch[turn] = false
if turn == 4 or turn == 21 or turn == 53 or turn == 64
@bomb = Bomb.new(@enemy[turn].pic.x + 50,@enemy[turn].pic.y + 40)
@bomb_switch = true
end
if turn == 12 or turn == 34 or turn == 47 or turn == 65
@level = Level.new(@enemy[turn].pic.x + 50,@enemy[turn].pic.y + 40)
@level_switch = true
end
if turn == 33
@power = Power.new(@enemy[turn].pic.x + 50,@enemy[turn].pic.y + 40)
@power_switch = true
end
if turn == 30 or turn == 66
@food = Food.new(@enemy[turn].pic.x + 50,@enemy[turn].pic.y + 40)
@food_switch = true
end
if turn == 70
@victory = true
end
end
end
def enemy_bullet_move(turn)
if @bullet_switch[turn]
for i in 0..@enemy[turn].bullet_num
if @enemy[turn].attack[i]
if @enemy[turn].bullet[i].type == 0
@enemy[turn].bullet[i].down_fly
end
if @enemy[turn].bullet[i].type == 1
@enemy[turn].bullet[i].search_fly(1)
end
if @enemy[turn].bullet[i].type == 2
@enemy[turn].bullet[i].search_fly(1)
end
if @enemy[turn].bullet[i].pic.y >=500
@enemy[turn].attack[i]=false
@enemy[turn].bullet[i].dispose
end
end
end
end
end
def my_bullet_move
for i in @[email]count..@me.bullet_num[/email]
if @me.attack[i]
@me.bullet[i].search_fly(2)
if @me.bullet[i].pic.y <= -60
@me.attack[i]=false
@me.bullet[i].dispose
@count += 1
end
end
end
end
def pl_move
if Input.trigger?(Input::UP) or Input.repeat?(Input::UP)
if @me.pic.y>=0
@me.pic.y-=20
end
end
if Input.trigger?(Input::RIGHT) or Input.repeat?(Input::RIGHT)
if @me.pic.x<=520
@me.pic.x+=20
end
end
if Input.trigger?(Input::DOWN) or Input.repeat?(Input::DOWN)
if @me.pic.y <=380
@me.pic.y+=20
end
end
if Input.trigger?(Input::LEFT) or Input.repeat?(Input::LEFT)
if @me.pic.x>=0
@me.pic.x-=20
end
end
end
end
class My_Plane
attr_accessor :pic
attr_accessor :hp
attr_accessor :power
attr_accessor :level
attr_accessor :bullet
attr_accessor :bullet_num
attr_accessor :attack
def initialize
@hp = 200
@attack = false
@level = 0
@power = 1
@pic = Sprite.new
@pic.x = 300
@pic.y = 360
@pic.bitmap = RPG::Cache.picture("BluePlane")
@attack = []
@bullet = []
@bullet_num = 0
end
def eat_bomb(x,y)
if x <= @pic.x + 80 and x >= @pic.x + 20 and y <= @pic.y + 70 and y >= @pic.y
Audio.se_play("Audio/SE/eatbomb")
return true
else
return false
end
end
def eat_level(x,y)
if x <= @pic.x + 80 and x >= @pic.x + 20 and y <= @pic.y + 70 and y >= @pic.y
Audio.se_play("Audio/SE/eatlevel")
return true
else
return false
end
end
def eat_power(x,y)
if x <= @pic.x + 80 and x >= @pic.x + 20 and y <= @pic.y + 70 and y >= @pic.y
Audio.se_play("Audio/SE/eatpower")
return true
else
return false
end
end
def eat_food(x,y)
if x <= @pic.x + 80 and x >= @pic.x + 20 and y <= @pic.y + 70 and y >= @pic.y
Audio.se_play("Audio/SE/eatlevel")
return true
else
return false
end
end
def shotn_spread
for i in 0..@level
shot_spread(i)
end
end
def shot_spread(place)
Audio.se_play("Audio/SE/destroyer_lazer1")
@bullet[@bullet_num] = My_Bullet.new(@power)
angle = Math::PI * (place + 1) / (@level + 2)
x = Math.cos(angle)
y = Math.sin(angle)
if x == 0
@bullet[@bullet_num].ratiox = 0
@bullet[@bullet_num].ratio = 1
@bullet[@bullet_num].ratioy = -1
else
@bullet[@bullet_num].ratio = y / x
if @bullet[@bullet_num].ratio > 0
@bullet[@bullet_num].ratiox = -1
@bullet[@bullet_num].ratioy = -1
else
@bullet[@bullet_num].ratiox = 1
@bullet[@bullet_num].ratioy = 1
end
end
if @power == 1
@bullet[@bullet_num].pic.x = @pic.x - 40 * Math.cos(angle) + 30
@bullet[@bullet_num].pic.y = @pic.y + 40 * Math.sin(angle) - 30
elsif @power ==2
@bullet[@bullet_num].pic.x = @pic.x - 40 * Math.cos(angle)
@bullet[@bullet_num].pic.y = @pic.y + 40 * Math.sin(angle) - 60
end
@attack[@bullet_num] = true
@bullet_num += 1
end
def hit(x,y,power)
if x >= @pic.x and x <= @pic.x + 70 and y >= @pic.y and y <= @pic.y + 40
@hp -= power
Audio.se_play("Audio/SE/lazer_hit")
return true
end
return false
end
def dispose
@pic.dispose
end
end
class Enemy_Plane
attr_accessor :pic
attr_accessor :boss_suit
attr_accessor :width
attr_accessor :hp
attr_accessor :power
attr_accessor :level
attr_accessor :speed
attr_accessor :attack_type
attr_accessor :bullet
attr_accessor :bullet_size
attr_accessor :bullet_num
attr_accessor :attack
def initialize(x,y)
@pic = Sprite.new
@pic.x = x
@pic.y = y
@level = 1
@power = 1
@boss_suit = 0
@speed = 1
@bullet_size = 0
@attack_type = 0
@bullet_num = 0
@width = 128
@bullet = []
@attack = []
end
def shot_forward(place,num)
Audio.se_play("Audio/SE/117-Fire01")
@bullet[@bullet_num] = Enemy_Bullet.new(@power)
@bullet[@bullet_num].type = 0
if @power == 1
@bullet[@bullet_num].pic.x = @pic.x + (place + 1) * @width/ (num + 2) - 30 + @boss_suit
else
@bullet[@bullet_num].pic.x = @pic.x + (place + 1) * @width/ (num + 2) - 60+ @boss_suit
end
@bullet[@bullet_num].pic.y = @pic.y + @width / 3+ @boss_suit
@attack[@bullet_num] = true
@bullet_num += 1
end
def shotn(num)
for i in 0..num
shot_forward(i,num)
end
end
def shotn_me(plane,num)
for i in 0..num
shot_me(plane,i,num)
end
end
def shot_me(plane,place,num)
Audio.se_play("Audio/SE/117-Fire01")
@bullet[@bullet_num] = Enemy_Bullet.new(@power)
@bullet[@bullet_num].type = 1
x = (plane.pic.x - pic.x) *1.0
y = plane.pic.y - pic.y
if x == 0
@bullet[@bullet_num].ratiox = 0
if y >= 0
@bullet[@bullet_num].ratio = 1
else
@bullet[@bullet_num].ratio = -1
end
else
@bullet[@bullet_num].ratio = y / x
if @bullet[@bullet_num].ratio == 0
if x >= 0
@bullet[@bullet_num].ratiox = 1
else
@bullet[@bullet_num].ratiox = -1
end
else
if x > 0
@bullet[@bullet_num].ratiox = 1
else
@bullet[@bullet_num].ratiox = -1
@bullet[@bullet_num].ratioy = -1
end
end
end
if @power == 1
@bullet[@bullet_num].pic.x = @pic.x + (place + 1) * width/ (num + 2) - 30+ @boss_suit
elsif @power == 4
@bullet[@bullet_num].pic.x = @pic.x + (place + 1) * width/ (num + 2) - 60+ @boss_suit
else
@bullet[@bullet_num].pic.x = @pic.x + (place + 1) * width/ (num + 2) - 100+ @boss_suit
end
@bullet[@bullet_num].pic.y = @pic.y + 60+ @boss_suit
@attack[@bullet_num] = true
@bullet_num += 1
end
def shotn_spread(num)
for i in 0..num
shot_spread(i,num)
end
end
def shot_spread(place,num)
Audio.se_play("Audio/SE/117-Fire01")
@bullet[@bullet_num] = Enemy_Bullet.new(@power)
@bullet[@bullet_num].type = 2
angle = Math::PI * (place + 1) / (num + 2)
x = Math.cos(angle)
y = Math.sin(angle)
if x == 0
@bullet[@bullet_num].ratiox = 0
@bullet[@bullet_num].ratio = 1
else
@bullet[@bullet_num].ratio = y / x
if @bullet[@bullet_num].ratio > 0
@bullet[@bullet_num].ratiox = - 1
else
@bullet[@bullet_num].ratiox = 1
@bullet[@bullet_num].ratioy = -1
end
end
if @power == 1 or @power == 4
@bullet[@bullet_num].pic.x = @pic.x - 40 * Math.cos(angle) + 30+ @boss_suit
else
@bullet[@bullet_num].pic.x = @pic.x - 40 * Math.cos(angle) + @boss_suit
end
@bullet[@bullet_num].pic.y = @pic.y + 40 * Math.sin(angle) + 40+ @boss_suit
@attack[@bullet_num] = true
@bullet_num += 1
end
def hit(x,y,power)
if x >= @pic.x- 10 and x <= @pic.x + 80 and y >= @pic.y and y <= @pic.y + 40
@hp -= power
Audio.se_play("Audio/SE/lazer_hit")
return true
end
return false
end
def dispose
@pic.dispose
end
end
class Enemy_Li < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = -1
@bullet_size = 0
@speed = 2
@level= 1
@hp = 2
@pic.bitmap = RPG::Cache.picture("LiPlane")
end
end
class Enemy_Green < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 0
@bullet_size = 0
@speed = 2
@power = 1
@level= 2
@hp = 2
@pic.bitmap = RPG::Cache.picture("GreenPlane")
end
end
class Enemy_God < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 1
@bullet_size = 0
@level = 4
@power = 1
@speed = 2
@hp = 5
@pic.bitmap = RPG::Cache.picture("GodPlane")
end
end
class Enemy_X < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 1
@bullet_size = 2
@level = 6
@power = 1
@speed = 1
@hp = 10
@pic.bitmap = RPG::Cache.picture("XPlane")
end
end
class Enemy_Jit < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 0
@bullet_size = 1
@power = 2
@level = 5
@speed = 1
@hp = 15
@pic.bitmap = RPG::Cache.picture("JitPlane")
end
end
class Enemy_Jp < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 2
@bullet_size = 3
@level = 6
@speed = 1
@power = 3
@hp = 15
@pic.bitmap = RPG::Cache.picture("JpPlane")
end
end
class Enemy_LX < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 1
@bullet_size = 4
@level = 10
@power = 4
@speed = 1
@hp = 30
@pic.bitmap = RPG::Cache.picture("LXPlane")
end
end
class Enemy_Red < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 2
@bullet_size = 1
@level = 5
@power = 3
@speed = 1
@hp = 20
@pic.bitmap = RPG::Cache.picture("RedPlane")
end
end
class Enemy_Toon < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 1
@bullet_size = 0
@level = 3
@power = 1
@speed = 2
@hp = 2
@pic.bitmap = RPG::Cache.picture("ToonPlane")
end
end
class Enemy_Ye < Enemy_Plane
def initialize(x,y)
super(x,y)
@attack_type = 0
@bullet_size = 1
@power = 1
@level = 6
@speed = 2.5
@hp = 5
@pic.bitmap = RPG::Cache.picture("YePlane")
end
end
class Enemy_Boss < Enemy_Plane
attr_accessor :mode_switch
def initialize(x,y)
super(x,y)
@mode_switch = false
@attack_type = 1
@boss_suit = 50
@bullet_size = 5
@power = 3
@level = 100
@width = 240
@speed = 1
@hp = 1000
@pic.bitmap = RPG::Cache.picture("boss")
end
def attack_mode
@attack_type = rand(3)
mode_switch = false
case @attack_type
when 0
@power = 4
@bullet_size = 6
when 1
@power = 3
@bullet_size = 5
when 2
@power = 2
@bullet_size = 10
end
end
def hit(x,y,power)
if x >= @pic.x - 40 and x <= @pic.x + 280 and y >= @pic.y and y <= @pic.y + 140
@hp -= power
Audio.se_play("Audio/SE/lazer_hit")
return true
end
return false
end
end
class Blast
attr_accessor :pic
attr_accessor :control
attr_accessor :speed
def initialize(x,y)
@control = 0
@speed =0
@pic = Sprite.new
@pic.x = x
@pic.y = y
@pic.bitmap = Bitmap.new(192,192)
end
def dispose
@pic.dispose
end
end
class Blast_Explosion < Blast
def initialize(x,y)
super(x,y)
end
def animation
if @speed == 5
if @control ==2 or @control == 4 or @control == 5
@pic.bitmap.dispose
@pic.bitmap = Bitmap.new(192,192)
end
if @control <= 4
@pic.bitmap.blt(0,0,RPG::Cache.picture("Explosion01"),Rect.new(192*@control,0,192,192))
@control +=1
elsif @control > 4 and @control <= 5
@pic.bitmap.blt(0,0,RPG::Cache.picture("Explosion01"),Rect.new(192*(@control - 4),192,192,192))
@control +=1
else
@control = -1
end
@speed = 0
end
@speed += 1
end
end
class Blast_Explosion2 < Blast
def initialize(x,y)
super(x,y)
end
def animation
if @speed == 5
if @control == 2 or @control == 4 or @control == 6 or @control == 9
@pic.bitmap.dispose
@pic.bitmap = Bitmap.new(192,192)
end
if @control <= 4
@pic.bitmap.blt(0,0,RPG::Cache.picture("Explosion02"),Rect.new(192*@control,0,192,192))
@control +=1
elsif @control > 4 and @control <= 9
@pic.bitmap.blt(0,0,RPG::Cache.picture("Explosion02"),Rect.new(192*(@control - 4),192,192,192))
@control +=1
else
@control = -1
end
@speed = 0
end
@speed += 1
end
end
class Blast_Hit < Blast
def initialize(x,y)
super(x,y)
end
def animation
if @speed == 2
if @control ==2 or @control == 4 or @control == 6 or @control == 9
@pic.bitmap.dispose
@pic.bitmap = Bitmap.new(192,192)
end
if @control <= 4
@pic.bitmap.blt(0,0,RPG::Cache.picture("011-Weapon06"),Rect.new(192*@control,0,192,192))
@control +=1
elsif @control > 4 and @control <= 9
@pic.bitmap.blt(0,0,RPG::Cache.picture("011-Weapon06"),Rect.new(192*(@control - 4),192,192,192))
@control +=1
else
@control = -1
end
@speed = 0
end
@speed += 1
end
end
class Fly_Pattern
attr_accessor :control
attr_accessor :direction
def initialize
@control = []
@direction = 1
for i in 0..100
@control[i] = 0
end
end
def pattern(plane,turn)
case turn
when 21
pattern_0(plane,turn)
when 22
pattern_1(plane,turn)
when 10,11,12,15,16,25,26,53
pattern_2(plane)
when 47,48
pattern_3(plane)
when 0,2,4,6,8,13,17,19,23,27,29,31,33,35,37,49,51,54,56,58,60,62,66,68
pattern_4(plane)
when 1,3,5,7,9,14,18,20,24,28,30,32,34,36,38,50,52,55,57,59,61,63,67,69
pattern_5(plane)
when 39,41,43
pattern_6(plane)
when 40,42,44
pattern_7(plane)
when 45,64
pattern_8(plane,turn)
when 46,65
pattern_9(plane,turn)
when 70
pattern_boss(plane,turn)
else
pattern_0(plane,turn)
end
end
def pattern_0(plane,turn)
@control[turn] += 1
if @control[turn]< 40
plane.pic.y += 5*plane.speed
end
if @control[turn]>= 40 and @control[turn] <= 100
plane.pic.x += 5*plane.speed
end
if @control[turn] > 100
plane.pic.y -= 5*plane.speed
end
end
def pattern_1(plane,turn)
@control[turn] += 1
if @control[turn]< 40
plane.pic.y += 5*plane.speed
end
if @control[turn]>= 40 and @control[turn] <= 100
plane.pic.x -= 5*plane.speed
end
if @control[turn] > 100
plane.pic.y -= 5*plane.speed
end
end
def pattern_2(plane)
plane.pic.y +=5*plane.speed
end
def pattern_3(plane)
plane.pic.y -=5*plane.speed
end
def pattern_4(plane)
plane.pic.x +=5*plane.speed
end
def pattern_5(plane)
plane.pic.x -= 5*plane.speed
end
def pattern_6(plane)
plane.pic.x += 4*plane.speed
plane.pic.y += 4*plane.speed
end
def pattern_7(plane)
plane.pic.x -= 4*plane.speed
plane.pic.y += 4*plane.speed
end
def pattern_8(plane,turn)
@control[turn] += 1
if @control[turn] <= 60
plane.pic.x += 4 *plane.speed
end
if @control[turn] <= 100 and @control[turn] > 60
plane.pic.y += 3*plane.speed
end
if @control[turn] <=160 and @control[turn] >100
plane.pic.x -= 4*plane.speed
end
if @control[turn] <=200 and @control[turn] >160
plane.pic.y += 3*plane.speed
end
if @control[turn] >200
plane.pic.x += 4 * plane.speed
end
end
def pattern_9(plane,turn)
@control[turn] += 1
if @control[turn] <= 60
plane.pic.x -= 4 *plane.speed
end
if @control[turn] <= 100 and @control[turn] > 60
plane.pic.y += 3*plane.speed
end
if @control[turn] <=160 and @control[turn] >100
plane.pic.x += 4 * plane.speed
end
if @control[turn] <=200 and @control[turn] >160
plane.pic.y += 3*plane.speed
end
if @control[turn] >200
plane.pic.x -= 4 * plane.speed
end
end
def pattern_boss(plane,turn)
@control[turn] += 1
if @control[turn] <= 30
plane.pic.y += 5 *plane.speed
end
if @control[turn] > 30 and @control[turn] <= 60
plane.pic.x -= 5 * plane.speed
end
if @control[turn] > 60
plane.pic.x += 5 *plane.speed * @direction
if (@control[turn] - 120) % 60 == 0
@direction = - @direction
end
end
end
end
class Attack_Pattern
attr_accessor :control
def initialize
@control = []
for i in 0..100
@control[i] = 0
end
end
def pattern(me,turn,plane)
case plane.attack_type
when 0
forward(turn,plane)
when 1
search(me,turn,plane)
when 2
spread(turn,plane)
end
end
def forward(turn,plane)
case turn
when 10,11,12,15,16
forward_1(turn,plane)
when 21,22
forward_2(turn,plane)
when 39,40,41,42,43,44
forward_3(turn,plane)
when 70
forward_boss(turn,plane)
else
forward_1(turn,plane)
end
end
def forward_1(turn,plane)
@control[turn] += 1
if @control[turn] % 10 == 0
plane.shotn(plane.bullet_size)
end
end
def forward_2(turn,plane)
@control[turn] += 1
if @control[turn] % 15 == 0
plane.shotn(plane.bullet_size)
end
if @control[turn] % 15 == 1
plane.shotn(plane.bullet_size)
end
if @control[turn] % 15 == 2
plane.shotn(plane.bullet_size)
end
end
def forward_3(turn,plane)
@control[turn] += 1
if @control[turn] % 15 == 0
plane.shotn(plane.bullet_size)
end
if @control[turn] % 15 == 1
plane.shotn(plane.bullet_size)
end
end
def forward_boss(turn,plane)
@control[turn] += 1
if @control[turn] % 15 == 0
plane.shotn(plane.bullet_size)
end
if @control[turn] % 15 == 3
plane.shotn(plane.bullet_size)
end
if @control[turn] == 60
@control[turn] == 0
plane.mode_switch = true
end
end
def search(me,turn,plane)
case turn
when 13,14,66,67,68,69
search_1(me,turn,plane)
when 23,24,25,26,49,50,51,52
search_2(me,turn,plane)
when 53,64,65
search_3(me,turn,plane)
when 70
search_boss(me,turn,plane)
else
search_1(me,turn,plane)
end
end
def search_1(me,turn,plane)
@control[turn] += 1
if @control[turn] % 10 == 0
plane.shotn_me(me,plane.bullet_size)
end
end
def search_2(me,turn,plane)
@control[turn] += 1
if @control[turn] % 15 == 0
plane.shotn_me(me,plane.bullet_size)
end
if @control[turn] % 15 == 1
plane.shotn_me(me,plane.bullet_size)
end
if @control[turn] % 15 == 2
plane.shotn_me(me,plane.bullet_size)
end
end
def search_3(me,turn,plane)
@control[turn] += 1
if @control[turn] % 15 == 0
plane.shotn_me(me,plane.bullet_size)
end
if @control[turn] % 15 == 3
plane.shotn_me(me,plane.bullet_size - 1)
end
end
def search_boss(me,turn,plane)
@control[turn] += 1
if @control[turn] % 10 == 0
plane.shotn_me(me,plane.bullet_size)
end
if @control[turn] % 10 == 1
plane.shotn_me(me,plane.bullet_size)
end
if @control[turn] % 10 == 2
plane.shotn_me(me,plane.bullet_size)
end
if @control[turn] == 30
@control[turn] == 0
plane.mode_switch = true
end
end
def spread(turn,plane)
case turn
when 45,46
spread_1(turn,plane)
when 37,38,47,48
spread_2(turn,plane)
when 70
spread_boss(turn,plane)
else
spread_1(turn,plane)
end
end
def spread_1(turn,plane)
@control[turn] += 1
if @control[turn] % 15 == 0
plane.shotn_spread(plane.bullet_size)
end
if @control[turn] % 15 == 1
plane.shotn_spread(plane.bullet_size - 1)
end
if @control[turn] % 15 == 2
plane.shotn_spread(plane.bullet_size)
end
if @control[turn] % 15 == 3
plane.shotn_spread(plane.bullet_size - 1)
end
end
def spread_2(turn,plane)
@control[turn] += 1
if @control[turn] % 10 == 0
plane.shotn_spread(plane.bullet_size)
end
end
def spread_boss(turn,plane)
@control[turn] += 1
if @control[turn] % 15 == 0
plane.shotn_spread(plane.bullet_size)
end
if @control[turn] % 15 == 2
plane.shotn_spread(plane.bullet_size - 1)
end
if @control[turn] % 15 == 4
plane.shotn_spread(plane.bullet_size)
end
if @control[turn] % 15 == 6
plane.shotn_spread(plane.bullet_size - 1)
end
if control[turn] == 60
@control[turn] == 0
plane.mode_switch = true
end
end
end
class Bullet
attr_accessor :pic
attr_accessor :power
attr_accessor :type
attr_accessor :ratio
attr_accessor :ratiox
attr_accessor :ratioy
def initialize(x)
@ratio = 1
@power = 1
@ratiox = 0
@ratioy = 1
@type = 0
@pic = Sprite.new
end
def down_fly
@pic.y += 10
end
def up_fly
@pic.y -= 20
end
def search_fly(speed)
@pic.x += 10 *speed * @ratiox / Math.hypot(@ratio, 1)
@pic.y += 10 *speed * @ratio *@ratioy / Math.hypot(@ratio, 1)
end
def dispose
@pic.dispose
end
end
class My_Bullet < Bullet
def initialize(x)
super(x)
if x == 1
@pic.bitmap = RPG::Cache.picture("bullet_1")
elsif x == 2
@pic.bitmap = RPG::Cache.picture("bullet_2")
end
end
end
class Enemy_Bullet < Bullet
def initialize(x)
super(x)
if x == 1
@power = 1
@pic.bitmap = Bitmap.new(64,64)
@pic.bitmap.blt(0,0,RPG::Cache.picture("EnemyFire_03"),Rect.new(0,0,64,64))
elsif x == 2
@power = 2
@pic.bitmap = Bitmap.new(128,128)
@pic.bitmap.blt(0,0,RPG::Cache.picture("EnemyFire_01"),Rect.new(256,0,128,128))
elsif x == 3
@power = 3
@pic.bitmap = Bitmap.new(128,128)
@pic.bitmap.blt(0,0,RPG::Cache.picture("EnemyFire_02"),Rect.new(256,0,128,128))
elsif x == 4
@power = 4
@pic.bitmap = Bitmap.new(128,128)
@pic.bitmap.blt(0,0,RPG::Cache.picture("bullet_3"),Rect.new(0,0,128,128))
end
end
end
class Items
attr_accessor :pic
def initialize(x,y)
@pic = Sprite.new
@pic.x = x
@pic.y = y
end
def move
@pic.y += 1
end
def dispose
@pic.dispose
end
end
class Bomb < Items
attr_accessor :pic
def initialize(x,y)
super(x,y)
@pic.bitmap = RPG::Cache.picture("bomb")
end
end
class Level < Items
attr_accessor :pic
def initialize(x,y)
super(x,y)
@pic.bitmap = RPG::Cache.picture("level")
end
end
class Power < Items
attr_accessor :pic
def initialize(x,y)
super(x,y)
@pic.bitmap = RPG::Cache.picture("power")
end
end
class Food < Items
attr_accessor :pic
def initialize(x,y)
super(x,y)
@pic.bitmap = RPG::Cache.picture("food")
end
end
class Window_Result < Window_Base
def initialize
super(20, 400, 500, 100)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = ["方正粗活意简体","方正粗活意简体"]
self.opacity = 0
end
def refresh(hp,score,destroy,bomb)
self.contents.clear
self.contents.font.size = 22
self.contents.font.color = Color.new(255,20,20)
self.contents.font.bold = false
self.contents.draw_text(0,20,64,32,"生命:")
self.contents.draw_text(240,20,64,32,"分数:#{score}")
self.contents.draw_text(320,20,64,32,"灭敌数:#{destroy}")
self.contents.draw_text(400,20,64,32,"炸弹数:#{bomb}")
if hp >= 70
self.contents.fill_rect(55, 27, hp * 0.8, 20,Color.new(84,121,241))
elsif hp >= 40
self.contents.fill_rect(55, 27, hp * 0.8, 20,Color.new(240,200,64))
else
self.contents.fill_rect(55, 27, hp * 0.8, 20,Color.new(231,81,81))
end
end
end
class Window_Show < Window_Base
def initialize
super(230, 140, 300, 300)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = ["方正粗活意简体","方正粗活意简体"]
self.opacity = 0
end
def refresh(turn)
self.contents.clear
self.contents.font.size = 80
self.contents.font.color = Color.new(255,80,20)
self.contents.font.bold = false
case turn
when 0
self.contents.draw_text(0,0,150,150,"开始")
when 1
self.contents.draw_text(0,0,150,150,"警告")
when 2
self.contents.draw_text(0,0,150,150,"胜利")
end
end
end
class Window_Boss < Window_Base
def initialize
super(20, 0, 500, 100)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = ["方正粗活意简体","方正粗活意简体"]
self.opacity = 0
end
def refresh(hp)
self.contents.clear
self.contents.font.size = 22
self.contents.font.color = Color.new(255,20,20)
self.contents.font.bold = false
self.contents.draw_text(0,20,64,32,"Boss:")
if hp >= 230
self.contents.fill_rect(55, 27, 0.4* hp ,20,Color.new(73,188,46))
elsif hp >= 200
self.contents.fill_rect(55, 27, 0.4* hp,20,Color.new(240,200,64))
else
self.contents.fill_rect(55, 27, 0.4* hp ,20,Color.new(231,81,81))
end
end
end