Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #0entrance, 1garden, 2waterway, 3distortion, 4corridor, 5pipeline, 6library, 7factory, 8goomba, 9chapel, 10clock, 11bonus, 12catacombs, 13cave,14abyss,15bowser
- class Map
- attr_reader :origin,:data,:id
- def initialize(id)
- $game.map=self
- @data=Marshal.load(f=File.new("data/world/#{id}",'r'))
- f.close
- @masks={}
- @data[:id]=id
- @modifies={}
- @tiles=[]
- @backs=[]
- @data[:objects].reject!{|obj| add(obj)}
- @data[:background][0]="FinalChaos" if @data[:background][0]=="Chaos" and $save[:cores].length==12 || $bossrush && $bossrush[4]==12
- @map=$screen.record(@data[:width]*640,@data[:height]*480){@tiles.each{|tile| tile.draw}}
- @map2=$screen.record(@data[:width]*640,@data[:height]*480){@backs.each{|tile| tile.draw}}
- @tiles=@backs=nil
- end
- def update
- x=@data[:origin][0]*10+$game.player.x.to_i/640*10
- y=@data[:origin][1]*10+$game.player.y.to_i/480*10
- room=$save[:map].find{|r| !r.dimension==!$save[:dimension] and r.x==x and r.y==y}
- if room
- val=((($save[:map].count{|room| room.discovered})/($save[:map].length.to_f-1))*100).round
- $items[:cap][4][:defence]=val**2/100
- end
- room.discover if room
- end
- def draw
- @modifies.each_pair{|mask,modifs| mask.render{modifs.each{|modif| modify_mask2(*modif)}}}
- @modifies.clear
- @map2.draw(-$game.scx,-$game.scy,1)
- @map.draw(-$game.scx,-$game.scy,$distorting ? 1.3 : 2.1)
- scy=$game.scy-((@data[:background][0]=="Sky" or @data[:background][0]=="DarkSky") ? $game.time*(@data[:background][0]=="DarkSky" ? -8 : 8) : 0)
- if File.exists?("data/gfx/backgrounds/#{@data[:background][0]}.png")
- img=Img["backgrounds/#{@data[:background][0]}"]
- (@data[:background][1] ? 640/img.width+2 : 1).times{|x| (@data[:background][2] ? 480/img.height+2 : 1).times{|y|
- if @data[:background][1]
- x1=-(@data[:background][3]*$game.scx+x*img.width).to_i% (img.width*(640/img.width+2))-img.width
- else
- x=-$game.scx*((img.width-640).to_f/(@data[:width]*640-640))
- x1=((x.to_f.nan? or x.to_f.infinite?) ? @data[:background][3] : x+@data[:background][3])
- end
- if @data[:background][2]
- y1=-(@data[:background][4]*scy+y*img.height).to_i% (img.height*(480/img.height+2))-img.height
- else
- y=-scy*((img.height-480).to_f/(@data[:height]*480-480))
- y1=((y.to_f.nan? or y.to_f.infinite?) ? @data[:background][4] : y+@data[:background][4])
- end
- img.draw(x1,y1,0)}}
- end
- end
- def init
- return if @modifies.empty?
- @modifies.each_pair{|mask,modifs| mask.render{modifs.each{|modif| modify_mask2(*modif)}}}
- @modifies.clear
- end
- def modify_mask(x,y,method,value,down=false)
- @modifies[mask(x/640,y/480)]||=[]
- if down
- @modifies[mask(x/640,y/480)].insert 10, [x,y,method,value]
- else
- @modifies[mask(x/640,y/480)]<<[x,y,method,value]
- end
- end
- def modify_mask2(x,y,method,value)
- case method
- when :splice
- img=(value.class==String ? Img[value] : Tls[value[0],value[1],value[2]][value[3]])
- img.draw(x%640,y%480,0)
- when :rect
- $screen.draw_quad(x%640,y%480,value[2],x%640+value[0],y%480,value[2],x%640+value[0],y%480+value[1],value[2],x%640,y%480+value[1],value[2],0)
- end
- end
- def mask(x,y)
- @masks[[x,y]] ||= Ashton::WindowBuffer.new
- @masks[[x,y]]
- end
- def solid?(x,y,down)
- return if !@masks[[x/640,y/480]]
- color=@masks[[x/640,y/480]][x%640,479-y%480]
- return true if color==Color::BLACK
- return true if down and color==Color::GREEN and down==:super || @masks[[x/640,(y-4)/480]][x%640,480 -(y-4)%480]!=Color::GREEN
- end
- def water?(x,y)
- x,y=x.to_i,y.to_i
- if !@masks[[x/640,y/480]]
- color=@masks[[x/640,0]][x%640,479] if y<0 and @masks[[x/640,0]]
- color=@masks[[x/640,@data[:height]-1]][x%640,0] if y>@data[:height]*480-1 and @masks[[x/640,@data[:height]-1]]
- color=@masks[[0,y/480]][0,479-y%480] if x<0 and @masks[[0,y/480]]
- color=@masks[[@data[:width]-1,y/480]][639,479-y%480] if x>@data[:width]*640-1 and @masks[[@data[:width]-1,y/480]]
- else
- color=@masks[[x/640,y/480]][x%640,479-y%480]
- end
- return true if color==Color::BLUE
- end
- def add(obj)
- case obj.type
- when :tile
- @tiles << Tile.new(obj.x,obj.y,*obj.args)
- when :waypoint
- Waypoint.new(obj.x,obj.y,*obj.args)
- when :back
- @backs << Background.new(obj.x,obj.y,*obj.args)
- when :pipe
- @tiles << Pipe.new(obj.x,obj.y,*obj.args)
- when :item
- BonusBlock.new(obj.x,obj.y,*obj.args)
- when :tunnel
- Tunnel.new(obj.x,obj.y,*obj.args)
- when :bonus
- Bonus.new(obj.x,obj.y,*obj.args)
- when :breakable
- Breakable.new(obj.x,obj.y,*obj.args)
- when :switchable
- Switchable.new(obj.x,obj.y,*obj.args)
- when :destructible
- Destructible.new(obj.x,obj.y,*obj.args)
- when :guide
- Guide.new(obj.x,obj.y,*obj.args)
- when :ice
- Ice.new(obj.x,obj.y,*obj.args)
- when :water
- Water.new(obj.x,obj.y,*obj.args)
- when :aback
- Aback.new(obj.x,obj.y,*obj.args)
- when :rwater
- RunningWater.new(obj.x,obj.y,*obj.args)
- when :relic
- RelicBox.new(obj.x,obj.y,*obj.args)
- when :bricks
- Bricks.new(obj.x,obj.y,*obj.args)
- when :belt
- Belt.new(obj.x,obj.y,*obj.args)
- when :cape
- CapeTri.new(obj.x,obj.y,*obj.args)
- when :fall
- Fall.new(obj.x,obj.y,*obj.args)
- when :cog
- Cog.new(obj.x,obj.y,*obj.args)
- when :spikes
- Spikes.new(obj.x,obj.y,*obj.args)
- when :pendulum
- Pendulum.new(obj.x,obj.y,*obj.args)
- when :portal
- Portal.new(obj.x,obj.y,*obj.args)
- when :lava
- Lava.new(obj.x,obj.y,*obj.args)
- when :qsave
- QuickSave.new(obj.x,obj.y,*obj.args)
- when :donut
- Donut.new(obj.x,obj.y,*obj.args)
- when :goomba
- Goomba.new(obj.x,obj.y,*obj.args)
- when :gktroopa
- GKTroopa.new(obj.x,obj.y,*obj.args)
- when :peeps
- Peeps.new(obj.x,obj.y,*obj.args)
- when :spiny
- Spiny.new(obj.x,obj.y,*obj.args)
- when :rktroopa
- RKTroopa.new(obj.x,obj.y,*obj.args)
- when :mmole
- MontyMole.new(obj.x,obj.y,*obj.args)
- when :nninji
- NNinji.new(obj.x,obj.y,*obj.args)
- when :yptroopa
- YPTroopa.new(obj.x,obj.y,*obj.args)
- when :rex
- Rex.new(obj.x,obj.y,*obj.args)
- when :swooper
- Swooper.new(obj.x,obj.y,*obj.args)
- when :blaster
- Blaster.new(obj.x,obj.y,*obj.args)
- when :cheepcheep
- CheepCheep.new(obj.x,obj.y,*obj.args)
- when :spinycheep
- SpinyCheepCheep.new(obj.x,obj.y,*obj.args)
- when :skeeter
- Skeeter.new(obj.x,obj.y,*obj.args)
- when :sushi
- Sushi.new(obj.x,obj.y,*obj.args)
- when :bbeetle
- BuzzyBeetle.new(obj.x,obj.y,*obj.args)
- when :hcrab
- HuckitCrab.new(obj.x,obj.y,*obj.args)
- when :pplant
- PPlant.new(obj.x,obj.y,*obj.args)
- when :iplant
- IPlant.new(obj.x,obj.y,*obj.args)
- when :mplant
- MPlant.new(obj.x,obj.y,*obj.args)
- when :venusft
- VenusFT.new(obj.x,obj.y,*obj.args)
- when :charginchk
- CharginChuck.new(obj.x,obj.y,*obj.args)
- when :hammerbro
- HammerBro.new(obj.x,obj.y,*obj.args)
- when :reboundbro
- ReboundBro.new(obj.x,obj.y,*obj.args)
- when :firebro
- FireBro.new(obj.x,obj.y,*obj.args)
- when :banzai
- BanzaiBill.new(obj.x,obj.y,*obj.args)
- when :fang
- Fang.new(obj.x,obj.y,*obj.args)
- when :mecha
- MechaP.new(obj.x,obj.y,*obj.args)
- when :sniper
- SniperKoopa.new(obj.x,obj.y,*obj.args)
- when :vspiny
- VenomSpiny.new(obj.x,obj.y,*obj.args)
- when :pbeetle
- PanzerBeetle.new(obj.x,obj.y,*obj.args)
- when :bptroopa
- BPTroopa.new(obj.x,obj.y,*obj.args)
- when :hgoomba
- HolyGoomba.new(obj.x,obj.y,*obj.args)
- when :shyguy
- ShyGuy.new(obj.x,obj.y,*obj.args)
- when :engine
- Engine.new(obj.x,obj.y,*obj.args)
- when :chomp
- ChainChomp.new(obj.x,obj.y,*obj.args)
- when :bomb
- Bobomb.new(obj.x,obj.y,*obj.args)
- when :parabeetle
- Parabeetle.new(obj.x,obj.y,*obj.args)
- when :paragoomba
- Paragoomba.new(obj.x,obj.y,*obj.args)
- when :firechomp
- FireChomp.new(obj.x,obj.y,*obj.args)
- when :flybro
- AFHB.new(obj.x,obj.y,*obj.args)
- when :ninji
- Ninji.new(obj.x,obj.y,*obj.args)
- when :pokey
- Pokey.new(obj.x,obj.y,*obj.args)
- when :vlotus
- VLotus.new(obj.x,obj.y,*obj.args)
- when :boomerangbro
- BoomerangBro.new(obj.x,obj.y,*obj.args)
- when :boo
- Boo.new(obj.x,obj.y,*obj.args)
- when :bigboo
- BigBoo.new(obj.x,obj.y,*obj.args)
- when :srat
- SRat.new(obj.x,obj.y,*obj.args)
- when :fishin
- Fishin.new(obj.x,obj.y,*obj.args)
- when :drybo
- DryBones.new(obj.x,obj.y,*obj.args)
- when :bony
- BonyBeetle.new(obj.x,obj.y,*obj.args)
- when :magi
- Magikoopa.new(obj.x,obj.y,*obj.args)
- when :necro
- Necrokoopa.new(obj.x,obj.y,*obj.args)
- when :priest
- Priest.new(obj.x,obj.y,*obj.args)
- when :ball
- SpEgg.new(obj.x,obj.y,*obj.args)
- when :lakitu
- Lakitu.new(obj.x,obj.y,*obj.args)
- when :stony
- Stony.new(obj.x,obj.y,*obj.args)
- when :giant
- KoopaGiant.new(obj.x,obj.y,*obj.args)
- when :nyan
- Nyan.new(obj.x,obj.y,*obj.args)
- when :scuttle
- Scuttle.new(obj.x,obj.y,*obj.args)
- when :dinot
- DinoTorch.new(obj.x,obj.y,*obj.args)
- when :dinof
- DinoTorch.new(obj.x,obj.y,true)
- when :thwomp
- Thwomp.new(obj.x,obj.y)
- when :podoboo
- Podoboo.new(obj.x,obj.y)
- when :titan
- Titan.new(obj.x,obj.y,*obj.args)
- when :chainsaw
- Chainsaw.new(obj.x,obj.y,*obj.args)
- when :snift
- Snift.new(obj.x,obj.y,*obj.args)
- when :wiggler
- Wiggler.new(obj.x,obj.y,*obj.args)
- when :piano
- MadPiano.new(obj.x,obj.y,*obj.args)
- when :outoo
- Outoo.new(obj.x,obj.y,*obj.args)
- when :clearbo
- ClearBones.new(obj.x,obj.y,*obj.args)
- when :skycheep
- SkyCheep.new(obj.x,obj.y,*obj.args)
- when :shadow
- ShadowBro.new(obj.x,obj.y,*obj.args)
- when :llotus
- LLotus.new(obj.x,obj.y,*obj.args)
- when :poiskey
- Poisonkey.new(obj.x,obj.y,*obj.args)
- when :mine
- Mine.new(obj.x,obj.y,*obj.args)
- when :chaincheep
- ChainCheep.new(obj.x,obj.y,*obj.args)
- when :novaboo
- Novaboo.new(obj.x,obj.y,*obj.args)
- when :mecha2
- MechaP2.new(obj.x,obj.y,*obj.args)
- when :sparky
- Sparky.new(obj.x,obj.y,*obj.args)
- when :master
- Master.new(obj.x,obj.y,*obj.args)
- when :reznor
- Reznor.new(obj.x,obj.y,*obj.args)
- when :darkstar
- DarkStar.new(obj.x,obj.y,*obj.args)
- when :muncher
- Muncher.new(obj.x,obj.y,*obj.args)
- when :fuzzy
- Fuzzy.new(obj.x,obj.y,*obj.args)
- when :vase
- Vase.new(obj.x,obj.y,*obj.args)
- when :mad
- MadBlock.new(obj.x,obj.y,*obj.args)
- when :sorcerer
- Sorckoopa.new(obj.x,obj.y,*obj.args)
- when :phanto
- Phanto.new(obj.x,obj.y,*obj.args)
- when :zombie
- Yoshi.new(obj.x,obj.y,*obj.args)
- when :ptooie
- Ptooie.new(obj.x,obj.y,*obj.args)
- end
- end
- def add_tile(tile) @tiles << tile;end
- def music(area)
- @data[:music]=true
- Msc[["Dracula's Castle","Platinum Moonlight","Nightmare",["Crucifix Held Close","Iron Blue Intention","Successor of Fate","Malak's Labyrinth","The Abyss"][music2],"An Empty Tome","YkY","Haunty Halls","Weapons Factory","Castle","Chapel of Dissonance","Clock Tower","Starman","Awake","Forbidden Area","The Abyss","level_zameczek"][area],:auto].play(!$premusic)
- end
- def music2
- $save[:dimension] ? [2,1,3,nil,2,0,0,1,nil,2,1,nil,3,3,4,0][$save[:dimension]] : 0
- end
- end
- class Tile < Entity
- def initialize(x,y,tileset,id)
- @x,@y,@tileset,@id=x,y,tileset,id
- if $save[:dimension] and ['t','r1','r2'].include? $game.map.data[:id]
- @tileset='Dark'+tileset
- end
- splice
- end
- def draw
- Tls["Tiles/#{@tileset}",32,32][@id].draw(@x,@y,$distorting ? 1.3 : 2.1)
- end
- def splice;$game.map.modify_mask(@x,@y,:splice,["Tiles/#{@tileset}-mask".sub('Dark',''),32,32,@id]);end
- def unsplice;$game.map.modify_mask(@x,@y,:rect,[32,32,0xffffffff]);end
- end
- class Pipe < Entity
- def initialize(x,y,layout,color)
- @x,@y,@layout,@color=x,y,layout,color
- splice
- init if color==:rainbow
- end
- def draw
- if @color==:rainbow
- 2.times{|x| 2.times{|y| Tls['Objects/Pipes',32,32][layout[x+y*2]].draw(@x+x*32,@y+y*32,2.1,1,1,Color.from_hsv($game.time%360,1,1));Tls['Objects/Pipes-const',32,32][layout[x+y*2]].draw(@x+x*32,@y+y*32,2)}}
- else
- 2.times{|x| 2.times{|y| Tls['Objects/Pipes',32,32][layout[x+y*2]].draw(@x+x*32,@y+y*32,2,1,1,Color.new(*@color));Tls['Objects/Pipes-const',32,32][layout[x+y*2]].draw(@x+x*32,@y+y*32,2)}}
- end
- end
- def splice
- 2.times{|x| 2.times{|y| $game.map.modify_mask(@x+x*32,@y+y*32,:splice,['Objects/Pipes-mask',32,32,layout[x+y*2]])}}
- end
- def layout;[[2,3,8,9],[8,9,8,9],[8,9,32,33],[12,13,18,19],[13,13,19,19],[13,17,19,23],[14,15,20,21],[16,22,26,27],[14,9,20,9],[8,15,8,21],[13,13,26,27],[16,22,19,19],[0,1,6,7],[4,5,10,11],[24,25,30,31],[28,29,34,35]][@layout];end
- end
- class Obj
- attr_reader :x,:y,:type,:args
- end
- class Waypoint < Entity
- attr_accessor :target
- def initialize(x,y,horizontal,target,path=nil)
- @x,@y,@horizontal,@target,@path=x,y,horizontal,target,path
- @target="#{@target}a" if $save[:dimension] and target.class!=String
- @unstoppable=true
- init
- end
- def update
- spec=(@target.class==String && @target.length==1 or @path)
- old=[$game.map.data[:origin][0]+$game.player.x.to_i/640,$game.map.data[:origin][1]+$game.player.y.to_i/480] if spec
- if !@horizontal and $game.player.y.between?(@y,@y+480) and (pos1=(@x==$game.map.data[:width]*640-32)) && $game.player.x>$game.map.data[:width]*640 || @x==0 && $game.player.x<0
- $game.way=self
- elsif @horizontal and $game.player.x.between?(@x,@x+640) and (pos1=(@y==$game.map.data[:height]*480-32)) && $game.player.y>$game.map.data[:height]*480 || @y==0 && $game.player.y<0
- $game.way=self
- end
- end
- def way
- spec=(@target.class==String && @target.length==1 or @path)
- old=[$game.map.data[:origin][0]+$game.player.x.to_i/640,$game.map.data[:origin][1]+$game.player.y.to_i/480] if spec
- if !@horizontal
- pos1=(@x==$game.map.data[:width]*640-32)
- $game.map.music($save[:area]) if ['s','t'].include?($game.map.data[:id]) if !Song.current_song
- $game.map.music($save[:area]) if $game.map.data[:id]=='!'
- origin=$game.map.data[:origin][1]
- last=$game.map.data[:id]
- $game.reset(@target)
- $game.player.y+=(origin-((spec && !@path || @target=='b') ? origin+$game.player.y.to_i/480 : $game.map.data[:origin][1]))*480
- $game.player.x=(pos1 ? 0 : $game.map.data[:width]*640)
- if @target=='s'
- Save.new
- $game.map.data[:origin][0]=old[0]
- $game.map.data[:origin][1]=old[1]
- Waypoint.new(pos1 ? 0 : 608,0,false,last)
- 2.times{|x| 4.times{|y| $game[Tile.new((pos1 ? 576 : 0)+x*32,192+y*32,'Castle',(x==0 ? 0 : 2)+[0,7,7,14][y])]}}
- elsif @target=='t'
- $game.map.data[:origin][0]=old[0]
- $game.map.data[:origin][1]=old[1]
- w=Waypoint.new(pos1 ? 0 : 608,0,false,last)
- 2.times{|x| 4.times{|y| $game[Tile.new((pos1 ? 576 : 0)+x*32,192+y*32,'Castle',(x==0 ? 0 : 2)+[0,7,7,14][y])]}}
- $save[:warps] << [old[0],old[1],w.x,w.target,$save[:area]] if !$save[:dimension] and !$save[:warps].include?([old[0],old[1],w.x,w.target,$save[:area]])
- Warp.new
- elsif @target=='!'
- $premusic=nil
- Msc['Item Room'].play(true)
- ESwitch.new([183,97,77,210,169].index(last))
- $game.map.data[:origin][0]=old[0]
- $game.map.data[:origin][1]=old[1]
- Waypoint.new(pos1 ? 0 : 608,0,false,last)
- 2.times{|x| 3.times{|y| $game[Tile.new((pos1 ? 576 : 0)+x*32,224+y*32,'Castle',(x==0 ? 0 : 2)+[0,7,14][y])]}}
- elsif @target=='b'
- $game.map.data[:origin][0]=old[0]
- $game.map.data[:origin][1]=old[1]
- Waypoint.new(pos1 ? 0 : 608,0,false,last)
- 3.times{|y| $game[Tile.new(pos1 ? 608 : 0,288+y*32,'Castle',pos1 ? 25 : 27)]}
- if !$save[:cores].include?(last) or $bossrush
- Song.current_song.stop if Song.current_song
- $premusic=nil
- BossDoor.new(pos1 ? 0 : 608,288,true)
- Core.new
- Msc['Piercing Silence',true].play if $save[:cores].length<12 or $bossrush && $bossrush[4]<12
- Song.current_song.stop if $save[:cores].length==12 and !$bossrush || $bossrush[4]==12
- end
- $save[:map].find{|room| !room.dimension==!$save[:dimension] and room.x==(old[0]+(pos1 ? -1 : 1))*10 and room.y==old[1]*10}.setwall(pos1 ? 1 : 3,2) if @path
- else
- $game.came=[$game.player.x,$game.player.y]
- $game.map.music(3) if last=='b' and !Song.current_song
- $save[:map].find{|room| !room.dimension==!$save[:dimension] and room.x==(old[0]+(pos1 ? -1 : 1))*10 and room.y==old[1]*10}.setwall(pos1 ? 1 : 3,2) if @path
- end
- if $save[:dimension] and !$save[:areas].include?(3)
- $game.area=["Dimensional Distortion",120]
- $save[:areas] << 3
- end
- elsif @horizontal
- pos1=(@y==$game.map.data[:height]*480-32)
- origin=$game.map.data[:origin][0]
- last=$game.map.data[:id]
- $game.reset(@target)
- $game.player.x+=(origin-((spec and !@path) ? origin+$game.player.x.to_i/640 : $game.map.data[:origin][0]))*640
- $game.player.y=(pos1 ? 0 : $game.map.data[:height]*480)
- $game.came=[$game.player.x,$game.player.y]
- $save[:map].find{|room| !room.dimension==!$save[:dimension] and room.x==old[0]*10 and room.y==(old[1]+(pos1 ? -1 : 1))*10}.setwall(pos1 ? 2 : 0,2) if @path
- end
- $game.way=nil
- $game.screen
- end
- end
- class Background < Entity
- def initialize(x,y,name)
- @x,@y,@name=x,y,name
- end
- def draw
- Img["Back/#{@name}"].draw(@x,@y,1)
- end
- end
- class Tunnel < Entity
- attr_reader :target,:dir,:id
- def initialize(x,y,dir,target,id)
- @x,@y,@dir,@target,@id=x,y,dir,target,id
- init
- end
- def update
- if !$game.player.warping?(true) and !@warping and Keypress[@dir] and (@dir==:right && $game.player.x>@x && $game.player.x<@x+64 || @dir==:left && $game.player.x<@x+32 && $game.player.x>@x-64 and $game.player.y.between?(@y,@y+32)) || (@dir==:down && $game.player.y>@y && $game.player.y<@y+64 || @dir==:up && $game.player.y<@y+48 && $game.player.y>@y-64 and $game.player.x.between?(@x,@x+32))
- Snd['Warp'].play
- $game.player.warp(@dir)
- @warping=true
- $game.player.y=@y+24 if [:left,:right].include?(@dir)
- $game.player.x=@x+16 if [:up,:down].include?(@dir)
- $game.player.vx=$game.player.vy=0
- elsif @warping and !$game.player.warping?
- if @target=='c' and $game.map.data[:id] != 'c'
- Song.current_song.stop
- old=$game.map.data[:id]
- orig=[$game.map.data[:origin][0]+$game.player.x.to_i/640,$game.map.data[:origin][1]+$game.player.y.to_i/480]
- $premusic=nil
- $game.reset('c')
- Tunnel.new(128,240,:left,'c',@dir==:right ? old : @id)
- Tunnel.new(480,240,:right,'c',@dir==:left ? old : @id)
- exit=$game.entities[0].find{|ent| ent.class==Tunnel and ent.dir==[:up,:right,:left,:down][[:down,:left,:right,:up].index(@dir)]}
- $game.player.x=(@dir==:right ? 128 : 512)
- $game.player.y=exit.y+24
- $game.map.data[:origin]=orig
- orig[0]+=(@dir==:right ? 1 : -1)
- elsif @target=='c'
- $game.reset(@id)
- exit=$game.entities[0].find{|ent| ent.class==Tunnel and ent.target=='c'}
- $game.player.x=exit.x+(@dir==:left ? 32 : -16)
- $game.player.y=exit.y+24
- region={10=>1,9=>0,27=>4,25=>0,26=>0,28=>2,44=>5,43=>2,61=>4,60=>5,66=>4,67=>6,71=>7,70=>4,92=>9,91=>8,115=>7,116=>10,121=>1,120=>10,142=>12,141=>4,157=>9,156=>10,163=>13,162=>5,176=>14,175=>13,103=>0,211=>15}
- $save[:area]=region[@id]
- $game.map.music(region[@id])
- if !$save[:areas].include?(region[@id])
- $game.area=[areas[region[@id]],120]
- $save[:areas] << region[@id]
- end
- else
- ($game.reset(@target) ; @exit=true) if @target!=$game.map.data[:id]
- exit=$game.entities[0].find{|ent| ent.class==Tunnel and ent.id==@id and ent != self}
- $game.player.x=exit.x+[16,48,16,-16][[:up,:right,:down,:left].index(exit.dir)]
- $game.player.y=exit.y+[-24,24,72,24][[:up,:right,:down,:left].index(exit.dir)]
- end
- Snd['Warp'].play
- $game.player.warp([:up,:right,:left,:down][[:down,:left,:right,:up].index(exit.dir)],(@target=='c' or @exit))
- @warping=@exit=nil
- end
- end
- end
- class Water < Entity
- def initialize(x,y,surface)
- @x,@y,@surface=x,y,surface
- $game.map.modify_mask(@x,@y+(@surface ? 16 : 0),:rect,[32,@surface ? 16 : 32,0xff0000ff])
- init
- end
- def draw
- return if @x>$game.scx+640 or @x+32<$game.scx or @y>$game.scy+480 or @y+32<$game.scy
- Tls["Objects/#{'Dark' if $save[:dimension]}Water",32,32][@surface ? $game.time/8%4 : 4].draw(@x,@y,2.05,1,1,0xc0ffffff)
- end
- end
- class RunningWater < Entity
- def initialize(x,y,surface,speed)
- @x,@y,@surface,@speed=x,y,surface,speed
- $game.map.modify_mask(@x,@y+(@surface ? 16 : 0),:rect,[32,@surface ? 16 : 32,0xff0000ff])
- init
- end
- def draw
- return if @x>$game.scx+640 or @x+32<$game.scx or @y>$game.scy+480 or @y+32<$game.scy
- if $game.player.x.between?(@x-16,@x+48) and $game.player.y.between?(@y-20,@y+16)
- $game.player.x+=@speed*0.5 if not @speed<0 && $game.player.left || @speed>0 && $game.player.right
- end
- if @surface
- $screen.clip_to(@x,@y,32,32){2.times{|x|
- Tls["Objects/RunningWater",32,32][$count/8%4].draw(@x+$count*@speed%32-x*32,@y,2.05,1,1,0xc0ffffff)}}
- else
- Tls["Objects/RunningWater",32,32][4].draw(@x,@y,2.05,1,1,0xc0ffffff)
- end
- end
- end
- class Lava < Entity
- def initialize(x,y,surface,over=nil)
- @x,@y,@surface,@over=x,y,surface,over
- $game.map.modify_mask(@x,@y+(@surface ? 16 : 0),:rect,[32,@surface ? 16 : 32,0xff0000ff],true)
- init
- end
- def draw
- if !$game.gameover and !$game.player.inv and $game.player.x.between?(@x-16,@x+48) and $game.player.y.between?(@y-20,@y+16)
- $save[:hp]-=1
- if $count % 8 == 0
- Snd["MarioDamage#{1+rand(5)}"].play
- Snd['Fizz'].play
- Info.new($game.player.x-7,$game.player.y-40,8,"Damage1")
- end
- end
- Tls["Objects/Lava",32,32][@surface ? $count/8%4 : 4].draw(@x,@y,@over ? 2.5 : 2.05,1,1,0xf0ffffff)
- end
- end
- class Aback < Entity
- def initialize(x,y,name)
- @x,@y=x,y
- name=Dir.entries('data/gfx/aback').find{|img| img.chop.chop.chop.chop.chop.chop==name}
- return if !name
- 4.times{name.chop!}
- @size=name.split('-')[1].to_i
- @name='Aback/'+name
- tile=Tls[@name,-@size,-1][0]
- @width=tile.width
- @height=tile.height
- init
- end
- def draw
- return if @x>$game.scx+640 or @x+@width<$game.scx or @y>$game.scy+480 or @y+@height<$game.scy
- Tls[@name,-@size,-1][$game.time/8% @size].draw(@x,@y,1)
- end
- end
- class Fall < Entity
- def initialize(x,y)
- @x,@y=x,y
- @unstoppable=true
- init
- end
- def update
- @player=[$game.player.x,$game.player.y] if !@player
- @player=[$game.player.x,$game.player.y] if $game.player.down?
- if $game.player.x.between?(@x,@x+640) and $game.player.y>$game.map.data[:height]*480+64
- if ($save[:hp]-=$save[:max_hp]/8)>0
- Snd['MarioDamage4'].play
- $game.player.x=@player[0]
- $game.player.y=@player[1]
- $game.player.vx=$game.player.vy=0
- $game.player.inv=60
- end
- end
- end
- def draw
- $screen.draw_quad(@x,@y,c=0x00000000,@x+640,@y,c,@x+640,@y+32,c=0xff000000,@x,@y+32,c,1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement