       @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)
 

    ctx.translate 0, yEdge * ctx.height
    drawFn()
    ctx.translate 0, -yEdge * ctx.height

ctx.keyup = (e) ->
  switch e.keyCode


QUARTER_PI = Math.PI / 4

SHIP_MASS = 10
SHIP_SIZE = 50
MAX_THRUST = 2000

Vec =
  add: ([x1, y1], [x2, y2]) ->
