 class Direction
   @UP: 0
   @DOWN: 180
-  @LEFT: 90
+  @LEFT: 270
   @RIGHT: 90
   @all: () -> [@UP, @DOWN, @LEFT, @RIGHT]
 

    @destroy() if @energy <= 0
  destroy_area: ->
    switch @direction
      when 0
        new MapArea2D(
          @area.x1 - @default_width/4,
          @area.y1 - @default_height/4,
          @area.x2 + @default_width/4,
          @area.y1
        )
      when 90
        new MapArea2D(
          @area.x2,
          @area.y1 - @default_height/4,
          @area.x2 + @default_width/4,
          @area.y2 + @default_height/4
        )
      when 180
        new MapArea2D(
          @area.x1 - @default_width/4,
          @area.y2,
          @area.x2 + @default_width/4,
          @area.y2 + @default_height/4
        )
      when 270
        new MapArea2D(
          @area.x1 - @default_width/4,
          @area.y1 - @default_height/4,

  _offset_by_direction: (offset) ->
    offset = parseInt(offset)
    switch (@direction)
      when Direction.UP
        [0, - _.min([offset, @area.y1])]
      when Direction.RIGHT
        [_.min([offset, @map.max_x - @area.x2]), 0]
      when Direction.DOWN
        [0, _.min([offset, @map.max_y - @area.y2])]
      when Direction.LEFT
        [- _.min([offset, @area.x1]), 0]

class Terrain extends MapUnit2D
