Module: UpdateMap

Included in:
Maze
Defined in:
lib/helper_tools/update_map.rb

Instance Method Summary collapse

Instance Method Details

#place_character(alt_map = nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/helper_tools/update_map.rb', line 11

def place_character(alt_map=nil)
  if alt_map
    alt_map[current_square[0]][current_square[1]] = character
  else
    presenting_map[current_square[0]][current_square[1]] = character
  end
end


19
20
21
# File 'lib/helper_tools/update_map.rb', line 19

def print_map(map_array=nil)
  (map_array || presenting_map).each { |row| puts row.join("") }
end

#reset_mapObject



6
7
8
# File 'lib/helper_tools/update_map.rb', line 6

def reset_map
  self.presenting_map = dup_map
end

#reset_screenObject



2
3
4
# File 'lib/helper_tools/update_map.rb', line 2

def reset_screen
  print "\e[2J\e[H"
end

#update_and_printObject



23
24
25
26
27
28
# File 'lib/helper_tools/update_map.rb', line 23

def update_and_print
  reset_screen
  reset_map
  place_character
  print_map 
end