     when 'k' then me.moveUp()
     when 'l' then me.moveRight()
   entity.moveTowards me for entity in entities
+  checkForCollisions()
 
 charm.removeAllListeners('^C')
 charm.on '^C', ->

  charm.position(0, rows).foreground(message_color).write(current_message)

class Entity
  constructor: (@character, @color) ->
  show: ->
    charm.position( @x, @y ).foreground( @color ).write @character
  moveLeft: -> @x = Math.max 1, @x-1
  moveDown: -> @y = Math.min rows-2, @y+1
  moveUp: -> @y = Math.max 1, @y-1
  moveRight: -> @x = Math.min cols, @x+1
  moveTowards: (other) ->
    xd = @x - other.x
    yd = @y - other.y
    xda = Math.abs xd

  e '¥', 'red', 14, 17
]

checkForCollision = (left, right) ->
  if left.x is right.x and left.y is right.y
    left.die()
    right.die()
    wreckage = e '*', 'yellow', left.x, left.y
    wreckage.die = wreckage.moveTowards = ->
    entities.push wreckage

checkForCollisions = ->
  for i in [0...entities.length]
    checkForCollision me, entities[i]
    for j in [i+1...entities.length]
      checkForCollision entities[i], entities[j]

redraw = ->
  charm.erase 'screen'
  entity.show() for entity in entities
  me.show()
  show_message()
  charm.position( cols-1, rows-1 )

setInterval redraw, 100

game_over = no
exiting = no

do_exit = (chr) ->
  unless exiting
    exiting = yes
    message "#{chr} again to quit...",'cyan'
