Method: Core::Game::Map#show_path
- Defined in:
- lib/game/map/map.rb
#show_path(anode) ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/game/map/map.rb', line 211 def show_path(anode) #shows the path back from node 'anode' by following the parent pointer curr = anode pathmap = generate_costmap while curr.parent do pathmap[curr.y][curr.x] = '*' curr = curr.parent end pathmap[curr.y][curr.x] = '*' pathstr="" pathmap.each_index do |row| pathmap[row].each_index do |col| pathstr<<"|#{pathmap[row][col]}" end pathstr<<"|\n" end puts(pathstr) end |