-- distance test and volatile table

function dist(sprite1, sprite2)
  return math.floor(math.sqrt(math.pow(sprite2.x - sprite1.x, 2) + math.pow(sprite2.y - sprite1.y, 2)) + 0.5)
end

function main()
  if volatile[1] == nil then
    volatile[1] = 0
  end

  while true do
    local dinkdist = dist(current_sprite, player)
    current_sprite:say(dinkdist)
    dink.wait(200)
    if dinkdist < 5 then
      dink.sneedler()
    end
  end
end

function hit()
  if volatile[1] ~= nil then
    volatile[1] = volatile[1] + 1
  else
    volatile[1] = 1
  end
end
