 Systems = require './systems'
 
 C = require './entity/components'
+
+clamp = (x,min,max) ->
+  return min if x < min
+  return max if x > max
+  x
+
+keepWithin = (x,target,minDist,maxDist) ->
+  if target - x < minDist
+    # move left to preserve min dist:
+    return target - minDist
+  else if target - x > maxDist
+    # move right to stay within max dist:
+    return target - maxDist
+  x # x is already at comfortable distance to target
+
 
 Systems.register 'viewport-track-samus', class ViewportTrackSamus
   constructor: ({@container,@tileGrid}) ->

  [ 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00 ]
]

areaA = [
  [ 0, 1, 2]
]


    divRem = (numer,denom) -> [Math.floor(numer/denom), numer % denom]

    map = areaB

    mapRowCount = map.length * 15
    mapColCount = map[0].length * 16
