summaryrefslogtreecommitdiff
path: root/lib/terrain.rb
blob: f3a1a606ca59d9592f74638aea070b38f80e960b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
class Terrain
  def initialize(edge_of_map)
    @map = edge_of_map
  end

  def move_forward( heading, location)
    new_location = heading.forward(location.clone)
    if( new_location[:x] < @map[:x] && new_location[:x] > 0 && new_location[:y] < @map[:y] && new_location[:y] > 0)
      location[:x] = new_location[:x]
      location[:y] = new_location[:y]
    end
  end
end