   ])
   battle_field.add_terrain(HomeTerrain, 240, 480)
 
+  document.battle_field = battle_field
+
   ui = new UI(battle_field)
   # ui.reset_zindex()
 


class Missile extends MovableBattleFieldObject
  power: 1
  speed: -> super() * 4
  set_power: (@power) ->
  set_direction: (@direction) ->
  set_belongs_to: (@belongs_to) ->
  type: -> 'missile'
  update: ->
    super()
    # if collide with other object, then explode
    destory_area = @destory_area()
    # START HERE
    # @explode() unless _.every(destory_area, () -> )

    # objects = @battle_field.find_objects_at(@destroy_area())

  exploded: false
  explode: ->
    # bom!
    @exploded = true

  # handle_move: (order, delta_time) ->
  #   super(order, delta_time)
  destroy_area: ->
    [x, y] = [@x(), @y()]
    switch @direction
      when 0
        [
          x - @battle_field.default_width / 4,
          y - (@battle_field.default_height / 4) - 1,
          x + @battle_field.default_width / 4,
          y - @battle_field.default_height / 4
        ]
      when 90
        [
          x + @battle_field.default_width / 4,
          y - @battle_field.default_height / 4,
          x + (@battle_field.default_width / 4) + 1,
          y + @battle_field.default_height / 4
        ]
      when 180
        [
          x - @battle_field.default_width / 4,
          y + @battle_field.default_height / 4,
          x + @battle_field.default_width / 4,
          y + (@battle_field.default_height / 4) + 1
        ]
      when 270
        [
          x - (@battle_field.default_width / 4) - 1,
          y - @battle_field.default_height / 4,
          x - @battle_field.default_width / 4,
          y + @battle_field.default_height / 4
        ]

class Gift extends BattleFieldObject


class GrassTerrain extends Terrain
  enterable: (battle_field_object) -> true
  type: -> "grass"
  layer: 2

