Class: RogueGenerator
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(width = nil, height = nil, opts = Hash.new) ⇒ RogueGenerator
constructor
A new instance of RogueGenerator.
Methods inherited from Map
Constructor Details
#initialize(width = nil, height = nil, opts = Hash.new) ⇒ RogueGenerator
Returns a new instance of RogueGenerator.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/delve/generator/rogue.rb', line 5 def initialize(width=nil, height=nil, opts=Hash.new) super width, height = { :cell_width => 3, :cell_height => 3, } opts.keys.each do |key| [key] = opts[key] end [:room_width] ||= calculate_room_size width, [:cell_width] [:room_height] ||= calculate_room_size height, [:cell_height] end |
Instance Method Details
#generate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/delve/generator/rogue.rb', line 21 def generate @map = fill 1 @rooms = Array.new @connected_cells = Array.new init_rooms connect_rooms connect_unconnected_rooms create_rooms create_corridors if block_given? (0..@map.length-1).each do |x| (0..@map[0].length-1).each do |y| yield x, y, @map[x][y] end end end end |