Module: DungeonDraw

Included in:
Dungeon
Defined in:
lib/dungeon/dungeon_draw.rb

Instance Method Summary collapse

Instance Method Details

#draw(output_file) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dungeon/dungeon_draw.rb', line 3

def draw( output_file )
  assert_dungeon_generated
  width = height = ( @dungeon_size * Room::ROOM_SQUARE_SIZE +
      ( ( @dungeon_size-1 ) * Room::SQUARES_BETWEEN_ROOMS ) ) * Room::SQUARE_SIZE_IN_PIXELS +
      ( Room::ROOM_SQUARE_SIZE * Room::SQUARE_SIZE_IN_PIXELS )

  create_gc( width, height )
  @rooms.each_pair do |_, r|
    r.compute_coords
    r.draw( @gc )
  end
  @hallways.draw_from_base_room @gc
  draw_gc( output_file )
end

#draw_current_room(output_file) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dungeon/dungeon_draw.rb', line 18

def draw_current_room( output_file )
  assert_dungeon_generated
  width = height = ( Room::ROOM_SQUARE_SIZE + Room::SQUARES_BETWEEN_ROOMS * 2 ) * Room::SQUARE_SIZE_IN_PIXELS

  create_gc( width, height )
  @current_room.compute_coords_at_origin
  @current_room.draw( @gc )

  @hallways.draw_hallways_connected_to_given_room_at_origin( @gc, @current_room )

  draw_gc( output_file )
end


31
32
33
34
35
36
37
38
39
40
# File 'lib/dungeon/dungeon_draw.rb', line 31

def print_dungeon( output_file )
  assert_dungeon_generated
  rooms = {}
  @rooms.each do |_, v|
    rooms[ v.id ] = v.to_hash(hallways )
  end
  File.open(output_file,'w') do |f|
    PP.pp(rooms,f)
  end
end