Class: RDGC::Map::Room

Inherits:
Area
  • Object
show all
Defined in:
lib/rdgc/map/room.rb

Constant Summary

Constants included from TileType

TileType::OUT, TileType::ROAD, TileType::ROOM, TileType::WALL

Instance Attribute Summary

Attributes inherited from Area

#bottom, #left, #right, #top

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Area

#blind_level, #blind_level_blind?, #blind_level_dark?, #blind_level_none?, #blind_level_open?, #coordinates, #each, #each_tile, #each_x, #each_y, #fill_tile, #has_xy?, #height, #random_point, #set_blind, #set_tile, #tile, #width

Class Method Details

.create(top, bottom, left, right) ⇒ Object



6
7
8
9
10
# File 'lib/rdgc/map/room.rb', line 6

def self.create(top, bottom, left, right)
  room = super(top, bottom, left, right)
  room.fill
  room
end

.create_from_block(b, opt = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/rdgc/map/room.rb', line 12

def self.create_from_block(b, opt = nil)
  room_w = room_size(b.width, opt)
  room_h = room_size(b.height, opt)
  return if (room_w <= 0 || room_h <= 0)

  l_point = b.left+1 + room_point(b.width, room_w)
  t_point = b.top+1 + room_point(b.height, room_h)

  self.create(t_point, t_point + room_h - 1, l_point, l_point + room_w - 1)
end

Instance Method Details

#fillObject



23
24
25
26
# File 'lib/rdgc/map/room.rb', line 23

def fill
  fill_tile TileType::ROOM
  self
end