Class: BMPMap

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-doom.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ BMPMap

Returns a new instance of BMPMap.



757
758
759
760
761
762
# File 'lib/ruby-doom.rb', line 757

def initialize(file)
  @things = Things.new
  @scale_factor = 1
  @thinning_factor = 5
  @bitmap_file = file
end

Instance Attribute Details

#scale_factorObject

Returns the value of attribute scale_factor.



756
757
758
# File 'lib/ruby-doom.rb', line 756

def scale_factor
  @scale_factor
end

#thinning_factorObject

Returns the value of attribute thinning_factor.



756
757
758
# File 'lib/ruby-doom.rb', line 756

def thinning_factor
  @thinning_factor
end

Instance Method Details

#add_commando(p) ⇒ Object



769
770
771
# File 'lib/ruby-doom.rb', line 769

def add_commando(p)
  @things.add_commando p  
end

#add_imp(p) ⇒ Object



772
773
774
# File 'lib/ruby-doom.rb', line 772

def add_imp(p)
  @things.add_imp p  
end

#add_sergeant(p) ⇒ Object



766
767
768
# File 'lib/ruby-doom.rb', line 766

def add_sergeant(p)
  @things.add_sergeant p
end

#add_shotgun(p) ⇒ Object



775
776
777
# File 'lib/ruby-doom.rb', line 775

def add_shotgun(p)
  @things.add_shotgun p
end

#create_wad(filename) ⇒ Object



778
779
780
781
782
783
784
785
786
787
788
# File 'lib/ruby-doom.rb', line 778

def create_wad(filename)
  b = BMPDecoder.new(@bitmap_file)
  b.scale_factor = @scale_factor
  b.thinning_factor = @thinning_factor
  w = Wad.new
  w.lumps << UndecodedLump.new("MAP01")
  w.lumps << @things
  pc = PathCompiler.new(PointsPath.new(b.thin))
  w.lumps.concat(pc.lumps)
  w.write(filename)
end

#set_player(p) ⇒ Object



763
764
765
# File 'lib/ruby-doom.rb', line 763

def set_player(p)
  @things.add_player p
end