   window.grid = new Grid 100, "#056"
   controls = new KeyboardControls
 
-  # dot = new Particle [100, ctx.height - 100]
-  window.rect = new Rectangle 200, 200, [100, 80], 0.3, "#F00"
-  rect2 = new Rectangle 120, 100, [0, 0], 0, "#00F"
+  window.rect = new Rectangle 100, 100, [0, 200], 0.3, "#F00"
+  rect.inverseMass = 1/10
+  floor = new Rectangle 800, 10, [0, -5], 0, "#888"
+  paused = false
 
   _.extend ctx,
     update: ->
       rect.reset()
-      rect.integrate ctx.dt / 1000, controls
+      rect.resetDebug()
+      contacts = rect.contactPoints(floor)
+
+      unless paused
+        rect.integrate ctx.dt / 1000, controls
+
+      if contacts.length > 0
+        unless paused
+          for c, i in contacts
+            console.log "contact #{i}", c.normal, c.depth
+        paused = true
     draw: ->
       grid.draw ctx
       rect.draw ctx
-      rect2.draw ctx
+      floor.draw ctx
       rect.drawDebug ctx
       stats.update()
     clear: ->
       ctx.clearRect -ctx.width/2, -ctx.height/2, ctx.width, ctx.height
     keyup: (e) ->
       if e.keyCode is 32 # space
-        rect.resetDebug()
-        rect.contactPoints(rect2)
+        paused = false
       controls.keyup e
     keydown: controls.keydown
 

  position: [0, 0]
  rotation: [1, 0] # Rotation.fromAngle(0)

  vertices: -> []

  color: "#CCC"


  reset: -> # reset caches, forces, etc.

  integrate: (dt, controls) ->
    return if @inverseMass <= 0 or dt <= 0

    @position = Vec.add @position, Vec.scale @velocity, dt
    acceleration = [0, -15]
    @velocity = Vec.add @velocity, Vec.scale acceleration, dt
    @velocity = Vec.scale @velocity, Math.pow(@damping, dt)



  draw: (ctx) ->
    vertices = @vertices()
