 class MoveCommand
   constructor: (@movedir) ->
 
+  movePoint: (pos) ->
+    return x: pos.x + @movedir.dx, y: pos.y + @movedir.dy
+
   render: (ctx) ->
     ctx.save()
     g.setStyle(ctx, g.lined_style)
-    g.renderArrow(ctx, @movedir, g.inner_command_size)
+    g.renderArrow(ctx, @movedir.theta, g.inner_command_size)
     ctx.restore()
 
 window.Dwim = Dwim

        dir.theta
      )

  moveBotTo: (x, y, dir) ->
    # check borders
    if x < 0 or y < 0 or x >= @Wi or y >= @Hi
      return false

    @botx = x
    @boty = y
    @botdir = dir

    return true


class Program
  constructor: (@instructions) ->

  render: (ctx) ->
    cs = g.command_size

    ctx.save()
    g.setStyle(ctx, g.thick_lined_style)

    ctx.translate(cs/2, cs/2)

    for instruction in @instructions
      g.renderShape(ctx, instruction, g.inner_command_size/2)
      ctx.translate(0, cs)

    ctx.restore()

class Mapping
  constructor: (@symbol_names) ->
    @commands = []

  render: (ctx) ->
    ocs = g.outer_command_size

      'hex'
      ])

    @mapping.commands[0] = new MoveCommand(LEFT)
    @mapping.commands[1] = new MoveCommand(UP)
    #@mapping.commands[2] = new MoveCommand(DOWN)
    @mapping.commands[3] = new MoveCommand(RIGHT)

    @pc = 0
    @execute()

    @startRenderer()
    @startInput()
