Class: VerticalHallway

Inherits:
Hallway show all
Defined in:
lib/hallways/vertical_hallway.rb

Constant Summary collapse

HALLWAY_HEIGHT =
HALLWAYS_LENGTH
HALLWAY_WIDTH =
HALLWAYS_WIDTH

Constants inherited from Hallway

Hallway::HALLWAYS_LENGTH, Hallway::HALLWAYS_WIDTH

Constants inherited from DrawableObject

DrawableObject::BACKGROUND_COLOR, DrawableObject::GRID_COLOR, DrawableObject::SQUARE_SIZE_IN_PIXELS, DrawableObject::TEXT_COLOR

Instance Attribute Summary

Attributes inherited from Hallway

#disabled, #hallway_id, #rooms

Instance Method Summary collapse

Methods inherited from Hallway

#disable!, #initialize, #set_draw_base_room, #to_hash

Constructor Details

This class inherits a constructor from Hallway

Instance Method Details

#draw(gc, base_room, y_decal = 0) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/hallways/vertical_hallway.rb', line 20

def draw( gc, base_room, y_decal = 0 )
  min_x = base_room.min_x + ( Room::ROOM_SQUARE_SIZE/2-1 ) * SQUARE_SIZE_IN_PIXELS
  max_x = min_x + HALLWAY_WIDTH * SQUARE_SIZE_IN_PIXELS

  min_y = base_room.max_y - y_decal
  max_y = min_y + HALLWAY_HEIGHT * SQUARE_SIZE_IN_PIXELS - y_decal

  super( gc, HALLWAY_WIDTH, HALLWAY_HEIGHT, min_x, max_x, min_y, max_y, y_decal: y_decal/2 )
end

#draw_from_base_room(gc) ⇒ Object



30
31
32
# File 'lib/hallways/vertical_hallway.rb', line 30

def draw_from_base_room( gc )
  draw( gc, @draw_base_room )
end

#draw_from_given_room(gc, room, direction) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/hallways/vertical_hallway.rb', line 34

def draw_from_given_room( gc, room, direction )
  if direction == :bottom
    draw( gc, room )
  else
    draw( gc, room, ( Room::ROOM_SQUARE_SIZE ) * SQUARE_SIZE_IN_PIXELS )
  end
end

#get_connected_room(direction) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/hallways/vertical_hallway.rb', line 12

def get_connected_room( direction )
  if direction == :bottom
    @hallway_id[1]
  else
    @hallway_id[0]
  end
end

#get_direction_array(rooms_keys, room) ⇒ Object



8
9
10
# File 'lib/hallways/vertical_hallway.rb', line 8

def get_direction_array( rooms_keys, room )
  super( rooms_keys, room, [ :bottom, :top ] )
end