Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Game
- attr_accessor :entities,:scx,:scy,:map,:player,:powerup,:time,:area,:came,:messages,:save,:gameover,:way,:unstoppable
- attr_reader :temp
- def initialize(session=nil)
- $game=self
- @temp=[]
- @time=0
- $bossrush=false
- if session==true
- place=$save[:session][1][:id]
- pos=$save[:session][0]
- qs=false
- @came=$save[:session][0]
- if !$save[:session][2]
- $save[:session]=nil
- Marshal.dump($save,f=File.open("data/save#{$save[:id]}",'w'))
- f.close
- $save=Marshal.load(f=File.open("data/save#{$save[:id]}s",'r'))
- f.close
- File.delete("data/save#{$save[:id]}s")
- else
- qs=true
- $save=Marshal.load(f=File.open("data/save#{$save[:id]}s",'r'))
- f.close
- end
- reset(place)
- (@player=Mario.new(*pos)).init(:solid)
- @player.model.mirror_x=true if @player.x>@map.data[:width]*320
- @entities[0].find{|ent| ent.class==QuickSave}.tp if qs
- elsif session
- $bossrush=["r1",false,0,nil,session==2 ? 0 : nil]
- $save[:dimension]=$bossrush[4]
- reset('r1')
- (@player=Mario.new(320,392)).init(:solid)
- elsif $save[:saved]
- reset('s')
- (@player=Mario.new(320,392)).init(:solid)
- @map.data[:id]=$save[:saved][1][:id]
- @map.data[:origin]=$save[:saved][1][:origin]
- $save[:saved][0].init
- @player.model.mirror_x=true if $save[:saved][0].x==0
- 2.times{|x| 4.times{|y| $game[Tile.new(($save[:saved][0].x==0 ? 576 : 0)+x*32,192+y*32,'Castle',(x==0 ? 0 : 2)+[0,7,7,14][y])]}}
- Save.new
- if $save[:session] and !$save[:session][2]
- $save[:session]=nil
- File.delete("data/save#{$save[:id]}s")
- end
- Marshal.dump($save,f=File.open("data/save#{$save[:id]}",'w'))
- f.close
- else
- reset('i1')
- (@player=Mario.new(416,320)).init(:solid)
- end
- @scx=[[@player.x-320,0].max,@map.data[:width]*640-640].min.to_i
- @scy=[[@player.y-240,0].max,@map.data[:height]*480-480].min.to_i
- if !$bossrush
- @map.music($save[:area]) if !['s','t','c','i1'].include?(@map.data[:id])
- else
- Msc["Item Room"].play(true)
- end
- @messages=[]
- @removed=[]
- refresh_stats
- end
- def update
- return @way.way if @way
- if @gameover
- @gameover+=1
- if @gameover<36
- return
- elsif @gameover==36
- @player.remove
- Corpse.new(@player.x-16,@player.y-40,@player.vx,@player.vy)
- elsif @gameover==180
- return $game=GameOver.new
- end
- end
- @level=nil if @level and (@level-=3)<0
- @powerup=nil if @powerup and (@powerup[1]-=3)<0
- @area=nil if @area and (@area[1]-=1)<-120
- @save=nil if @save and (@save+=1)==120
- return if @level or @powerup or @area or !@messages.empty? && @messages.find{|mess| mess.guide}
- @time+=1 if !@stoptime
- $save[:time]+=1
- @entities[0].each {|ent| ent.update if ent.respond_to?(:update) and !ent.stop and not @stoptime && !ent.unstoppable and !@start} if !$bossrush || $bossrush[1]
- @removed.each{|ent| @entities.each{|grp| grp.delete(ent)}}
- @removed.clear
- @stoptime.resume if @stoptime and @stoptime.paused?
- if Keypress[:start,false] and !@gameover
- @stoptime.pause if @stoptime
- Snd['Sys5'].play
- $temp=self
- return $game=Menu.new
- end
- if Keypress[:select,false] and !@gameover
- Snd['Sys5'].play
- $temp=self
- return $game=Minimap.new(@map.data[:origin],@player.x,@player.y)
- end
- if ($save[:exp]-$save[:all])>=$save[:next]
- Snd['Level Up'].play
- lv=$save[:level]+=1
- $save[:all]+=$save[:next]
- $save[:next]=10*lv**2-5*lv+(75-(lv-1))
- $save[:max_hp]+=12
- $save[:hp]+=12
- $save[:max_mp]+=8
- $save[:mp]+=8
- $save[:max_stars]+=4
- $save[:stars]+=4
- $save[:base_strength]+=(1+(lv%3==0 ? 1 : 0)+(lv%5==3 ? 1 : 0)+(lv%8==7 ? 1 : 0))
- $save[:base_constitution]+=(1+(lv%3==1 ? 1 : 0)+(lv%5==4 ? 1 : 0)+(lv%8==4 ? 1 : 0))
- $save[:base_intelligence]+=(1+(lv%3==0 ? 1 : 0)+(lv%5==2 ? 1 : 0)+(lv%8==6 ? 1 : 0))
- $save[:base_mind]+=(1+(lv%3==2 ? 1 : 0)+(lv%5==1 ? 1 : 0)+(lv%8==3 ? 1 : 0))
- $save[:base_luck]+=1
- refresh_stats
- @level=400
- end
- magic=nil
- $save[:magic].length.times{|mag| next if !$save[:magic][mag]
- sp=$save[:magic][mag][0]
- $save[:magic][mag][1].times{|i| sp-=$items[:magic][mag][:levels][i]}
- if $save[:magic][mag][1]<$items[:magic][mag][:levels].length and sp>=$items[:magic][mag][:levels][$save[:magic][mag][1]] ; magic=mag ; break end}
- if magic
- $save[:magic][magic][1]+=1
- Snd['Level Up'].play
- Info.new($game.player.x-((cnd=($save[:magic][magic][1]==$items[:magic][magic][:levels].length)) ? 28 : 21),$game.player.y-48,nil,cnd ? Tls['System/Master',56,16] : Tls['System/Magic Up',42,32])
- @player.set_att(magic)
- end
- @map.update
- screen
- if $save[:hp]<=0 and !@gameover
- @stoptime.stop if @stoptime
- Msc['Fail'].play
- @gameover=0
- @shake=nil
- end
- if @shop
- @shop=nil
- $temp=self
- $game=Shop.new
- end
- if @stoptime and !@stoptime.playing?
- Song.current_song.play(!$premusic) if Song.current_song
- @stoptime=nil
- end
- 4.times{|i| if !$save[:plans][i] and $save[:items][:misc].include?(i)
- $save[:plans][i]=true
- map=Marshal.load(f=File.open("data/plan#{i}",'r'))
- f.close
- map.each{|plan| $save[:map].find{|room| room.x/10==plan[0] and room.y/10==plan[1]}.map!}
- end}
- $save[:kills][0]||=0;$save[:kills][35]||=0;$save[:kills][36]||=0
- if $save[:magic][6]
- value=($save[:kills][0] ? $save[:kills][0] : 0)+($save[:kills][35] ? $save[:kills][35] : 0)+($save[:kills][36] ? $save[:kills][36] : 0)+($save[:kills][86] ? $save[:kills][86] : 0)+($save[:kills][101] ? $save[:kills][101] : 0)*1000
- $items[:magic][6][:attack]=value/($save[:magic][6][1]==1 ? 1 : 2)
- $items[:magic][6][:use]=[30+value,$save[:max_mp]].min/($save[:magic][6][1]==1 ? 2 : 1)
- end
- $items[:pants][6][:defence]=$save[:coins]/250
- $items[:boots][7][:stomp]=$save[:allkills]/100
- $items[:accessory][10][:luck]=$save[:time]/54000
- refresh_stats
- if $bossrush
- if !$bossrush[1]
- @entities[0].each{|ent| ent.remove if ent.class==Waypoint}
- case $bossrush[0]
- when "r1"
- Waypoint.new(640-32,0,false,$bossrush[4] ? "b" : 7)
- when "b"
- @player.y=480-96-24
- Waypoint.new(0,0,false,$bossrush[4]<12 ? "b" : "r2")
- Waypoint.new(608,0,false,$bossrush[4]<12 ? "b" : "r2")
- when 7
- @player.y=480-64-24
- Waypoint.new(640-32,0,false,38)
- when 38
- @player.y=480-96-24
- Waypoint.new(640-32,0,false,77)
- when 77
- @player.y=480-160-24
- Waypoint.new(0,0,false,107)
- when 107
- @player.y=480-192-24
- Waypoint.new(1280-32,480,false,190)
- when 190
- @player.y=480-64-24
- Waypoint.new(0,0,false,159)
- when 159
- @player.y=960-32-24
- Waypoint.new(1280-32,480,false,182)
- when 182
- @player.y=480-128-24
- Waypoint.new(640-32,0,false,223)
- when 223
- @player.y=480-64-24
- Waypoint.new(1280-32,0,false,252)
- when 252
- @player.y=480-160-24
- Waypoint.new(0,0,false,136)
- when 136
- @player.y=480-160-24
- Waypoint.new(0,0,false,207)
- when 207
- @player.y=480-160-24
- Waypoint.new(0,0,false,243)
- when 243
- @player.y=384-24
- Waypoint.new(1280-32,0,false,249)
- when 249
- @player.x=1279
- @player.y=480-64-24
- @player.vx=-2
- Waypoint.new(1280-32,0,false,"r2")
- when "r2"
- @player.x=256
- @player.y=480-64-24
- Msc["Item Room"].play(true)
- if !$bossrush[4]
- if $bossrush[2]<28800 and not $save[:items][:weapon].include?(16) or $save[:equip][2]==16
- type=:weapon
- id=16
- $config[4][5]=true
- elsif $bossrush[2]<43200 and not $save[:items][:magic].include?(12) or $save[:equip][1]==12
- type=:magic
- id=12
- $config[4][4]=true
- elsif $bossrush[2]<57600 and not $save[:items][:boots].include?(11) or $save[:equip][5]==11
- type=:boots
- id=11
- $config[4][3]=true
- else
- type=:usable
- id=12
- end
- else
- if $bossrush[2]<21600 and not $save[:items][:suit].include?(12) or $save[:equip][0]==12
- type=:suit
- id=12
- $config[4][6]=true
- else
- type=:usable
- id=5
- end
- end
- @_item=Item.new(480,288,type,id)
- end
- $bossrush[1]=true
- end
- if $bossrush[0]=="r2" and !@_gotomenu and !@entities[0].find{|e| e.class==Item}
- save=Marshal.load(f=File.open("data/save#{$save[:id]}",'r'))
- f.close
- save[:items][@_item.type] << @_item.id
- Marshal.dump(save,f=File.open("data/save#{$save[:id]}",'w'))
- f.close
- $config[$bossrush[4] ? 3 : 2]<<[$save[:name],$bossrush[2]]
- f=File.open('data/config','w')
- Marshal.dump($config,f)
- f.close
- @_gotomenu=true
- end
- if @_gotomenu and !@item
- $game=MainMenu.new
- end
- @entities[1].each{|ent| ent.nodrop=:br}
- if $bossrush[3]
- Song.current_song.stop
- $premusic=nil
- $bossrush[3]=false
- case $bossrush[0]
- when 7,38,159,182,223,243
- @entities[0].find{|ent| ent.class==BossDoor and ent.x>0}.open=true
- when 77,190,252,136,207
- @entities[0].find{|ent| ent.class==BossDoor and ent.x==0}.open=true
- when 107
- @entities[0].find{|ent| ent.class==BossDoor and ent.x>0 and ent.y>480}.open=true
- end
- end
- $bossrush[2]+=1 if $bossrush[0] != "r2"
- end
- return ###DEBUGGGG
- if Keypress[KbF8,false]
- QuickSave.new(@player.x,@player.y-128)
- end
- if Keypress[KbF2]
- map=$save[:map]
- $save[:map]=Marshal.load(f=File.open('data/map','r'))
- map.each{|r| if r.discovered then $save[:map].find{|ro| ro.dimension==r.dimension and ro.x==r.x and ro.y==r.y}.discover end}
- $save[:plans].clear
- end
- $items.each_key{|type| $items[type].length.times{|id| $save[:items][type] << id if !$save[:items][type].include?(id)}} if Keypress[KbF1,false]
- $save[:exp]+=100000 if Keypress[KbF4,false]
- $save[:luck]=$save[:defence]=$save[:mind]=$save[:strength]=$save[:intelligence]=$save[:stomp]=$save[:constitution]=$save[:hp]=$save[:mp]=$save[:stars]=999999999999 if Keypress[KbF6]
- $save[:intelligence]=999999999999 if Keypress[KbF7]
- $game=End.new(true) if Keypress[KbF10,false]
- $game=MainMenu.new if Keypress[KbF12,false]
- if Keypress[KbF9,false]
- Msc['World Revolution',true].play
- # pl.x=640
- # pl.y-=32
- # pl.ignore=true
- $game.reset('f')
- MegaBowser.new
- end
- if Keypress[KbF11]
- begin
- eval gets.chomp
- rescue
- puts "Fail"
- end
- end
- end
- def draw
- @map.init
- return if @way
- if @player.starman
- color=rand(3)
- color2=rand(4)
- $shaders[4].Red=(color==0 or color2==0)
- $shaders[4].Green=(color==1 or color2==1)
- $shaders[4].Blue=(color==2 or color2==2)
- end
- if @shake
- @shake[4]+=1
- if @shake[4]==@shake[1]
- @shake[4]=0
- @shake[2]-=1
- @shake[0]-=@shake[3][:damping] if @shake[3][:damping]
- @shakex=-@shake[0]+rand(@shake[0]*2+1)
- @shakey=-@shake[0]+rand(@shake[0]*2+1)
- end
- @scx+=@shakex
- @scy+=@shakey
- $screen.draw_quad(@shakex-@scx,0,c=0xff000000,-@scx,0,c,@shakex-@scx,$screen.height,c,-@scx,$screen.height,c,3.5) if @shakex<0
- $screen.draw_quad(@map.data[:width]*640-@scx,0,c=0xff000000,@map.data[:width]*640-@scx+@shakex,0,c,@map.data[:width]*640-@scx+@shakex,$screen.height,c,@map.data[:width]*640-@scx,$screen.height,c,3.5) if @shakex>0
- $screen.draw_quad(0,@shakey-@scy,c=0xff000000,$screen.width,@shakey-@scy,c,$screen.width,-@scy,c,0,-@scy,c,3.5) if @shakey<0
- $screen.draw_quad(0,@map.data[:height]*480-@scy,c=0xff000000,0,@map.data[:height]*480-@scy+@shakey,c,$screen.width,@map.data[:height]*480-@scy+@shakey,c,$screen.width,@map.data[:height]*480-@scy,c,3.5) if @shakey>0
- @shake=@shakex=@shakey=nil if @shake[2]==0
- end
- if @flash
- alpha=(@flash[0].alpha+(@flash[2] ? @flash[1] : -@flash[1]))
- if @flash[2] and alpha>255
- @flash[2]=nil
- @flash[0].alpha=255
- elsif !@flash[2] and alpha<0
- @flash=nil
- end
- @flash[0].alpha=alpha if @flash
- $screen.draw_quad(0,0,@flash[0],$screen.width,0,@flash[0],$screen.width,$screen.height,@flash[0],0,$screen.height,@flash[0],3) if @flash
- end
- @map.draw
- $screen.translate(-@scx,-@scy) do
- @entities[0].each {|ent| ent.draw if ent.respond_to?(:draw) and !ent.invisible}
- end
- if @makelife
- 16.times{|dir| Img['Effects/Make Life'].draw(@makelife[0]-offset_x(dir*22.5,-@makelife[1]*4%64)-@scx,128-offset_y(dir*22.5,-@makelife[1]*4%64)-@scy,3)}
- @makelife[1]+=1
- if @makelife[1]==64
- Bonus.new(@makelife[0],128,0,true)
- @makelife=nil
- end
- end
- Fnt['data/fonts/nine.ttf',100].draw_rel(@warning[0],320,240,4,0.5,0.5,1,1,0xffff0000) if @warning and $count%10<5
- @warning=nil if @warning and (@warning[1]-=1)==0
- if @messages.empty? and !@player.ignore
- width=[$save[:max_hp]/4,$save[:max_mp]/2].max
- Img['System/BarFrame',true].draw(58,0,4,width)
- Tls['System/Bars',1,8,true][0].draw(58,4,4,(([$save[:hp],0].max/$save[:max_hp].to_f)*width).to_i)
- Tls['System/Bars',1,8,true][1].draw(58,40,4,(($save[:mp]/$save[:max_mp].to_f)*width).to_i)
- Img['System/Stars'].draw(0,0,4)
- Img['System/BarEdge'].draw(58+width,0,4)
- Img['System/Exp',true].draw(1,52,4,((($save[:exp]-$save[:all])/$save[:next].to_f)*100).to_i)
- Fnt[['System/Font',20,20]].draw($save[:stars],41,39,4,:scalex=>0.5,:scaley=>0.5,:align=>:right)
- Fnt[['System/Font',20,20]].draw([$save[:hp],0].max,59,15,4,:scalex=>0.5,:scaley=>0.5)
- if @boss
- Tls['System/Bars',1,8,true][2].draw(16,456,4,(@boss[0].hp.to_f/@boss[1])*608)
- end
- end
- if @enemy and (@enemy[1]-=1)>0
- Tls['System/EnemyLabel',20,24][2].draw(620,456,4)
- (@enemy[0].name.length-1).times{|x| Tls['System/EnemyLabel',20,24][1].draw(600-x*20,456,4)}
- Tls['System/EnemyLabel',20,24][0].draw(620-@enemy[0].name.length*20,456,4)
- Fnt[['System/Font',20,20]].draw(@enemy[0].name,636,460,4,:align=>:right,:scaley=>0.8)
- elsif @enemy and missing(@enemy[0])
- @enemy=nil
- end
- if @item and (@item[1]-=1)>0
- Tls['System/ItemLabel',20,24][0].draw(0,456,4)
- (@item[0].length-1).times{|x| Tls['System/ItemLabel',20,24][1].draw(20+x*20,456,4)}
- Tls['System/ItemLabel',20,24][2].draw(@item[0].length*20,456,4)
- Fnt[['System/Font',20,20]].draw(@item[0],4,460,4,:scaley=>0.8)
- elsif @item
- @item=nil
- end
- Img['System/Level Up'].draw_rot(320,240-[120-@level,0].max,4,0,0.5,0.5,[(@level-120)*0.5,1].max,[(@level-120)*0.1,1].max,Color.new([255-(300-@level*3),0].max,255,255,255)) if @level
- Tls['System/Power Up',398,54][@powerup[0]].draw_rot(320,240-[120-@powerup[1]*2,0].max,4,0,0.5,0.5,[(@powerup[1]-120)*0.5,1].max,[200-@powerup[1],100].min*0.01,Color.new([255-(300-@powerup[1]*3),0].max,255,255,255)) if @powerup
- if @area
- @area[0].length.times{|x| Fnt[['System/Font',20,20]].draw(@area[0][x],310-@area[0].length*10+x*20,230+offset_y(@area[1]*4+x*40,(@area[1]/16.0)**2),4,:color=>Color.new([255-@area[1].abs*2,0].max,255,255,255))}
- end
- if @save
- text='Game Saved'
- text.length.times{|x| Fnt[['System/Font',20,20]].draw(text[x],120+x*40,480-offset_x(@save*3-x*20,80),4,:scalex=>2,:scaley=>2)}
- end
- events(@map.data[:id])
- @messages[0].draw if !@messages.empty?
- if $bossrush
- txt=[]
- txt << "#{'0' if (t=($bossrush[2]/3600%60).to_i)<10}#{t}"
- txt << "#{'0' if (t=($bossrush[2]/60%60).to_i)<10}#{t}"
- txt << "#{'0' if ($bossrush[2]/0.6)%100<10}#{(($bossrush[2]/0.6)%100).to_i}"
- Fnt[['System/Font',20,20]].draw(txt.join(':'),@map.data[:id]=="r2" ? 320 : 120,460,4,:scaley=>0.8)
- end
- end
- def screen
- @scx=[[@player.x-320,0].max,@map.data[:width]*640-640].min.to_i
- @scy=[[@player.y-240,0].max,@map.data[:height]*480-480].min.to_i
- end
- def button_down(id)
- end
- def solid?(x,y,down=nil)
- @map.solid?(x.to_i,y.to_i,down) or @entities[3].find{|ent| ent.check(x,y,down)}
- end
- def reset(room)
- @start=true
- @temp.clear
- @entities=[[]] ; 5.times{@entities<<[]}
- @player.init if @player
- @map=Map.new(room)
- if $bossrush
- $bossrush[1]=false
- $bossrush[0]=@map.data[:id]
- end
- end
- def missing(obj)
- !@entities[0].include?(obj)
- end
- def remove(ent)
- @removed << ent
- end
- def stomp(x,y,pound)
- return if @player.starman
- $game.entities[1].each{|ent| ent.stomp(x,y,pound)}
- $game.entities[5].each{|ent| ent.stomp(x,y,pound)}
- end
- def pow(x,y,width,pound)
- return if @player.starman
- found=nil
- $game.entities[1].each{|ent| found=true if ent.pow(x,y,width,pound)}
- $game.entities[2].each{|ent| found=true if ent.pow(x,y,width,pound)}
- found
- end
- def kill(x,y,sizex,sizey,attack,element,id,inv=nil)
- damaged=nil
- $game.entities[1].each{|ent| damaged=true if ent.kill(x,y,sizex,sizey,attack,element,id,inv)}
- $game.entities[4].each{|ent| damaged=true if ent.kill(x,y,sizex,sizey,attack,element,id)}
- damaged
- end
- def refresh_stats(change=nil,item=nil)
- equip=$save[:equip].dup
- equip[change]=item if change
- $save[:stomp]=$save[:defence]=0
- $save[:strength]=$save[:base_strength]
- $save[:constitution]=$save[:base_constitution]
- $save[:intelligence]=$save[:base_intelligence]
- $save[:mind]=$save[:base_mind]
- $save[:luck]=$save[:base_luck]
- $save[:intelligence]=$save[:base_intelligence]
- $save[:mp_regen]=$save[:base_mp_regen]
- items=[:suit,:magic,:weapon,:cap,:pants,:boots,:accessory,:accessory]
- 8.times{|i|
- $save[:resistance][i]=nil if !equip[i]
- next if !equip[i]
- item=$items[items[i]][equip[i]]
- $save[:strength]+=item[:strength] if item[:strength]
- $save[:constitution]+=item[:constitution] if item[:constitution]
- $save[:intelligence]+=item[:intelligence] if item[:intelligence]
- $save[:mind]+=item[:mind] if item[:mind]
- $save[:luck]+=item[:luck] if item[:luck]
- $save[:mp_regen]+=item[:mp_regen] if item[:mp_regen]
- $save[:stomp]+=item[:stomp] if item[:stomp]
- $save[:defence]+=item[:defence] if item[:defence]
- $save[:resistance][i]=item[:resist]
- }
- $save[:intelligence]=($save[:intelligence]*=1.5).round if equip[3]==3
- $save[:mind]=($save[:mind]*1.1).round if equip[3]==6
- $save[:defence]/=8 if equip[0]==8
- if equip[3]==7 && equip[4]==8 && equip[5]==8
- $save[:intelligence]+=50
- $save[:mind]+=50
- $save[:constitution]+=50
- $save[:strength]+=30
- $save[:luck]+=15
- $save[:mp_regen]+=5
- end
- if equip[6]==4 && equip[7]==15 or equip[7]==4 && equip[6]==15
- $save[:constitution]*=2
- $save[:strength]*=2
- $save[:mp_regen]+=1
- end
- if equip[0]==12 and $save[:dimension]
- $save[:strength]*=3
- $save[:constitution]*=3
- $save[:intelligence]*=3
- $save[:mind]*=3
- $save[:luck]*=3
- $save[:mp_regen]*=3
- end
- $save[:stomp]+=$save[:strength]
- $save[:defence]+=$save[:constitution]/2
- $save[:stomp]+=$save[:defence] if equip[5]==6
- $save[:defence]=0 if equip[5]==6
- $save[:intelligence]=$save[:mind]=$save[:constitution]=$save[:strength]=$save[:luck]=$save[:stomp]=$save[:defence]=$save[:mp_regen]=60 if equip[4]==9
- $save[:items][:suit].uniq!
- $save[:items][:magic].uniq!
- $save[:items][:weapon].uniq!
- end
- def enemy=(value)
- @enemy=[value,180] if !@enemy or value != @enemy[0]
- end
- def item=(value)
- @item=[value,180]
- end
- def [](entity)
- @entities[0] << entity
- end
- def shop!
- @shop=true
- end
- def stop_time(sound)
- if @unstoppable
- sound.stop
- Snd["Timenostop"].play
- return
- end
- @stoptime=sound
- Song.current_song.pause if Song.current_song
- end
- def stopped;@stoptime;end
- def flash(color,speed,starting=nil)
- @flash=[color.class==Color ? color : Color.new(color),speed,starting]
- end
- def flashing
- return if !@flash
- @flash[0].alpha
- end
- def shake(max,time,num,args={})
- @shake=[max,time,num,args,0]
- @shakex=-@shake[0]+rand(@shake[0]*2+1)
- @shakey=-@shake[0]+rand(@shake[0]*2+1)
- end
- def warning(mess)
- @warning=[mess,60]
- end
- def make_life
- if $bossrush
- $bossrush[3]=true
- return
- end
- Snd['Makelife'].play
- @makelife=[@map.data[:width]*640/2-16,0]
- end
- def boss(boss)
- @boss=[boss,boss.hp]
- end
- end
- class Menu
- def initialize
- @state=:main
- @select=0
- @max=5
- @pos=0
- @enemies=[]
- $enemies.each_index{|enemy| @enemies[enemy]=true if $save[:enemies][enemy] and $save[:enemies][enemy].count(true)>=$enemies[enemy][:drop].length}
- @magic=[]
- $save[:magic].length.times{|magic| @magic[magic]=($save[:magic][magic] and $save[:magic][magic][1]==$items[:magic][magic][:levels].length)}
- @unsaveable=(['s','c','t','!','b'].include?($temp.map.data[:id]) or $bossrush)
- end
- def update
- if Keypress[:start,false] or @state==:main && Keypress[:shoot,false]
- Snd['Sys3'].play
- $game=$temp
- $temp=nil
- end
- (@select+=1;Snd['Sys1'].play) if @select<@max and Keypress[:down,false] and @state != :enemy
- (@select-=1;Snd['Sys1'].play) if @select>0 and Keypress[:up,false] and @state != :enemy
- case @state
- when :main
- if Keypress[:jump,false]
- case @select
- when 0
- @state=:equip
- @max=7
- when 1
- return Snd['Sys4'].play if ($save[:items][:usable]+$save[:items][:misc]).empty?
- @state=:useitem
- $save[:items][:usable].sort!
- @pos=0
- when 2
- @state=:relics
- @max=$relics.length-1
- when 3
- @state=:guides
- @max=$guides.length-1
- when 4
- @state=:enemies
- @max=$enemies.length-1
- when 5
- return Snd['Sys4'].play if @unsaveable
- save=Marshal.load(f=File.open("data/save#{$save[:id]}",'r'))
- f.close
- save[:session]=[$temp.came,$temp.map.data]
- save[:session][2]=nil
- Marshal.dump(save,f=File.open("data/save#{$save[:id]}",'w'))
- f.close
- Marshal.dump($save,f=File.open("data/save#{$save[:id]}s",'w'))
- f.close
- $game=MainMenu.new
- Snd['Sys5'].play
- return
- end
- @select=0
- Snd['Sys2'].play
- return
- end
- when :equip
- items=[:suit,:magic,:weapon,:cap,:pants,:boots,:accessory,:accessory]
- @pos=0 if !@choose
- if Keypress[:jump,false] and !@choose and not @select==0 && $save[:items][:suit].empty?
- Snd['Sys2'].play
- @choose=@select
- @select=0
- @max=$save[:items][items[@choose]].uniq.length
- @max-=1 if @choose==0
- elsif Keypress[:jump,false] and @choose
- Snd['Sys2'].play
- last=$save[:equip][@choose]
- $save[:equip][@choose]=((@select==0 and @choose>0) ? nil : $save[:items][items[@choose]].uniq[@choose==0 ? @select : @select-1])
- $save[:items][items[@choose]].delete_at($save[:items][items[@choose]].index($save[:equip][@choose])) if $save[:equip][@choose]# if @select>0 || @choose==0
- $save[:items][items[@choose]].unshift last if last
- @select=@choose
- @choose=nil
- @max=7
- $temp.refresh_stats
- end
- if Keypress[:shoot,false] and !@choose
- Snd['Sys3'].play
- @state=:main
- @select=0
- elsif Keypress[:shoot,false]
- Snd['Sys3'].play
- @max=7
- @select=@choose
- @choose=nil
- end
- (@select+=1;Snd['Sys1'].play if Keypress[:right,false]) if @choose and @select<@max and Keypress[:down,false] || Keypress[:right,false]
- (@select-=1;Snd['Sys1'].play if Keypress[:left,false]) if @choose and @select>0 and Keypress[:up,false] || Keypress[:left,false]
- @pos+=2 if @choose and @select-@pos>7
- @pos-=2 if @choose and @select-@pos<0
- when :useitem
- @max=$save[:items][:usable].uniq.length+$save[:items][:misc].uniq.length-1
- if Keypress[:jump,false] and @select<$save[:items][:usable].uniq.length
- Snd['Use'].play
- item=$items[:usable][$save[:items][:usable].uniq[@select]]
- $save[:hp]=[$save[:hp]+item[:hp],$save[:max_hp]].min if item[:hp]
- $save[:mp]=[$save[:mp]+item[:mp],$save[:max_mp]].min if item[:mp]
- $save[:stars]=[$save[:stars]+item[:stars],$save[:max_stars]].min if item[:stars]
- $save[:status]='GOOD' if item[:status]==$save[:status]
- $save[:recoil]=item[:recoil]
- $save[:items][:usable].delete_at($save[:items][:usable].index($save[:items][:usable].uniq[@select]))
- @max=$save[:items][:usable].uniq.length+$save[:items][:misc].uniq.length-1
- @select-=1 if @select>@max
- end
- if Keypress[:shoot,false]
- Snd['Sys3'].play
- @state=:main
- @select=1
- end
- (@select+=1;Snd['Sys1'].play if Keypress[:right,false]) if @select<@max and Keypress[:down,false] || Keypress[:right,false]
- (@select-=1;Snd['Sys1'].play if Keypress[:left,false]) if @select>0 and Keypress[:up,false] || Keypress[:left,false]
- @pos+=2 if @select-@pos>13
- @pos-=2 if @select-@pos<0
- when :relics
- (@select+=1;Snd['Sys1'].play if Keypress[:right,false]) if @select<@max and Keypress[:down,false] || Keypress[:right,false]
- (@select-=1;Snd['Sys1'].play if Keypress[:left,false]) if @select>0 and Keypress[:up,false] || Keypress[:left,false]
- if Keypress[:shoot,false]
- Snd['Sys3'].play
- @state=:main
- @select=2
- end
- if Keypress[:jump,false]
- if $save[:relics][@select]!=nil
- $save[:relics][@select]=!$save[:relics][@select]
- Snd["Sys#{$save[:relics][@select] ? 2 : 3}"].play
- else
- Snd['Sys4'].play
- end
- end
- when :guides
- if Keypress[:jump,false] and !@guide and $save[:guides][@select]
- @guide=@select
- @name=$guides[@select][0]
- @text=$guides[@select][1]
- @char=0
- @part=1
- Snd['Sys2'].play
- elsif @guide
- @char+=1
- if @char>=@text.length and Keypress[:jump,false]
- @part+=1
- if $guides[@guide][@part]
- @text=$guides[@guide][@part]
- @char=0
- else
- @guide=@text=@char=@part=@name=nil
- end
- end
- end
- @pos+=1 if @select-@pos>6
- @pos-=1 if @select-@pos<0
- if Keypress[:shoot,false]
- Snd['Sys3'].play
- @guide=nil
- @state=:main
- @select=3
- end
- when :infos
- if Keypress[:jump,false]
- @state=[:enemies,:items,:areas][@select]
- @select=0
- @max=$enemies.length-1 if @state==:enemies
- end
- if Keypress[:shoot,false]
- @state=:main
- @select=4
- end
- when :enemies
- if Keypress[:jump,false] and $save[:enemies][@select]
- Snd['Sys2'].play
- @state=:enemy
- end
- if Keypress[:shoot,false]
- Snd['Sys3'].play
- @state=:main
- @select=4
- end
- (@select+=1;Snd['Sys1'].play if Keypress[:right,false]) if @select<@max and Keypress[:down,false] || Keypress[:right,false]
- (@select-=1;Snd['Sys1'].play if Keypress[:left,false]) if @select>0 and Keypress[:up,false] || Keypress[:left,false]
- (@select+=28;Snd['Sys1'].play) if Keypress[KbPageDown,false] and @select<@max-27
- (@select-=28;Snd['Sys1'].play) if Keypress[KbPageUp,false] and @select>27
- when :enemy
- (@state=:enemies;Snd['Sys3'].play) if Keypress[:shoot,false]
- ens=$enemies.length
- ens.times{|id| (@select=id;Snd['Sys1'].play;break) if id>@select and $save[:enemies][id]} if Keypress[KbRight,false]
- ens.times{|id| (@select=(ens-id-1);Snd['Sys1'].play;break) if (ens-id-1)<@select and $save[:enemies][ens-id-1]} if Keypress[KbLeft,false]
- end
- end
- def draw
- case @state
- when :main
- Img['System/Menu1'].draw(0,0,0)
- Img['Faces/Mario'].draw(9,9,0)
- Fnt[['System/Font',20,20]].draw("Mario",69,150,0,:align=>:center)
- Fnt['data/fonts/nine.ttf',40].draw("Lv.#{0 if $save[:level]<10}#{$save[:level]}",20,180,0)
- Fnt[['System/Font',20,20]].draw("HP /",218,18,0)
- Fnt[['System/Font',20,20]].draw($save[:hp],358,18,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw($save[:max_hp],478,18,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("MP /",218,48,0)
- Fnt[['System/Font',20,20]].draw($save[:mp],358,48,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw($save[:max_mp],478,48,0,:align=>:right)
- Img['System/Star'].draw(222,72,0)
- Fnt[['System/Font',20,20]].draw("/",358,78,0)
- Fnt[['System/Font',20,20]].draw($save[:stars],358,78,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw($save[:max_stars],478,78,0,:align=>:right)
- bar(492,19,100,18,$save[:hp],$save[:max_hp],0xffff8000)
- bar(492,49,100,18,$save[:mp],$save[:max_mp],0xff80ff80)
- bar(492,79,100,18,$save[:stars],$save[:max_stars],0xffffff00)
- time=$save[:time]
- txt=[]
- txt << "#{'0' if (t=(time/216000%60).to_i)<10}#{t}"
- txt << "#{'0' if (t=(time/3600%60).to_i)<10}#{t}"
- txt << "#{'0' if (t=(time/60%60).to_i)<10}#{t}"
- $temp.refresh_stats if $save[:equip][3]==8
- Fnt[['System/Font',20,20]].draw("STR",218,118,0)
- Fnt[['System/Font',20,20]].draw($save[:strength],358,118,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("CON",218,148,0)
- Fnt[['System/Font',20,20]].draw($save[:constitution],358,148,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("INT",218,178,0)
- Fnt[['System/Font',20,20]].draw($save[:intelligence],358,178,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("MND",218,208,0)
- Fnt[['System/Font',20,20]].draw($save[:mind],358,208,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("LCK",218,238,0)
- Fnt[['System/Font',20,20]].draw($save[:luck],358,238,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("REG",218,268,0)
- Fnt[['System/Font',20,20]].draw($save[:mp_regen],358,268,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("STOMP",400,118,0)
- Fnt[['System/Font',20,20]].draw($save[:stomp],600,118,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("DEFEN",400,148,0)
- Fnt[['System/Font',20,20]].draw($save[:defence],600,148,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("EXP",400,178,0,:color=>0xff0080ff)
- Fnt[['System/Font',20,20]].draw($save[:exp],400,208,0,:color=>0xff0080ff)
- Fnt[['System/Font',20,20]].draw("NEXT",400,238,0,:color=>0xff0080ff)
- Fnt[['System/Font',20,20]].draw($save[:all]+$save[:next]-$save[:exp],400,268,0,:color=>0xff0080ff)
- Fnt[['System/Font',20,20]].draw("TIME:",218,298,0)
- Fnt[['System/Font',20,20]].draw(txt.join(':'),500,298,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("COINS:",218,328,0,:color=>0xffffff00)
- Fnt[['System/Font',20,20]].draw($save[:coins],500,328,0,:align=>:right,:color=>0xffffff00)
- Fnt[['System/Font',20,20]].draw("STATUS - #{$save[:status]}",218,358,0)
- 8.times{|i| x=(i==0 ? 0 : i-2) ; Tls['Icons/Elements',32,32][$save[:resistance][i]].draw(520+x%2*32,298+x/2*24,0) if $save[:resistance][i]}
- Fnt[['System/Font',20,20]].draw("Equip",20,300,0,:color=>(@select==0 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Item Use",20,330,0,:color=>(@select==1 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Relics",20,360,0,:color=>(@select==2 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Guides",20,390,0,:color=>(@select==3 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Enemies",20,420,0,:color=>(@select==4 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Suspend",20,450,0,:color=>(@select==5 ? 0xffffffff : 0x80ffffff))
- # Fnt[['System/Font',20,20]].draw(["Change equipment and set magic.","View or use an item.","Display list of^collected relicts.","Read hints and^information^from guides.","Show list of all^known items, enemies^and areas.","Hold up the game to^continue later."][@select],216,400,0,:max=>424)
- Fnt[['System/Font',20,20]].draw(["Change equipment and set magic.","View or use an item.","Display list of^collected relicts.","Read hints and^information^from guides.","Show database of^defeated enemies.",@unsaveable ? "You can't suspend in^special rooms.": "Hold up the game to^continue later."][@select],216,400,0,:max=>424)
- when :equip #suit | magic, weapon | cap, pants | boots | accessory1, accessory2
- Img['System/Menu2'].draw(0,0,0)
- Fnt['data/fonts/nine.ttf',50].draw("Equip",0,0,0)
- items=[:suit,:magic,:weapon,:cap,:pants,:boots,:accessory,:accessory]
- seletc=(@choose ? @choose : @select)
- 8.times{|i| Fnt[['System/Font',20,20]].draw($save[:equip][i] ? $items[items[i]][$save[:equip][i]][:name] : '---',40,100+30*i,0,:color=>(seletc==i ? 0xffffffff : 0x80ffffff))
- Img["Icons/#{items[i]}/#{$save[:equip][i]}"].draw(8,98+i*30,0) if $save[:equip][i]}
- # Fnt[['System/Font',20,20]].draw(items[seletc].to_s.capitalize,20,50,0,:scalex=>1.5,:scaley=>1.5)
- Fnt['data/fonts/nine.ttf',30].draw(items[seletc].to_s.capitalize,20,50,0)
- Fnt[['System/Font',20,20]].draw($save[:equip][@select] ? $items[items[@select]][$save[:equip][@select]][:descr] : "You are not wearing any #{items[@select]}.",44,440,0,:xspacing=>15) if !@choose
- Img["Icons/#{items[@select]}/#{$save[:equip][@select]}"].draw(4,444,0) if !@choose and $save[:equip][@select]
- type=items[seletc]
- list=(type==:suit ? [] : [nil])+$save[:items][type]
- select=(@choose ? @select : 0)
- $screen.clip_to(0,340,640,99){$screen.translate(0,-@pos*10){
- list.uniq.length.times{|id| Fnt[['System/Font',20,20]].draw((id==0 and seletc>0) ? '---' : $items[type][list.uniq[id]][:name],32+id%2*320,350+id/2*20,0,:color=>Color.new((@choose and select==id) ? 255 : 128,(seletc==1 and id>0 and @magic[list.uniq[id]]) ? 0 : 255,255,255),:scalex=>0.75,:scaley=>0.75)
- Fnt[['System/Font',20,20]].draw(list.count(list.uniq[id]),320+id%2*320,350+id/2*20,0,:color=>(select==id ? 0xffffffff : 0x80ffffff),:scalex=>0.75,:scaley=>0.75,:align=>:right) if id>0 and seletc>2}}}
- Fnt[['System/Font',20,20]].draw((seletc==0 or @select>0) ? $items[type][list.uniq[@select]][:descr] : "Don't wear any #{items[@choose]}.",44,440,0,:xspacing=>15) if @choose
- Img["Icons/#{type}/#{list.uniq[@select]}"].draw(4,444,0) if @choose and @select>0 || seletc==0
- if [1,2].include?(seletc) and !@choose && $save[:equip][seletc] || @choose && @select>0
- item=$items[type][@choose ? list.uniq[@select] : $save[:equip][@select]]
- Fnt[['System/Font',20,20]].draw("Damage",320,100,0)
- Fnt[['System/Font',20,20]].draw(item[:attack].class==String ? item[:attack] : item[:attack]+($save[[:intelligence,:strength][seletc-1]]/(item[:divide] ? item[:divide] : 1)).to_i,560,100,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw(seletc==1 ? 'MP use' : 'Stars:',320,120,0)
- Fnt[['System/Font',20,20]].draw(item[:use],560,120,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("Recoil",320,140,0) if seletc==1
- Fnt[['System/Font',20,20]].draw(item[:recoil],560,140,0,:align=>:right) if seletc==1
- Tls['Icons/Elements',32,32][item[:element]].draw(564,94,0) if item[:element]
- if seletc==1
- magic=(@choose ? $save[:items][:magic][select-1] : $save[:equip][1])
- return if !magic
- $save[:magic][magic]||=[0,0]
- # mag=[]
- # $save[:magic][magic][1].times{|i| mag[i]=(i==0 ? 0 : mag[i-1])+$items[:magic][:levels][i]}
- mag=$save[:magic][magic][0]
- $save[:magic][magic][1].times{|i| mag-=$items[:magic][magic][:levels][i]}
- $items[:magic][magic][:levels].length.times{|x| Tls['System/Mastery',26,26][1].draw(320+x*26,180,0) ; bar(320+x*26,180,26,26,$save[:magic][magic][1]>x ? 1 : mag,$save[:magic][magic][1]>x ? 1 : $items[:magic][magic][:levels][x],$save[:magic][magic][1]==$items[:magic][magic][:levels].length ? 0xff00ffff : $save[:magic][magic][1]>x ? 0xff00ff00 : 0xffff0000) if x<=$save[:magic][magic][1] ; Tls['System/Mastery',26,26][0].draw(320+x*26,180,0)}
- Fnt[['System/Font',20,20]].draw($save[:magic][magic][1]==$items[:magic][magic][:levels].length ? "MASTER" : "SP: #{mag} / #{$items[:magic][magic][:levels][$save[:magic][magic][1]]}",320,220,0)
- end
- elsif ![1,2].include?(seletc)
- Fnt[['System/Font',20,20]].draw("STOMP",400,100,0,:scalex=>0.5)
- Fnt[['System/Font',20,20]].draw("DEFEN",400,120,0,:scalex=>0.5)
- Fnt[['System/Font',20,20]].draw("STR",400,140,0)
- Fnt[['System/Font',20,20]].draw("CON",400,160,0)
- Fnt[['System/Font',20,20]].draw("INT",400,180,0)
- Fnt[['System/Font',20,20]].draw("MND",400,200,0)
- Fnt[['System/Font',20,20]].draw("LCK",400,220,0)
- Fnt[['System/Font',20,20]].draw("REG",400,240,0)
- attrs=[:stomp,:defence,:strength,:constitution,:intelligence,:mind,:luck,:mp_regen]
- old=[]
- 8.times{|i| old[i]=$save[attrs[i]] ; Fnt[['System/Font',20,20]].draw($save[attrs[i]],540,100+i*20,0,:align=>:right)}
- if @choose
- $temp.refresh_stats(@choose,list.uniq[@select])
- 8.times{|i| Tls['Icons/Elements',32,32][$save[:resistance][i]].draw(320+i*32,24,0) if $save[:resistance][i]}
- 8.times{|i| Fnt[['System/Font',20,20]].draw($save[attrs[i]],640,100+i*20,0,:align=>:right,:color=>c=(old[i]>$save[attrs[i]] ? 0xffff0000 : old[i]<$save[attrs[i]] ? 0xff00ff00 : 0xffffffff))
- Tls['System/Arrow',20,20][[0xff00ff00,0xffffffff,0xffff0000].index(c)].draw(540,100+i*20,0)}
- $temp.refresh_stats
- else
- 8.times{|i| Tls['Icons/Elements',32,32][$save[:resistance][i]].draw(320+i*32,24,0) if $save[:resistance][i]}
- end
- Fnt[['System/Font',20,20]].draw("Resistance",320,0,0)
- end
- when :useitem
- Img['System/Menu4'].draw(0,0,0)
- Fnt['data/fonts/nine.ttf',50].draw("Use Item",0,0,0)
- list1=$save[:items][:usable]
- list2=$save[:items][:misc]
- border=list1.uniq.length
- return (@state=:main ; @select=1) if (list1+list2).empty?
- $screen.clip_to(0,236,640,203){$screen.translate(0,-@pos*15){
- (list1.uniq.length+list2.uniq.length).times{|id| Fnt[['System/Font',20,20]].draw($items[id<border ? :usable : :misc][(list1.uniq+list2.uniq)[id]][:name],32+id%2*320,240+id/2*30,0,:color=>(@select==id ? 0xffffffff : 0x80ffffff),:scalex=>0.75,:scaley=>0.75,:xspacing=>13)
- Fnt[['System/Font',20,20]].draw((id < border ? list1 : list2).count((list1.uniq+list2.uniq)[id]),320+id%2*320,240+id/2*30,0,:color=>(@select==id ? 0xffffffff : 0x80ffffff),:scalex=>0.75,:scaley=>0.75,:align=>:right)}}}
- Fnt[['System/Font',20,20]].draw("HP /",18,68,0)
- Fnt[['System/Font',20,20]].draw($save[:hp],158,68,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw($save[:max_hp],278,68,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("MP /",18,98,0)
- Fnt[['System/Font',20,20]].draw($save[:mp],158,98,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw($save[:max_mp],278,98,0,:align=>:right)
- Img['System/Star'].draw(22,122,0)
- Fnt[['System/Font',20,20]].draw("/",158,128,0)
- Fnt[['System/Font',20,20]].draw($save[:stars],158,128,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw($save[:max_stars],278,128,0,:align=>:right)
- bar(292,69,200,18,$save[:hp],$save[:max_hp],0xffff8000)
- bar(292,99,200,18,$save[:mp],$save[:max_mp],0xff80ff80)
- bar(292,129,200,18,$save[:stars],$save[:max_stars],0xffffff00)
- Fnt[['System/Font',20,20]].draw("STATUS - #{$save[:status]}",18,158,0)
- Fnt[['System/Font',20,20]].draw($items[@select<border ? :usable : :misc][(list1.uniq+list2.uniq)[@select]][:descr],44,440,0,:xspacing=>15)
- Img["Icons/#{@select < border ? 'Usable' : 'Misc'}/#{(list1.uniq+list2.uniq)[@select]}"].draw(4,444,0)
- when :relics
- Img['System/Menu5'].draw(0,0,0)
- Fnt['data/fonts/nine.ttf',50].draw("Relics",0,0,0)
- $relics.length.times{|id| Fnt[['System/Font',20,20]].draw(($save[:relics][id]!=nil) ? $relics[id][0] : '?'*$relics[id][0].length,32+id%2*240,64+id/2*30,1,:color=>(@select==id ? 0xffffffff : 0x80ffffff),:scalex=>0.75,:scaley=>0.75)
- Tls['System/Relic',400,30][($save[:relics][id] ? 1 : 0)+id%2*2].draw(id%2*240,59+id/2*30,0) if $save[:relics][id]!=nil}
- Fnt[['System/Font',20,20]].draw(($save[:relics][@select]!=nil) ? $relics[@select][1] : "You don't have this relic.",44,440,0,:xscale=>0.75,:xspacing=>14)
- Img["Icons/Relics/#{$save[:relics][@select]!=nil ? @select : 'None'}"].draw(4,444,0)
- when :guides
- Img['System/Menu7'].draw(0,0,0)
- Fnt['data/fonts/nine.ttf',50].draw("Guides",0,0,0)
- $screen.clip_to(0,144,640,336){$screen.translate(0,-@pos*45){
- $guides.length.times{|id| Fnt[['System/Font',20,20]].draw("Guide ##{id+1}",32,144+id*45,1,:color=>(@select==id ? 0xffffffff : 0x80ffffff),:scalex=>0.75,:scaley=>0.75)
- Fnt[['System/Font',20,20]].draw($save[:guides][id] ? $guides[id][0] : 'Unavailable',32,144+id*45+15,1,:color=>Color.new(@select==id ? 255 : 128,255,$save[:guides][id] ? 255 : 0,255),:scalex=>0.75,:scaley=>0.75)}
- }}
- if @guide
- Fnt[['System/Font',20,20]].draw(@text[(0...@char)],150,20,4,:xspacing=>15)
- Fnt[['System/Font',20,20]].draw(@name,392,0,4,:align=>:center)
- else
- Fnt[['System/Font',20,20]].draw($save[:guides][@select] ? "Jump to display" : "Find guide to read it",392,0,4,:align=>:center)
- end
- # $relics.length.times{|id| Fnt[['System/Font',20,20]].draw(($save[:guides][id]!=nil) ? $relics[id][0] : '?'*$relics[id][0].length,32+id%2*240,64+id/2*30,1,:color=>(@select==id ? 0xffffffff : 0x80ffffff),:scalex=>0.75,:scaley=>0.75)
- # Tls['System/Relic',400,30][($save[:relics][id] ? 1 : 0)+id%2*2].draw(id%2*240,59+id/2*30,0) if $save[:relics][id]!=nil}
- when :infos
- Fnt[['System/Font',20,20]].draw("Encyclopedia",320,100,0,:align=>:center,:scalex=>2,:scaley=>2)
- Fnt[['System/Font',20,20]].draw("Enemies",320,200,0,:align=>:center,:color=>(@select==0 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Items",320,230,0,:align=>:center,:color=>(@select==1 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Areas",320,260,0,:align=>:center,:color=>(@select==2 ? 0xffffffff : 0x80ffffff))
- when :enemies
- Img['System/Menu6'].draw(0,0,0)
- Fnt['data/fonts/nine.ttf',50].draw("Enemies' Data",0,0,0)
- Fnt[['System/Font',20,20]].draw("Killed enemies:^#{$save[:allkills]}",330,5,0)
- $screen.clip_to(0,68,640,412){$screen.translate(0,-(@select/28*420)){
- $enemies.length.times{|id| Fnt[['System/Font',20,20]].draw("#{0 if id+1<100}#{0 if id+1<10}#{id+1} "+($save[:enemies][id] ? $enemies[id][:name] : '????????'),15+id%2*320,68+id/2*30,0,:color=>Color.new(@select==id ? 255 : 128,@enemies[id] ? 0 : 255,255,255),:scalex=>0.75,:scaley=>0.75)}
- }}
- Tls['System/Page',34,30][1].draw(303,59,1) if @select>27 and $count%30<15
- Tls['System/Page',34,30][0].draw(303,450,1) if @select<@max-27 and $count%30<15
- when :enemy
- Img['System/Menu3'].draw(0,0,0)
- $screen.clip_to(9,9,190,190) {enemy_img($enemies[@select][:name]).draw_rot(104,104,0,0) if enemy_img($enemies[@select][:name])}
- Fnt[['System/Font',20,20]].draw("No.#{0 if @select+1<100}#{0 if @select+1<10}#{@select+1}",208,20,0)
- Fnt[['System/Font',20,20]].draw($enemies[@select][:name],208,60,0)
- Fnt[['System/Font',20,20]].draw("HP:",208,140,0)
- Fnt[['System/Font',20,20]].draw($enemies[@select][:hp],480,140,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("EXP: SP:",208,170,0)
- Fnt[['System/Font',20,20]].draw($enemies[@select][:exp],480,170,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw($enemies[@select][:sp],625,170,0,:align=>:right)
- Fnt[['System/Font',20,20]].draw("TOLERANCE:",8,220,0)
- Fnt[['System/Font',20,20]].draw("WEAKNESS:",8,250,0)
- Fnt[['System/Font',20,20]].draw("DROP:^ :",8,280,0)
- Fnt[['System/Font',20,20]].draw($enemies[@select][:drop][0] ? $save[:enemies][@select][0] ? $items[$enemies[@select][:drop][0][0]][$enemies[@select][:drop][0][1]][:name] : "???" : "---",208,280,0)
- Fnt[['System/Font',20,20]].draw($enemies[@select][:drop][1] ? $save[:enemies][@select][0] ? $items[$enemies[@select][:drop][1][0]][$enemies[@select][:drop][1][1]][:name] : "???" : "---",208,310,0)
- Fnt[['System/Font',20,20]].draw("Killed: #{$save[:kills][@select]}",8,340,0)
- Fnt[['System/Font',20,20]].draw($enemies[@select][:descr],8,420,0,:xspacing=>15)
- rare=([$save[:equip][6],$save[:equip][7]].include?(3) ? 2 : 1)
- if $enemies[@select][:drop][0]
- rarity=($enemies[@select][:drop][0][2]+$save[:luck]*0.025)*rare
- if $save[:equip][3]==9
- Fnt[['System/Font',20,20]].draw(rarity.round(2),108,282,0)
- else
- (rarity>8 ? 1 : rarity>5 ? 2 : rarity>3 ? 3 : rarity>1 ? 4 : 5).times{|x| Img['System/Rarity'].draw(108+x*16,282,0)}
- end
- end
- if $enemies[@select][:drop][1]
- rarity=($enemies[@select][:drop][1][2]+$save[:luck]*0.025)*rare
- # (rarity>8 ? 1 : rarity>2.5 ? 2 : rarity>0.8 ? 3 : rarity>0.2 ? 4 : 5).times{|x| Img['System/Rarity'].draw(108+x*16,312,0)}
- if $save[:equip][3]==9
- Fnt[['System/Font',20,20]].draw(rarity,108,312,0)
- else
- (rarity>8 ? 1 : rarity>5 ? 2 : rarity>3 ? 3 : rarity>1 ? 4 : 5).times{|x| Img['System/Rarity'].draw(108+x*16,312,0)}
- end
- end
- 11.times{|x| Tls['Icons/Elements',32,32][x].draw(228+x*32,214,0) if $enemies[@select][:tolerance].include?(x)} if $enemies[@select][:tolerance]
- 11.times{|x| Tls['Icons/Elements',32,32][x].draw(228+x*32,244,0) if $enemies[@select][:weakness].include?(x)} if $enemies[@select][:weakness]
- end
- end
- def bar(x,y,width,height,value,max,color)
- $screen.draw_quad(x,y,color,x+(value.to_f/max)*width,y,color,x+(value.to_f/max)*width,y+height,color,x,y+height,color,0)
- end
- def enemy_img(id)
- case id
- when 'Goomba'
- Tls['Enemies/Goomba',32,32][$count/8%2]
- when 'Green K.Troopa'
- Tls['Enemies/Green Koopa Troopa',32,48][$count/8%2]
- when 'Peeps'
- Tls['Enemies/Peeps',48,45][([0]*60+[1,2,3,2,1])[$count/4%65]]
- when 'Swooper'
- Tls['Enemies/Swooper',32,44][1+$count/8%2]
- when 'Red K.Troopa'
- Tls['Enemies/Red Koopa Troopa',32,48][$count/8%2]
- when 'Spiny'
- Tls['Enemies/Spiny',32,32][$count/8%2]
- when 'Monty Mole'
- Tls['Enemies/Monty Mole',32,32][[4,5][$count/8%2]]
- when 'Novice Ninji'
- Tls['Enemies/Ninji1',32,32][$count/8%2]
- when 'Y. Paratroopa'
- Tls['Enemies/Yellow Paratroopa',32,48][$count/8%2]
- when 'Rex'
- Tls['Enemies/Rex',32,64][$count/8%2]
- when 'Cheep-Cheep'
- Tls['Enemies/Cheep Cheep',32,32][$count/8%2]
- when 'Spiny Ch-Cheep'
- Tls['Enemies/Spiny Cheep Cheep',33,42][$count/8%2]
- when 'Sushi'
- Tls['Enemies/Sushi',144,54][$count/8%2]
- when 'Skeeter'
- Img['Enemies/Skeeter']
- when 'Buzzy Beetle'
- Tls['Enemies/Buzzy Beetle',32,32][$count/8%2]
- when 'Huckit Crab'
- Tls['Enemies/Huckit Crab',54,40][$count/4%2]
- when 'Piranha Plant'
- Tls['Enemies/Piranha Plant',32,48][$count/8%2]
- when 'Iceranha Plant'
- Tls['Enemies/Iceranha Plant',32,48][$count/8%2]
- when 'Venus Fire Trap'
- Tls['Enemies/Venus Preview',32,48][$count/8%2]
- when 'Medusa Plant'
- Tls['Enemies/Medusa Plant',32,48][$count/8%2]
- when 'Fang'
- Tls['Enemies/Fang',56,36][1+$count/8%2]
- when "Chargin' Chuck"
- Tls['Enemies/Chargin Chuck Preview',52,54][[0,0,0,1,2,3,4,4,4,3,2,1][$count/16%12]]
- when 'Bullet Bill'
- Tls['Enemies/Bullet Bill',32,28][[0,1,2,1][$count/8%4]]
- when 'Bill Blaster'
- Img['Enemies/Blaster']
- when 'Rocket Engine'
- Img['Enemies/Engine Preview']
- when 'Hammer Bro.'
- Tls['Enemies/Hammer Bro.',32,68][2+$count/8%2]
- when 'Rebound Bro.'
- Tls['Enemies/Rebound Bro.',32,48][2+$count/8%2]
- when 'Panzer Beetle'
- Tls['Enemies/Panzer Beetle',32,32][$count/8%2]
- when 'Venomous Spiny'
- Tls['Enemies/Venom Spiny',32,32][$count/8%2]
- when 'Shy Guy'
- Tls['Enemies/Shy Guy',32,32][$count/8%2]
- when 'Fire Bro.'
- Tls['Enemies/Fire Bro.',32,48][2+$count/8%2]
- when 'Bob-omb'
- Tls['Enemies/Bob-omb',32,32][$count/8%2]
- when 'Mecha-Plant'
- Tls['Enemies/Mecha Plant Preview',32,64][$count/8%2]
- when 'Sniper Koopa'
- Img['Enemies/SK Preview']
- when 'Holy Goomba'
- Tls['Enemies/Holy Goomba',48,48][$count/8%2]
- when 'Chain-Chomp'
- Tls['Enemies/ChainChomp Preview',96,96][$count/8%2]
- when 'Paragoomba'
- Tls['Enemies/Paragoomba',40,48][$count/8%4]
- when 'B. Paratroopa'
- Tls['Enemies/Blue Paratroopa',32,48][$count/8%2]
- when 'Para-Beetle'
- Tls['Enemies/ParaBeetle',32,32][$count/8%2]
- when 'Fire Chomp'
- Tls['Enemies/FireChomp',32,32][$count/8%2]
- when "A. Flyin' H. B."
- Tls['Enemies/FlyingHB',108,78][$count/15%2]
- when 'Banzai Bill'
- Img['Enemies/Banzai Bill']
- when 'Stoney Koopa'
- Tls['Enemies/Stoney',46,26][$count/8%2+2]
- when 'Ninji'
- Tls['Enemies/Ninji2',32,32][$count/8%2]
- when 'Boomerang Bro.'
- Tls['Enemies/Boomerang Bro.',32,48][2+$count/8%2]
- when "Pokey"
- Tls['Enemies/Pokey Preview',40,96][$count/8%4]
- when "Volcano Lotus"
- Tls['Enemies/Volcano Lotus',64,32][$count/8%2]
- when 'Scaredy Rat'
- Tls['Enemies/Scaredy Rat',41,28][[0,1,0,2][$count/8%4]]
- when 'Eerie'
- Tls['Enemies/Eerie',32,32][$count/8%2]
- when 'Boo'
- Tls['Enemies/Bou',32,32][$count/60%2]
- when 'Big Boo'
- Tls['Enemies/Big Boo',134,128][$count/60%2]
- when "Fishin' Boo"
- Tls['Enemies/Fishin Preview',86,166][$count/8%4]
- when "Dry Bones"
- Tls['Enemies/Dry Bones',48,56][$count/8%2]
- when "Bony Beetle"
- Tls['Enemies/Bony Beetle',32,32][$count/8%2]
- when "Magikoopa"
- Tls['Enemies/Magi',52,62][1+$count/8%2]
- when "Spiny Egg"
- Img['Enemies/SpikyBall']
- when "Lakitu"
- Tls['Enemies/Lakitu',32,64][0]
- when "Stony"
- Tls['Enemies/Stony',32,32][$count/8%2]
- when "Scuttle Bug"
- Img['Enemies/ScuttleBug']
- when "Koopa Priest"
- Tls['Enemies/Priest',70,78][1+$count/8%2]
- when "Necrokoopa"
- Tls['Enemies/Necro',52,62][1+$count/8%2]
- when "Dino-Torch"
- Tls['Enemies/Dino-Torch',32,32][$count/8%2]
- when "Dino-Fridge"
- Tls['Enemies/Dino-Fridge',32,32][$count/8%2]
- when "Nyan Cat"
- Tls['Enemies/Nyan',94,57][$count/8%6]
- when "Hammer Giant"
- Img['Enemies/Giant']
- when "Clear Dry Bones"
- Tls['Enemies/Clear Dry Bones',48,56][$count/8%2]
- when "Zombie Yoshi"
- Tls['Enemies/Zombie',52,64][0]
- when 'Golden Goomba'
- Tls['Enemies/GoldGoomba',32,32][$count/8%2]
- when 'Titan'
- Tls['Enemies/Titan',32,32][$count/8%2]
- when 'Boom Boom Boom'
- Tls['Enemies/BBB',136,108][[1,2,3,4,3,2][$count/8%6]]
- when 'Orobunagi'
- Tls['Enemies/Unagi Preview',190,87][$count/4%10]
- when 'P-cus Ultimatus'
- Tls['Enemies/Ultimatus Preview',50,190][$count/8%2]
- when 'Thwomp Destroyer'
- Img['Enemies/Destroyer Preview']
- when 'Tox Box Max'
- Tls['Enemies/Tox Box',256,256][0]
- when 'Boo Formation'
- Tls['Enemies/Boo Formation',128,128][$count/16%4]
- when 'Goombfalloon'
- [Img['Enemies/Goombfalloon'],Tls['Enemies/Legion',48,48][0]][$count/60%2]
- when 'Death'
- Tls['Enemies/Death2',230,170][[4,9][$count/60%2]]
- when 'Chaos Core'
- Img['Enemies/Chaos Preview']
- when "Wiggler"
- rage=($count/128%2==0)
- Tls['Enemies/Wiggler',158,80][(rage ? 4 : 0)+$count/(rage ? 4 : 8)%4]
- when 'Thwomp'
- Tls['Enemies/Thwomp',72,96][0]
- when 'Chainsaw'
- Tls['Enemies/Chainsaw',32,86][$count%2]
- when 'Podoboo'
- Tls['Enemies/Podoboo',28,32][$count/8%3]
- when 'Mad Piano'
- Tls['Enemies/Mad Piano',128,121][[0,1,2,3,2,1][$count/4%6]]
- when 'Out-Boo'
- Tls['Enemies/Outoo',32,32][$count/60%2]
- when 'Floating Mine'
- Tls['Enemies/Mine',30,30][$count/16%2]
- when "Li'l Sparky"
- Img['Enemies/Sparky']
- when 'Snift'
- Tls['Enemies/Snift',32,32][$count/8%2]
- when 'Lakithunder'
- Tls['Enemies/Lakithunder',78,94][0]
- when 'Muncher'
- Tls['Enemies/Muncher',32,32][$count/8%2]
- when 'Po-ison-key'
- Tls['Enemies/Poisonkey Preview',56,144][$count/8%4]
- when 'Fuzzy'
- Tls['Enemies/Fuzzy',48,44][$count/8%4]
- when 'Ghost Vase'
- Tls['Enemies/Vase',24,48][$count/60%2]
- when 'Mad Block'
- Tls['Enemies/Mad Block',32,32][4]
- when 'Lightning Lotus'
- Tls['Enemies/Lighting Lotus',64,32][$count/16%2]
- when 'Chain-Cheep'
- Tls['Enemies/ChainCheep Preview',96,96][$count/8%2]
- when 'Shadow Bro.'
- Tls['Enemies/Shadow Bro.',32,68][2+$count/8%2]
- when 'Reznor'
- Tls['Enemies/Reznor',64,66][0]
- when 'Novaboo'
- Tls['Enemies/Novaboo',28,32][$count/8%3]
- when 'Sky Cheep-Cheep'
- Tls['Enemies/Sky Cheep Cheep',32,32][$count/8%4]
- when 'Ptooie'
- Tls['Enemies/Ptooie',32,50][$count/8%4]
- when 'Mecha-Plant v.2.6b'
- Tls['Enemies/MechaPlant Preview',32,64][$count/8%2]
- when 'Dark Star'
- Tls['Enemies/Dark Star',122,120][$count/4%12]
- when 'Sorckoopa'
- Tls['Enemies/Sorc',52,62][1+$count/8%2]
- when 'Hammer Master'
- Img['Enemies/HammerMaster']
- when 'Omnisledge Bro.'
- Tls['Enemies/Omnis',192,256][$count/4%6]
- when 'Luigi'
- Img['Enemies/Luigi']
- when 'Bang Star'
- Img['Enemies/Bang Star']
- when 'Phanto'
- Tls['Enemies/Phanto',32][0]
- when 'Kamek'
- Tls['Enemies/Kamek',100,96][$count/8%2]
- when 'Bowser'
- Tls['Enemies/Bowser',96,120][0]
- when 'Mega Bowser'
- Img['Enemies/Mega Bowser Preview']
- end
- end
- end
- class Minimap
- def initialize(origin,x,y)
- @x=origin[0]*10+x/64.0
- @y=origin[1]*10+y/48.0
- if $save[:relics][9]==true
- @image1=$screen.record(640,480){$save[:map].each{|room| room.draw(0)}}
- @image2=$screen.record(640,480){$save[:map].each{|room| room.draw(1)}}
- @image3=$screen.record(640,480){$save[:map].each{|room| room.draw(2)}}
- @mode=($save[:dimension] ? 0 : 2)
- else
- @image1=$screen.record(640,480){$save[:map].each{|room| room.draw(3)}}
- end
- @time=0
- @percent=(($save[:map].count{|room| room.discovered}/$save[:map].length.to_f)*100).round(2)
- end
- def update
- @time+=1
- if Keypress[:shoot,false] or Keypress[:select,false]
- Snd['Sys3'].play
- $game=$temp
- $temp=nil
- end
- end
- def draw
- if $save[:relics][9]
- Fnt[['System/Font',20,20]].draw(["Distortion","Combined","Normal"][@mode],320,0,0,:align=>:center)
- (@mode-=1;Snd['Sys1'].play) if Keypress[:left,false] and @mode>0
- (@mode+=1;Snd['Sys1'].play) if Keypress[:right,false] and @mode<2
- [@image3,@image1,@image2][@mode].draw(0,0,0)
- else
- @image1.draw(0,0,0)
- end
- Img['System/Position'].draw_rot(@x,@y,0,0,0.5,0.5,(100-@time%100)*0.01,(100-@time%100)*0.01,Color.new((@time%100*2.5).to_i,255,255,255)) if not @mode==0 && !$save[:dimension] || @mode==2 && $save[:dimension]
- Fnt[['System/Font',20,20]].draw("#{@percent}%",10,10,0)
- end
- end
- class Shop
- def initialize
- Snd['Sys5'].play
- @state=:main
- @select=0
- @max=2
- @items={:misc=>[],:usable=>[],:cap=>[],:pants=>[],:boots=>[],:accessory=>[]}
- add_item(:misc,'Castle Map 2')
- add_item(:usable,'Super Mushroom')
- add_item(:usable,'Ultra Mushroom') if $save[:events][10]
- add_item(:usable,'Hyper Mushroom') if $save[:events][23]
- add_item(:usable,'Mana Potion')
- add_item(:usable,'Mana Bottle') if $save[:events][10]
- add_item(:usable,'Star Prism') if $save[:events][10]
- add_item(:usable,'Star Refresh') if $save[:events][23]
- add_item(:usable,'De-Poisoned Mushroom')
- add_item(:usable,'Holy Mushroom')
- add_item(:boots,'Wooden Boots')
- add_item(:accessory,'A Ring') if $save[:cores].length>0
- add_item(:accessory,'4-leaf Clover')
- add_item(:accessory,'New Scarf') if $save[:events][7]
- add_item(:accessory,'Mushroom Badge') if $save[:events][23]
- add_item(:accessory,"Ring'o Drop") if $save[:events][23]
- add_item(:accessory,"Sorcerer Necklace") if $save[:enemies][94] and $save[:enemies][94][0]
- add_item(:pants,'Elven Pants') if $save[:events][7]
- add_item(:cap,'Metal Cap') if $save[:events][6]
- add_item(:cap,'Geeks') if $save[:events][14]
- end
- def update
- (@select+=1;Snd['Sys1'].play) if @select<@max and Keypress[:down,false]
- (@select-=1;Snd['Sys1'].play) if @select>0 and Keypress[:up,false]
- case @state
- when :main
- @max=2
- if Keypress[:jump,false]
- case @select
- when 0
- Snd['Sys2'].play
- @select=0
- @state=:buy
- @max=-1
- @items.values.each{|val| @max+=val.length}
- @amm=1
- @old=nil
- @pos=0
- when 1
- return Snd['Sys4'].play if !select2
- Snd['Sys2'].play
- @select=0
- @state=:sell
- @max=-1
- $save[:items].each_pair{|type,ary| @max+=ary.uniq.length if ![:suit,:magic,:weapon,:misc].include?(type)}
- @amm=1
- @old=nil
- @pos=0
- when 2
- Snd['Sys5'].play
- $game=$temp
- $temp=nil
- message
- end
- end
- if Keypress[:shoot,false]
- $game=$temp
- $temp=nil
- message
- if $save[:items][:misc].include?(1)
- map=Marshal.load(f=File.open("data/plan1",'r'))
- f.close
- map.each{|plan| room=$save[:map].find{|room| room.x/10==plan[0] and room.y/10==plan[1]} ; room.map! if room}
- end
- end
- when :buy
- @amm=1 if @old != @select
- @old=@select
- if Keypress[:jump,false] and (price=$items[select][@items[select][@sel]][:price]*@amm)<=$save[:coins]
- Snd['Item'].play
- $save[:coins]-=price
- $save[:items][select]=$save[:items][select]+[@items[select][@sel]]*@amm
- elsif Keypress[:jump,false]
- Snd['Sys4'].play
- end
- if Keypress[KbRight]
- @hold||=0
- if @amm<99 and (@hold%8)==0
- @amm+=1
- Snd['Sys1'].play
- end
- @hold+=1
- elsif Keypress[KbLeft]
- @hold||=0
- if @amm>1 and (@hold%8)==0
- @amm-=1
- Snd['Sys1'].play
- end
- @hold+=1
- else
- @hold=0
- end
- if Keypress[:shoot,false]
- Snd['Sys3'].play
- @select=0
- @state=:main
- end
- @pos+=1 if @select-@pos>7
- @pos-=1 if @select-@pos<0
- when :sell
- @amm=1 if @old != @select
- @old=@select
- if Keypress[:jump,false]
- Snd['Sys2'].play
- $save[:coins]+=$items[select2][$save[:items][select2].uniq[@sel]][:price]/2*@amm
- @amm.times{$save[:items][select2].delete_at($save[:items][select2].index($save[:items][select2].uniq[@sel]))}
- return @state=:main if !select2
- @amm=[@amm,$save[:items][select2].count($save[:items][select2].uniq[@sel])].min
- @max=-1
- $save[:items].each_pair{|type,ary| @max+=ary.uniq.length if ![:suit,:magic,:weapon,:misc].include?(type)}
- @select=[@select,@max].min
- return @state=:main if !$save[:items].values.find{|cat| !cat.empty?}
- end
- if Keypress[KbRight]
- @hold||=0
- if @amm<$save[:items][select2].count($save[:items][select2].uniq[@sel]) and (@hold%8)==0
- @amm+=1
- Snd['Sys1'].play
- end
- @hold+=1
- elsif Keypress[KbLeft]
- @hold||=0
- if @amm>1 and (@hold%8)==0
- @amm-=1
- Snd['Sys1'].play
- end
- @hold+=1
- else
- @hold=0
- end
- if Keypress[:shoot,false]
- Snd['Sys3'].play
- @select=1
- @state=:main
- end
- @pos+=1 if @select-@pos>7
- @pos-=1 if @select-@pos<0
- end
- end
- def draw
- case @state
- when :main
- Fnt[['System/Font',20,20]].draw("Buy",320,120,0,:align=>:center,:color=>(@select==0 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Sell",320,150,0,:align=>:center,:color=>(@select==1 ? 0xffffffff : 0x80ffffff))
- Fnt[['System/Font',20,20]].draw("Exit",320,180,0,:align=>:center,:color=>(@select==2 ? 0xffffffff : 0x80ffffff))
- Img['Faces/Toad3'].draw(16,316,0)
- Fnt[['System/Font',20,20]].draw(["So you want to buy? I have good deals for^you.","Is there something you don't need? Give me^for a fair price.","Leaving already? Come back later for new^items."][@select],0,440,0,:xspacing=>15)
- when :buy
- Img['System/Shop'].draw(0,0,0)
- Fnt['data/fonts/nine.ttf',128].draw("Buy",138,0,0)
- Fnt[['System/Font',20,20]].draw("Coins: #{$save[:coins]}",20,160,0,:color=>0xffffff00)
- y=0
- $screen.clip_to(0,196,640,200){$screen.translate(0,-@pos*25){
- @items.keys.length.times{|type| typ=[:misc,:usable,:cap,:pants,:boots,:accessory][type] ; @items[typ].each{|id| Fnt[['System/Font',20,20]].draw($items[typ][id][:name],40,200+y*25,0,:xspacing=>15,:color=>(@select==y ? 0xffffffff : 0x80ffffff)) ; Fnt[['System/Font',20,20]].draw(price=$items[typ][id][:price],600,200+y*25,0,:xspacing=>15,:align=>:right,:color=>(price>$save[:coins] ? 0xffff0000 : 0xffffffff)) ; y+=1}}}}
- Fnt[['System/Font',20,20]].draw($items[select][@items[select][@sel]][:descr],44,440,0,:xspacing=>15)
- Img["Icons/#{select}/#{@items[select][@sel]}"].draw(4,444,0)
- Fnt[['System/Font',20,20]].draw("Buy x#{@amm} - #{price=$items[select][@items[select][@sel]][:price]*@amm}",20,410,0,:color=>(price>$save[:coins] ? 0xffff0000 : 0xffffffff))
- Fnt[['System/Font',20,20]].draw("Keeping: #{$save[:items][select].count(@items[select][@sel])}",400,410,0)
- Fnt[['System/Font',20,20]].draw("STOMP",400,20,0,:scalex=>0.5)
- Fnt[['System/Font',20,20]].draw("DEFEN",400,40,0,:scalex=>0.5)
- Fnt[['System/Font',20,20]].draw("STR",400,60,0)
- Fnt[['System/Font',20,20]].draw("CON",400,80,0)
- Fnt[['System/Font',20,20]].draw("INT",400,100,0)
- Fnt[['System/Font',20,20]].draw("MND",400,120,0)
- Fnt[['System/Font',20,20]].draw("LCK",400,140,0)
- Fnt[['System/Font',20,20]].draw("REG",400,160,0)
- attrs=[:stomp,:defence,:strength,:constitution,:intelligence,:mind,:luck,:mp_regen]
- old=[]
- 8.times{|i| old[i]=$save[attrs[i]] ; Fnt[['System/Font',20,20]].draw($save[attrs[i]],540,20+i*20,0,:align=>:right)}
- if [:cap,:boots,:pants,:accessory].include?(select)
- items=[:suit,:magic,:weapon,:cap,:pants,:boots,:accessory,:accessory]
- $temp.refresh_stats(items.index(select),@items[select][@sel])
- 8.times{|i| Fnt[['System/Font',20,20]].draw($save[attrs[i]],640,20+i*20,0,:align=>:right,:color=>c=(old[i]>$save[attrs[i]] ? 0xffff0000 : old[i]<$save[attrs[i]] ? 0xff00ff00 : 0xffffffff))
- Tls['System/Arrow',20,20][[0xff00ff00,0xffffffff,0xffff0000].index(c)].draw(540,20+i*20,0)}
- $temp.refresh_stats
- end
- Img['System/Further'].draw(8,204,2) if @pos>0 and $count%60<30
- Img['System/Further'].draw(8,390,2,1,-1) if @pos<@max-7 and $count%60<30
- when :sell
- Img['System/Shop'].draw(0,0,0)
- Fnt['data/fonts/nine.ttf',128].draw("Sell",138,0,0)
- Fnt[['System/Font',20,20]].draw("Coins: #{$save[:coins]}",20,160,0,:color=>0xffffff00)
- y=0
- keys=$save[:items].keys-[:misc,:magic,:weapon,:suit]
- $screen.clip_to(0,196,640,200){$screen.translate(0,-@pos*25){
- keys.length.times{|type| typ=[:usable,:cap,:pants,:boots,:accessory][type] ; $save[:items][typ].uniq.each{|id| Fnt[['System/Font',20,20]].draw($items[typ][id][:name],40,200+y*25,0,:xspacing=>15,:color=>(@select==y ? 0xffffffff : 0x80ffffff)) ; Fnt[['System/Font',20,20]].draw($save[:items][typ].count(id),600,200+y*25,0,:xspacing=>15,:align=>:right) ; y+=1}}}}
- Fnt[['System/Font',20,20]].draw($items[select2][$save[:items][select2].uniq[@sel]][:descr],44,440,0,:xspacing=>15)
- Img["Icons/#{select2}/#{$save[:items][select2].uniq[@sel]}"].draw(4,444,0)
- Fnt[['System/Font',20,20]].draw("Sell x#{@amm} - #{$items[select2][$save[:items][select2].uniq[@sel]][:price]/2*@amm}",20,410,0)
- Fnt[['System/Font',20,20]].draw("STOMP",400,20,0,:scalex=>0.5)
- Fnt[['System/Font',20,20]].draw("DEFEN",400,40,0,:scalex=>0.5)
- Fnt[['System/Font',20,20]].draw("STR",400,60,0)
- Fnt[['System/Font',20,20]].draw("CON",400,80,0)
- Fnt[['System/Font',20,20]].draw("INT",400,100,0)
- Fnt[['System/Font',20,20]].draw("MND",400,120,0)
- Fnt[['System/Font',20,20]].draw("LCK",400,140,0)
- Fnt[['System/Font',20,20]].draw("REG",400,160,0)
- attrs=[:stomp,:defence,:strength,:constitution,:intelligence,:mind,:luck,:mp_regen]
- old=[]
- 8.times{|i| old[i]=$save[attrs[i]] ; Fnt[['System/Font',20,20]].draw($save[attrs[i]],540,20+i*20,0,:align=>:right)}
- if [:cap,:boots,:pants,:accessory].include?(select2)
- items=[:suit,:magic,:weapon,:cap,:pants,:boots,:accessory,:accessory]
- $temp.refresh_stats(items.index(select2),$save[:items][select2].uniq[@sel])
- 8.times{|i| Fnt[['System/Font',20,20]].draw($save[attrs[i]],640,20+i*20,0,:align=>:right,:color=>c=(old[i]>$save[attrs[i]] ? 0xffff0000 : old[i]<$save[attrs[i]] ? 0xff00ff00 : 0xffffffff))
- Tls['System/Arrow',20,20][[0xff00ff00,0xffffffff,0xffff0000].index(c)].draw(540,20+i*20,0)}
- $temp.refresh_stats
- end
- Img['System/Further'].draw(8,204,2) if @pos>0 and $count%60<30
- Img['System/Further'].draw(8,390,2,1,-1) if @pos<@max-7 and $count%60<30
- end
- end
- def select
- @sel=@select
- return :misc if @sel<@items[:misc].length
- return :usable if (@sel-=@items[:misc].length)<@items[:usable].length
- return :cap if (@sel-=@items[:usable].length)<@items[:cap].length
- return :pants if (@sel-=@items[:cap].length)<@items[:pants].length
- return :boots if (@sel-=@items[:pants].length)<@items[:boots].length
- return :accessory if (@sel-=@items[:boots].length)<@items[:accessory].length
- end
- def select2
- @sel=@select
- return :usable if @sel<$save[:items][:usable].uniq.length
- return :cap if (@sel-=$save[:items][:usable].uniq.length)<$save[:items][:cap].uniq.length
- return :pants if (@sel-=$save[:items][:cap].uniq.length)<$save[:items][:pants].uniq.length
- return :boots if (@sel-=$save[:items][:pants].uniq.length)<$save[:items][:boots].uniq.length
- return :accessory if (@sel-=$save[:items][:boots].uniq.length)<$save[:items][:accessory].uniq.length
- end
- def add_item(type,name)
- @items[type] << $items[type].index{|item| item[:name]==name}
- end
- def message
- if !$save[:events][37]
- $save[:events][37]=true
- Message.new("Toad","Toad3","Be sure to come back,^to check if I have new wares.")
- end
- end
- end
- class MainMenu
- def initialize
- @select=0
- @max=2
- @state=:intro
- Msc['Zelda2'].play
- @saves=[]
- 5.times{|id|@saves[id]=if File.exists?("data/save#{id}")
- data=Marshal.load(f=File.new("data/save#{id}",'r'))
- f.close ; data end}
- @sessions=[]
- 5.times{|id|@sessions[id]=if File.exists?("data/save#{id}s")
- data=Marshal.load(f=File.new("data/save#{id}s",'r'))
- f.close ; data end}
- @music=[]
- (Dir.entries('data/music')-['.','..']).each{|msc| @music << msc.chop.chop.chop.chop}
- @music.delete_if{|mus| mus.include?('-pre')}
- @games={'Castlevania: Aria of Sorrow'=>['Clock Tower','Confrontation','Forbidden Area'],'Castlevania: Dawn of Sorrow'=>['The Abyss','Platinum Moonlight'],'Chrono Trigger'=>['World Revolution'],'Castlevania: Circle of the Moon'=>['Nightmare','Awake'],'Castlevania: Portrait of Ruin'=>['Piercing Silence',"Crucifix Held Close","Iron Blue Intention","Chaotic Playground"],"Castlevania: Symphony of the Night"=>["Dracula's Castle"],"Castlevania: Order of Ecclesia"=>["An Empty Tome","Malak's Labyrinth"],
- "Super Mario Galaxy"=>["Haunty Halls"],"Super Smash Bros. Brawl"=>["Zelda2"],"Castlevania: Harmony of Dissonance"=>["Successor of Fate","Boss A","Chapel of Dissonance"],"Super Metroid"=>["Item Room"],"Super Mario Bros."=>["Fail","Game Over","Castle"],"New Super Mario Bros."=>["Starman"],"Super Mario RPG"=>["Weapons Factory","Fight Against Culex","Fight Against Monsters"],"Other/Unknown"=>["YkY","level_zameczek"]}
- @soundtest=$config[4][0]
- @bossrush=$config[4][1]
- @bossrush2=$config[4][2]
- end
- def update
- case @state
- when :intro
- return (@state=:main;Snd['Sys5'].play) if Keypress[KbReturn,false]
- when :credits
- return (@state=:main;Snd['Sys3'].play) if Keypress[:shoot,false]
- when :main
- (@select+=1;Snd['Sys1'].play) if Keypress[KbDown,false] and @select<@max
- (@select-=1;Snd['Sys1'].play) if Keypress[KbUp,false] and @select>0
- if Keypress[:jump,false]
- case @select
- when 0
- Snd['Sys2'].play
- @boss=nil
- @state=:saves
- when 1
- Snd['Sys2'].play
- @state=:config
- @select=0
- when 2
- Snd['Sys2'].play
- @state=:credits
- when 3
- Snd['Sys5'].play
- $screen.close
- when 4
- Song.current_song.stop
- Snd['Sys5'].play
- @state=:sound
- @select=0
- when 5
- Song.current_song.stop
- Snd['Sys5'].play
- @state=:boss
- @select=0
- end
- return
- end
- when :saves
- return (@state=:main;@select=0;Snd['Sys3'].play) if Keypress[:shoot,false] and !@save and !@name and !@boss
- return (@state=:boss;@select=@boss-1;Snd['Sys3'].play) if Keypress[:shoot,false] and @boss
- (@select+=1;Snd['Sys1'].play) if Keypress[KbRight,false] and @select<4 and !@save and !@new
- (@select-=1;Snd['Sys1'].play) if Keypress[KbLeft,false] and @select>0 and !@save and !@new
- if @saves[@select]
- (@select2+=1;Snd['Sys1'].play) if Keypress[KbRight,false] and@save and @select2<3 and !@action and !@copy
- (@select2-=1;Snd['Sys1'].play) if Keypress[KbLeft,false] and @save and @select2>0 and !@action and !@copy
- (@select2+=1;Snd['Sys1'].play) if Keypress[KbRight] and @select2==1 and !@saves[@select][:session]
- (@select2-=1;Snd['Sys1'].play) if Keypress[KbLeft] and @select2==1 and !@saves[@select][:session]
- if Keypress[KbRight,false] and @copy and !5.times{|id| if id>@copy and !@saves[id] then @anoth=id ; break end} then Snd['Sys1'].play; @copy=@anoth ; @anoth=nil end
- if Keypress[KbLeft,false] and @copy and !5.times{|id| if id<@copy and !@saves[id] then @anoth=id ; break end} then Snd['Sys1'].play ; @copy=@anoth ; @anoth=nil end
- if Keypress[:jump,false] and !@save
- if @boss
- if @boss==1 && @saves[@select][:clear] or @boss==2 && @saves[@select][:superclear]
- $save=@saves[@select]
- return Game.new(@boss)
- else
- return Snd['Sys4'].play
- end
- end
- Snd['Sys2'].play
- @save=true
- @select2=(@saves[@select][:session] ? 1 : 0)
- elsif Keypress[:jump,false] and !@action
- case @select2
- when 0
- if @saves[@select][:session] and !@saves[@select][:session][2]
- Snd['Sys2'].play
- @action=0
- @question="Suspended game will be erased. Continue?"
- return @choose=true
- else
- Snd['Sys5'].play
- Song.current_song.stop
- $save=@saves[@select]
- Game.new
- end
- when 1
- if !@saves[@select][:session][2]
- Snd['Sys2'].play
- @action=1
- @question="You can continue suspended game only once. Proceed?"
- return @choose=true
- else
- Snd['Sys5'].play
- Song.current_song.stop
- $save=@saves[@select]
- Game.new(true)
- end
- when 2
- Snd['Sys2'].play
- @action=2
- return @question="Deleted save will be gone forever. Are you sure?"
- when 3
- if @saves.compact.length<5 and !@copy
- Snd['Sys2'].play
- @copy=@saves.index(nil)
- elsif @copy
- Snd['Sys2'].play
- @saves[@copy]=@saves[@select].dup
- @saves[@copy][:id]=@copy
- @saves[@copy][:session]=nil
- Marshal.dump(@saves[@copy],f=File.new("data/save#{@copy}",'w'))
- f.close
- @copy=nil
- elsif !@info
- Snd['Sys4'].play
- @info=["No free slot available",60]
- end
- end
- end
- if @save and Keypress[:shoot,false]
- Snd['Sys3'].play
- if @copy
- @copy=nil
- else
- @save=@select2=nil
- end
- end
- if @action and Keypress[KbRight,false]
- Snd['Sys1'].play
- @choose=false
- elsif @action and Keypress[KbLeft,false]
- Snd['Sys1'].play
- @choose=true
- elsif @action and Keypress[:jump,false]
- return (Snd['Sys3'].play;@action=nil) if !@choose
- case @action
- when 0
- Snd['Sys5'].play
- Song.current_song.stop
- $save=@saves[@select]
- @saves[@select][:id]=@select
- Game.new
- when 1
- Snd['Sys5'].play
- Song.current_song.stop
- $save=@saves[@select]
- @saves[@select][:id]=@select
- Game.new(true)
- when 2
- Snd['Sys2'].play
- @saves[@select]=nil
- File.delete("data/save#{@select}")
- @save=@select2=nil
- end
- @action=nil
- elsif @action and Keypress[:shoot,false]
- @action=nil
- end
- else
- if Keypress[:jump,false] and !@new
- Snd['Sys2'].play
- @new=0
- @name=[]
- elsif Keypress[:jump,false] and @new
- Snd['Sys2'].play
- @name<<chars[@new] if @name.length<6
- elsif Keypress[:shoot,false] and @new
- Snd['Sys3'].play
- if @name.length>0
- @name.pop
- else
- @new=@name=nil
- end
- elsif Keypress[KbReturn,false] and @new
- Snd['Sys5'].play
- save={:name=>@name.join,:id=>@select,:events=>[],:area=>0,:areas=>[],:plans=>[],:brekables=>[],:warps=>[[14,29,0,5,0]],:hp=>200,:max_hp=>200,:mp=>100,:max_mp=>100,:mp_regen=>1,:base_mp_regen=>1,:stars=>25,:max_stars=>25,:stomp=>0,:defence=>0,:base_strength=>1,:base_constitution=>1,:base_intelligence=>1,:base_mind=>1,:base_luck=>1,:exp=>0,:next=>80,:all=>0,:level=>1,:coins=>0,:time=>0,:status=>'GOOD',:equip=>[0,nil,nil,0,0,0],:relics=>[],:items=>{:magic=>[],:weapon=>[],:suit=>[],:cap=>[],:pants=>[],:boots=>[],:accessory=>[],:usable=>[],:misc=>[]},:enemies=>{},:bonus=>[],:dimension=>false,:kills=>[],:allkills=>0,:magic=>[],:resistance=>[],:guides=>[],:cores=>[]}
- save[:map]=Marshal.load(f=File.open('data/map','r'))
- f.close
- Marshal.dump(save,f=File.new("data/save#{@select}",'w'))
- f.close
- $save=save
- Game.new
- end
- if @new
- (@new+=1;Snd['Sys1'].play) if Keypress[KbRight,false] and @new<chars.length-1
- (@new-=1;Snd['Sys1'].play) if Keypress[KbLeft,false] and @new>0
- (@new+=20;Snd['Sys1'].play) if Keypress[KbDown,false] and @new<chars.length-20
- (@new-=20;Snd['Sys1'].play) if Keypress[KbUp,false] and @new>19
- end
- end
- when :config
- if !@set
- (@select+=1;Snd['Sys1'].play) if Keypress[KbDown,false] and @select<11
- (@select-=1;Snd['Sys1'].play) if Keypress[KbUp,false] and @select>0
- if Keypress[:jump,false] and @select<9 and !@pressed
- Snd['Sys2'].play
- @set=[:up,:down,:left,:right,:jump,:shoot,:spin,:start,:select][@select]
- elsif Keypress[:jump,false] and @select==9
- Snd['Sys4'].play
- # Snd['Sys2'].play
- # $config[0]=!$config[0]
- elsif Keypress[:jump,false] and @select==10
- Snd['Sys2'].play
- f=File.open('data/config','w')
- Marshal.dump($config,f)
- f.close
- @state=:main
- @select=1
- elsif Keypress[:jump,false] and !@pressed
- Snd['Sys3'].play
- f=File.open('data/config','r')
- $config=Marshal.load(f)
- f.close
- @state=:main
- @select=1
- end
- @pressed=nil
- end
- when :sound
- (@select+=1;Snd['Sys1'].play) if Keypress[KbDown,false] and @select<@music.length-1
- (@select-=1;Snd['Sys1'].play) if Keypress[KbUp,false] and @select>0
- if Keypress[:jump,false] and !@song || @song!=@select
- @song=@select
- Msc[@music[@select],:auto].play(!$premusic)
- elsif Keypress[:jump,false] and @song==@select
- Song.current_song.play(!$premusic)
- end
- Song.current_song.pause if Keypress[:spin,false] and Song.current_song
- $premusic=@song=Song.current_song.stop if Keypress[:shoot,false] and Song.current_song
- if Keypress[KbReturn,false]
- Snd['Sys3'].play
- Msc['Zelda2'].play
- @song=nil
- @select=@max=3
- @state=:main
- end
- when :boss
- if Keypress[:shoot,false]
- Snd['Sys3'].play
- return (@state=:main;@select=4;Msc['Zelda2'].play) if !@highscores and !@prizes
- @prizes=@highscores=nil
- end
- @max=3
- if !@highscores and !@prizes
- (@select+=1;Snd['Sys1'].play) if Keypress[KbDown,false] and @select<@max
- (@select-=1;Snd['Sys1'].play) if Keypress[KbUp,false] and @select>0
- end
- if Keypress[:jump,false] and !@highscores and !@prizes
- case @select
- when 0
- Snd['Sys2'].play
- @boss=1
- @select=0
- @state=:saves
- when 1
- return Snd['Sys4'].play if !@bossrush2
- Snd['Sys2'].play
- @boss=2
- @select=0
- @state=:saves
- when 2
- Snd['Sys2'].play
- @highscores=true
- when 3
- Snd['Sys2'].play
- @prizes=true
- end
- end
- end
- end
- def draw
- case @state
- when :intro
- Img['System/Title Screen'].draw(0,0,0)
- Img['System/Title'].draw(116,64,0)
- Fnt[['System/Font',20,20]].draw("Press Enter",320,440,0,:align=>:center) if $count%60<30
- when :main
- Img['System/Title Screen'].draw(0,0,0)
- Img['System/Title'].draw(116,64,0)
- texts=["Start game","Config","Credits","Quit"]
- texts << "Sound Test" if @soundtest
- texts << "Boss Rush" if @bossrush
- @max=texts.length-1
- texts.length.times{|text| Fnt[['System/Font',20,20]].draw(texts[text],320,240+text*30,0,:align=>:center) if @select != text or $count%30<15}
- when :config
- Img['System/Config Screen'].draw(0,0,0)
- keys=[:up,:down,:left,:right,:jump,:shoot,:spin,:start,:select]
- names=["Up","Down","Left",:"Right","Jump","Shoot","Spin","Menu","Map"]
- texts=["Up - #{key($config[1][:up])}","Down - #{key($config[1][:down])}","Left - #{key($config[1][:left])}","Right - #{key($config[1][:right])}",
- "Jump - #{key($config[1][:jump])}","Shoot - #{key($config[1][:shoot])}","Spin - #{key($config[1][:spin])}","Menu - #{key($config[1][:start])}","Map - #{key($config[1][:select])}",
- $config[0] ? "Fullscreen Mode" : "Windowed Mode","Apply changes","Cancel"]
- texts.length.times{|text| Fnt[['System/Font',20,20]].draw((text<9 and @set==keys[text]) ? "Press key for #{names[text]}" : texts[text],320,60+text*30,0,:align=>:center,:color=>(@select==text ? 0xffffffff : 0x80ffffff))}
- Fnt[['System/Font',20,20]].draw("Restart game to apply #{$config[0] ? "Fullscreen Mode" : "Windowed Mode"}",10,460,0,:xspacing=>15) if $config[0] != $screen.fullscreen?
- Fnt[['System/Font',20,20]].draw("Fullscreen currently not supported :(",10,460,0,:xspacing=>15) if @select==9
- when :credits
- Img['System/Sound Screen'].draw(0,0,0)
- credits=["#Game programming, design","#graphic and sound editing","KoBeWi","#Game engine","Ruby","Gosu",
- "#Graphics","MFGG","$Featured (cuz request)","$Teek","$Theo402","The ShyGuy Kingdom",
- "Spriters Resource","Super Mario Bros. X","LF2 mod by neo_w43","#Sounds","MFGG","Super Mario Bros. X",
- "freesound.org","#Music","KHInsider Soundtracks","(check Sound Test for list of all tracks)"]
- y=28
- credits.each do |crd|
- y+=(crd.include?("#") ? 25 : 15)
- Fnt[['System/Font',20,20]].draw(crd.delete("$#"),crd.include?("$") ? 30 : 10,y,0,:color=>(crd.include?("#") ? 0xffffff00 : 0xffffffff),:scalex=>0.75,:scaley=>0.75)
- end
- when :saves
- Img['System/Save Screen'].draw(0,0,0)
- 5.times{|x| Img['System/Save'].draw(x*128,0,0)
- Fnt[['System/Font',20,20]].draw("State#{x+1}",4+x*128,4,0)
- Fnt[['System/Font',20,20]].draw((@saves[x][:name] if @saves[x]),4+x*128,32,0)}
- Img['System/Savesel'].draw(48+@select*128,72+offset_y($count*8,4),0)
- Img['System/Savesel'].draw(48+@copy*128,72+offset_y($count*8,4),0,1,1,0xff00ffff) if @copy
- if @saves[@select]
- save=(@select2==1 ? @sessions[@select] : @saves[@select])
- Fnt[['System/Font',20,20]].draw(@info[0],32,340,0,:color=>0xffff0000) if @info
- @info=nil if @info and (@info[1]-=1)==0
- time=save[:time]
- txt=[]
- txt << "#{'0' if (t=(time/216000%60).to_i)<10}#{t}"
- txt << "#{'0' if (t=(time/3600%60).to_i)<10}#{t}"
- txt << "#{'0' if (t=(time/60%60).to_i)<10}#{t}"
- Fnt[['System/Font',20,20]].draw("Level #{save[:level]}",32,128,0)
- Fnt[['System/Font',20,20]].draw(areas[save[:area]],32,158,0)
- Fnt[['System/Font',20,20]].draw("Time #{txt.join(':')}",32,188,0)
- Fnt[['System/Font',20,20]].draw("Cleared",32,256,0,:color=>(save[:superclear] ? 0xffff0000 : 0xffffff00)) if save[:clear]
- if @save
- Img['System/Savesel'].draw(48+@select2*128,408+offset_y($count*8,4),0,1,-1)
- Img['System/Action'].draw(0,416,0)
- Fnt[['System/Font',20,20]].draw("Start^game",8,424,0)
- Img['System/Action'].draw(128,416,0) if @saves[@select][:session]
- Fnt[['System/Font',20,20]].draw(@saves[@select][:session][2] ? "Load^quicksave" : "Continue^session",136,424,0,:xspacing=>13) if @saves[@select][:session]
- Img['System/Action'].draw(256,416,0)
- Fnt[['System/Font',20,20]].draw("Delete^save",264,424,0)
- Img['System/Action'].draw(384,416,0)
- Fnt[['System/Font',20,20]].draw("Copy^data",392,424,0)
- if @action
- Fnt[['System/Font',20,20]].draw(@question,320,240,0,:align=>:center,:xspacing=>12)
- Fnt[['System/Font',20,20]].draw("Yes",160,280,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw("No",480,280,0,:align=>:center)
- Img['System/Savesel'].draw(@choose ? 144 : 464,308+offset_y($count*8,4),0)
- end
- end
- else
- if !@new
- Fnt[['System/Font',20,20]].draw("This position is unused",32,128,0)
- else
- Fnt[['System/Font',20,20]].draw("Type your name",320,128,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw(@name.join,120,160,0,:scalex=>2,:scaley=>2)
- Fnt[['System/Font',20,20]].draw('-'*6,120,190,0,:scalex=>2,:scaley=>2)
- chars.length.times{|char| Fnt[['System/Font',20,20]].draw(chars[char],20+(char%20)*30,240+(char/20)*30,0)
- Img['System/Charsel'].draw(14+(char%20)*30,234+(char/20)*30,0) if @new==char}
- Fnt[['System/Font',20,20]].draw("Enter - Accept",20,390,0,:scalex=>0.75,:scaley=>0.75)
- Fnt[['System/Font',20,20]].draw("Jump - Select",20,420,0,:scalex=>0.75,:scaley=>0.75)
- Fnt[['System/Font',20,20]].draw("Shoot - Delete/Cancel",20,450,0,:scalex=>0.75,:scaley=>0.75)
- end
- end
- when :sound
- Img['System/Sound Screen'].draw(0,0,0)
- game=@games.keys.find{|key| @games[key].include?(@music[@select])}
- Fnt[['System/Font',20,20]].draw('Sound Test',320,20,0,:align=>:center,:scalex=>2,:scaley=>2)
- Fnt[['System/Font',20,20]].draw('Game',320,140,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw(game,320,170,0,:align=>:center,:xspacing=>15)
- Fnt[['System/Font',20,20]].draw('Title',320,210,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw(@music[@select],320,240,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw("#{@select+1} / #{@music.length}",320,310,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw('Up/Down - select music',20,360,0)
- Fnt[['System/Font',20,20]].draw('Jump - play/resume',20,380,0)
- Fnt[['System/Font',20,20]].draw('Shoot - stop',20,400,0)
- Fnt[['System/Font',20,20]].draw('Spin - pause',20,420,0)
- Fnt[['System/Font',20,20]].draw('Enter - return to main menu',20,440,0)
- when :boss
- Img['System/Boss Screen'].draw(0,0,0)
- Fnt[['System/Font',20,20]].draw('Boss Rush',320,20,0,:align=>:center,:scalex=>2,:scaley=>2)
- if @highscores
- Fnt[['System/Font',20,20]].draw("Highscores",320,100,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw("Normal Course",320,130,0,:align=>:center,:color=>0xffffff00)
- Fnt[['System/Font',20,20]].draw(@bossrush2 ? 'Chaos Course' : "???",320,270,0,:align=>:center,:color=>0xffffff00)
- $config[2].sort!{|x,y| x[1]<=>y[1]}
- $config[3].sort!{|x,y| x[1]<=>y[1]}
- 5.times do |y|
- Fnt[['System/Font',20,20]].draw($config[2][y] ? "#{time($config[2][y][1])} #{$config[2][y][0]}" : "99:99:99 ???",320,160+y*20,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw($config[3][y] ? "#{time($config[3][y][1])} #{$config[3][y][0]}" : "99:99:99 ???",320,300+y*20,0,:align=>:center)
- end
- elsif @prizes
- Fnt[['System/Font',20,20]].draw("Unlockable Items",320,100,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw("Normal Course",320,270,0,:align=>:center,:color=>0xffffff00)
- Fnt[['System/Font',20,20]].draw("8 minutes - #{$config[4][5] ? 'Starman' : '???'}",320,300,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw("12 minutes - #{$config[4][4] ? 'Noobshot' : '???'}",320,320,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw("16 minutes - #{$config[4][3] ? 'Overlord Boots' : '???'}",320,340,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw("Any - Cool OMeGa Mushroom",320,360,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw(@bossrush2 ? 'Chaos Course' : "???",320,390,0,:align=>:center,:color=>0xffffff00)
- Fnt[['System/Font',20,20]].draw("6 minutes - #{$config[4][6] ? 'Shadow Suit' : '???'}",320,420,0,:align=>:center)
- Fnt[['System/Font',20,20]].draw("Any - 3-UP Moon",320,440,0,:align=>:center)
- else
- texts=['Normal Course',@bossrush2 ? 'Chaos Course' : "???",'Highscores','Unlockables']
- texts.length.times{|text| Fnt[['System/Font',20,20]].draw(texts[text],320,240+text*30,0,:align=>:center) if @select != text or $count%30<15}
- end
- end
- end
- def time(tm)
- txt=[]
- txt << "#{'0' if (t=(tm/3600%60).to_i)<10}#{t}"
- txt << "#{'0' if (t=(tm/60%60).to_i)<10}#{t}"
- txt << "#{'0' if (tm/0.6)%100<10}#{((tm/0.6)%100).to_i}"
- txt.join(":")
- end
- def chars
- ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0','.','/',':','!','@','%','?','_','-',',','<','>','+',"'"]
- end
- def key(id)
- unless defined? @button_names
- button_constants = Gosu.constants(false)
- .grep(/^(?:Gp|Kb|Ms)/)
- .inject({}) { |h, k| h.merge! Gosu.const_get(k) => k }
- @button_names = Hash.new do |names, id|
- ch = $screen.button_id_to_char id
- names[id] = (ch and ch.ord > 0x20) ? ch.upcase : button_constants[id]
- end
- end
- @button_names[id].to_s.reverse.chomp('bK').reverse
- end
- def button_down(id)
- if @set
- Snd['Sys2'].play
- $config[1][@set]=id
- @set=nil
- @pressed=true
- end
- end
- end
- class GameOver
- def initialize
- Msc['Game Over'].play
- end
- def update;end
- def draw
- Img['System/Game Over'].draw(0,0,0)
- end
- def button_down(id)
- $game=MainMenu.new
- end
- end
- class End
- def initialize(good)
- @good=good
- @txt=0
- @percent=(($save[:map].count{|room| room.discovered}/$save[:map].length.to_f)*100).round(2)
- @old=$config[4].dup
- $config[4][0]=true
- $config[4][1]=true
- $config[4][2]=true if @good
- f=File.open('data/config','w')
- Marshal.dump($config,f)
- f.close
- $save[:session]=nil
- $save[:clear]=true
- $save[:superclear]=true if @good
- $save[:hp]=$save[:max_hp]
- Marshal.dump($save,f=File.open("data/save#{$save[:id]}",'w'))
- f.close
- end
- def update
- @txt+=1 if @txt<txt.length
- if @txt==txt.length and Keypress[:jump]
- @stats=true
- end
- if @stats and Keypress[KbReturn]
- $game=MainMenu.new
- end
- end
- def draw
- Img["System/" + (@good ? "Sound Screen" : "Boss Screen")].draw(0,0,0)
- if @stats
- Fnt[['System/Font',20,20]].draw("Final Stats",320,120,1,:align=>:center,:color=>0xffffff00)
- Fnt[['System/Font',20,20]].draw("Time #{time($save[:time])}",320,160,1,:align=>:center)
- Fnt[['System/Font',20,20]].draw("Map #{@percent}%",320,200,1,:align=>:center)
- Fnt[['System/Font',20,20]].draw("Sound test unlocked!",320,240,1,:align=>:center) if @old[0] != $config[4][0]
- Fnt[['System/Font',20,20]].draw("Boss rush unlocked!",320,280,1,:align=>:center) if @old[1] != $config[4][1]
- Fnt[['System/Font',20,20]].draw("Chaos boss course unlocked!",320,320,1,:align=>:center) if @old[2] != $config[4][2]
- Fnt[['System/Font',20,20]].draw("Press Enter",320,440,0,:align=>:center) if $count%60<30
- else
- Fnt[['System/Font',20,20]].draw(txt[0...@txt],60,120,1)
- end
- end
- def txt
- if @good
- "Mario has succeeded in^destroying Castlevania,^banishing it from^Mushroom Kingdom forever.^Bowser has never more^been so powerful, and^stopping his actions^became boring. So from^time to time, Mario^was giving rescuing^mission to Luigi, so two^brothers shared the^princess. And everyone^lived happily ever after.^^Except Bowser."
- else
- "Castlevania remained in^Mushroom Kingdom and^Mario had to live by^the castle. Saving Peach^took him longer each^time and he couldn't^even sleep, because of^noise coming from castle.^Soon, he lost his^sanity and was closed^in Mushroom Asylum.^No one else was capable^of rescuing princess,^so she stayed with Bowser.^^Forever."
- end
- end
- def time(tm)
- txt=[]
- txt << "#{'0' if (t=(tm/216000%60).to_i)<10}#{t}"
- txt << "#{'0' if (t=(tm/3600%60).to_i)<10}#{t}"
- txt << "#{'0' if (t=(tm/60%60).to_i)<10}#{t}"
- txt << "#{'0' if (tm/0.6)%100<10}#{((tm/0.6)%100).to_i}"
- txt.join(":")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement