       @theta -= PI/30
 
     if @thrust = controls.up
-      a = MAX_THRUST / SHIP_MASS
-      deltaX = a * cos(@theta) * dt
-      deltaY = a * sin(@theta) * dt
-      @velocity = Vec.add @velocity, [deltaX, deltaY]
+      acceleration = Vec.polarToVector(@theta, MAX_THRUST / SHIP_MASS)
+      @velocity = Vec.add @velocity, Vec.mul(acceleration, dt)
 
     @position = Vec.add @position, Vec.mul(@velocity, dt)
 

  left: false
  right: false

ctx.update = ->
  ship.update ctx.dt / 1000, controls

ctx.draw = ->
  ship.draw(ctx)
  drawWrappedEdges ship.nearEdges(ctx), -> ship.draw(ctx)

  stats.update()

drawWrappedEdges = ([xEdge,yEdge], drawFn) ->
  if xEdge isnt 0
    ctx.translate xEdge * ctx.width, 0
    drawFn()

    [x1 - x2, y1 - y2]
  mul: ([x, y], c) ->
    [x * c, y * c]
  polarToVector: (theta, length) ->
    [ cos(theta) * length, sin(theta) * length ]

class Ship
  constructor: (x, y, @theta= HALF_PI * 3) ->
