Win = [220,220,1]
Lose = [220,220,2]
AllClear = [220,220,3]
WinLoli = [220,220,4]
LoseLoli = [220,220,5]
Clear = [220,220,[0,0,6,6,7,7,7,8,8,8,9,9,9,10,10,10,10,10,10]]
SB = [(1..32).inject([]){|a,b|a<<[b,(b-28)**2/10]}.reverse,
(1..32).inject([]){|a,b|a<<[b,(b-32)**2/8+5]}.reverse,
(1..32).inject([]){|a,b|a<<[b,(b-30)**2/15-5]}.reverse,
(1..32).inject([]){|a,b|a<<[b,(b-32)**2/12+2]}.reverse,
(1..32).inject([]){|a,b|a<<[b,(b+2)**2/10]}.reverse,
(1..32).inject([]){|a,b|a<<[b,(b)**2/8+5]}.reverse,
(1..32).inject([]){|a,b|a<<[b,(b-1)**2/15-5]}.reverse,
(1..32).inject([]){|a,b|a<<[b,(b+2)**2/12+2]}.reverse,
] # 移动路径
#-------------------------------------------------------------------------- # ● 危机! #-------------------------------------------------------------------------- def crisis! return if@crisis == (@map.max <= Max) or @allclear_count > 0 @crisis = (@map.max <= Max) if @crisis loli_show 3 @bgp_sprite.bitmap = RPG::Cache.picture("背景底纹危急") else loli_show 4 @bgp_sprite.bitmap = RPG::Cache.picture("背景底纹一般") end end #-------------------------------------------------------------------------- # ● 眨眼刷新 #-------------------------------------------------------------------------- def update_eyes @eyes = 200 if @eyes == 0 @eyes -= 1 @loli_.bitmap = RPG::Cache.picture("绿之妖精眨眼") if @eyes == 10 @loli_.bitmap = RPG::Cache.picture("绿之妖精一般") if @eyes == 1 end #-------------------------------------------------------------------------- # ● 全消 #-------------------------------------------------------------------------- def allclear loli_show 0 animation = $data_animations[AllClear[2]] @amina[2].animation(animation, true) @allclear_count = 30 @crisis = nil end #-------------------------------------------------------------------------- # ● 刷新处理 #-------------------------------------------------------------------------- def update_p @pause_wnd.update if @pause_wnd.active # 窗口刷新 bgm_show # 显示BGM文字 update_eyes # 眨眼 @allclear_count -= 1 if @allclear_count > 0 crisis! if @allclear_count == 1 @amina.each{|i|i.update} loli_update return win if @score_tag <= @score if @pause_count # 暂停精灵刷新 @pause_count += 0.1 @pause_count %= 7 @pause_spt.bitmap.clear @pause_spt.bitmap.blt(0,0, @pause_cache, Rect.new(0,0,(6+@pause_count.to_i)*22,45)) end if Input.trigger?(Input::B) # B按下时 $game_system.se_play($data_system.cancel_se) Graphics.freeze if @pause_wnd.active # 关闭 @pause_wnd.visible = false @black.opacity = 0 @pause_count = nil @pause_spt.dispose;@pause_spt.bitmap.dispose;@pause_spt = nil @input_allow = true else # 生成 @pause_spt = Sprite.new;@pause_spt.bitmap = Bitmap.new(640,480) @pause_spt.x = 202;@pause_spt.y= 203 @pause_count = 1 @pause_spt.bitmap.blt(0,0, @pause_cache, Rect.new(0,0,(6+@pause_count)*22,45)) @pause_spt.z = 590 @pause_wnd.visible = true @black.opacity = 100 @input_allow = false end Graphics.transition(30) @pause_wnd.index = 0 return @pause_wnd.active = !@pause_wnd.active end if Input.trigger?(Input::C) and @pause_wnd.active# C按下时 $game_system.se_play($data_system.decision_se) case @pause_wnd.index when 0 # 恢复 Graphics.freeze @pause_wnd.visible = false @black.opacity = 0 @pause_count = nil @pause_spt.dispose;@pause_spt.bitmap.dispose;@pause_spt = nil Graphics.transition(30) @pause_wnd.index = 0 @input_allow = true return @pause_wnd.active = !@pause_wnd.active when 1 # 随机BGM play(@bgms[rand(@bgms.size)]) when 2 # 返回标题 $scene = Scene_Title.new @pause_spt.dispose;@pause_spt.bitmap.dispose;@pause_spt = nil end end end #-------------------------------------------------------------------------- # ● 按键处理 #-------------------------------------------------------------------------- def input_p @move = 0;@speed = false;@turn = 0 @move = 1 if Input.repeat?(Input::RIGHT) and !$game_system.se_play($data_system.cursor_se) @move =-1 if Input.repeat?(Input::LEFT) and !$game_system.se_play($data_system.cursor_se) @turn = 1 if Input.trigger?(Input::R)and !$game_system.se_play($data_system.cursor_se) @turn =-1 if Input.trigger?(Input::L)and !$game_system.se_play($data_system.cursor_se) @speed=true if Input.press?(Input::DOWN) end #-------------------------------------------------------------------------- # ● 精灵处理 #-------------------------------------------------------------------------- def sprite_p # 刷新puyo if @map.can_down?(@now_b) @now_b.move_down if @now_b.can_down? else if @now_b.can_down? and @now_b.can_turn? and @now_b.can_move? @map.register(@now_b) chain = 0;num=0 loop do until @map.update Graphics.update update_eyes end @map.update # 再运行一次以检 Graphics.update break if @map.can_next? # 无4组时 # 执行清空 chain += 1 # 连击 animation = $data_animations[Clear[2][chain]] @amina[-1].animation(animation, true) @map.sb! # 显示SB了 60.times{|i|@amina[-1].update;Graphics.update;update_eyes break if @map.sb_update Audio.se_play("Audio/SE/chain#{[chain,7].min}") if i == 10 show_chain chain if i == 32# 显示连击 } Graphics.update num = @map.remove # 消除 @score += num * 10 * (2 ** chain) # 加分 check_score # 更新分数 20.times{Graphics.update;update_eyes} end show_chain 0 # 消除显示连击 show_next return lose if @map.game_over? return allclear if @map.all_clear? crisis! end end @now_b.move(@move) if @move != 0 and @now_b.can_move? and @map.can_move?(@now_b,@move) @now_b.turn(@turn) if @turn != 0 and @now_b.can_turn? and @map.can_turn?(@now_b,@turn) @level.times{@now_b.update(@speed)} end #-------------------------------------------------------------------------- # ● BGM播放 #-------------------------------------------------------------------------- def play(bgm=@bgm) @bgm = bgm # 记录名称 Audio.bgm_play("Audio/BGM/#{@bgm}", 100, 100) @bgm_bmp.dispose if @bgm_bmp # 释放之前位图 rect = @black.bitmap.text_size(@bgm) # 获取文字宽度 @bgm_bmp = Bitmap.new(rect.width, rect.height) # 生成新位图 @bgm_bmp.draw_text(rect, @bgm) # 刻画文字 @show.bitmap.fill_rect(BGMRect, Color.new(0,0,0,0)) # 清空之前像素块 @show.bitmap.blt(BGMRect.x, BGMRect.y, @bgm_bmp, Rect.new(0,0,BGMRect.width,BGMRect.height)) # 复制像素块 @bgm_x = 0 end #-------------------------------------------------------------------------- # ● BGM显示 #-------------------------------------------------------------------------- def bgm_show return if !@bgm_bmp @show.bitmap.fill_rect(BGMRect, Color.new(0,0,0,0)) # 清空之前像素块 @bgm_x = [[@bgm_x+(@bgm_s ? 0.25 : -0.25),@bgm_bmp.width-BGMRect.width].min,0].max @bgm_s = !@bgm_s if @bgm_x == @bgm_bmp.width-BGMRect.width or @bgm_x == 0 @show.bitmap.blt(BGMRect.x, BGMRect.y, @bgm_bmp, Rect.new(@bgm_x,0,BGMRect.width,BGMRect.height)) # 复制像素块 end #-------------------------------------------------------------------------- # ● 显示连击 0即为消除 #-------------------------------------------------------------------------- def show_chain(chain) if chain > 0 show_chain 0 x = 0;bmp = RPG::Cache.picture("chain") chain.to_s.split("").each{|i|@show.bitmap.blt(Chain.x+x, Chain.y, bmp, Rect.new(i.to_i*20,0,20,42));x += 20} @show.bitmap.blt(Chain.x+x, Chain.y, bmp, Rect.new(200,0,90,42)) else @show.bitmap.fill_rect(Chain, Color.new(0,0,0,0)) end end end
@show.z = 105
Clear = [220,220,[0,0,6,6,7,7,7,8,8,8,9,9,9,10,10,10,10,10,10]]
#-------------------------------------------------------------------------- # ● 精灵处理 #-------------------------------------------------------------------------- def sprite_p # 刷新puyo if @map.can_down?(@now_b) @now_b.move_down if @now_b.can_down? else if @now_b.can_down? and @now_b.can_turn? and @now_b.can_move? @map.register(@now_b) chain = 0;num=0 loop do until @map.update Graphics.update update_eyes end @map.update # 再运行一次以检 Graphics.update break if @map.can_next? # 无4组时 # 执行清空 chain += 1 # 连击 @map.sb! # 显示SB了 60.times{|i|Graphics.update;update_eyes break if @map.sb_update Audio.se_play("Audio/SE/chain#{[chain,7].min}") if i == 10 show_chain chain if i == 32# 显示连击 } Graphics.update num = @map.remove # 消除 @score += num * 10 * (2 ** chain) # 加分 check_score # 更新分数 20.times{Graphics.update;update_eyes} end show_chain 0 # 消除显示连击 @amina[-1].animation($data_animations[Clear[2][chain]], true) show_next return lose if @map.game_over? return allclear if @map.all_clear? crisis! end end @now_b.move(@move) if @move != 0 and @now_b.can_move? and @map.can_move?(@now_b,@move) @now_b.turn(@turn) if @turn != 0 and @now_b.can_turn? and @map.can_turn?(@now_b,@turn) @level.times{@now_b.update(@speed)} end
精灵处理
@now_b.move_down if @now_b.can_down?
170.6 KB, 下载次数: 36
@score += num * 10 * (2 ** chain) # 加分
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |