 TWEEN_DURATION = 0.5
 
 delay1s = (func) -> setTimeout func, 1000
+
 
 randomChoice = (values) ->
     # http://rosettacode.org/wiki/Pick_random_element#CoffeeScript
     return values[Math.floor(Math.random() * values.length)]
+
+
+class QueryString
+    # Provide easy access to QueryString data
+    # https://gist.github.com/greystate/1274961
+
+    constructor: (@queryString) ->
+        @queryString or= window.document.location.search?.substr 1
+        @variables = @queryString.split '&'
+        @pairs = ([key, value] = pair.split '=' for pair in @variables)
+
+    get: (name) ->
+        for [key, value] in @pairs
+            return value if key is name
 
 
 class FieldWidget

            @movesDiff.setText('+'+@level.movesDiff)
            @movesDiff.opacity(1)

            tween = new Kinetic.Tween
                node: @movesDiff
                opacity: 0
                duration: TWEEN_DURATION * 5

            tween.play()

        @centerText(@score)
        @centerText(@scoreDiff)



class Game
    level: null

    constructor: () ->
        qs = new QueryString
        boardSize = qs.get('size')
        if not boardSize?
            boardSize = 4

        @level = new Level boardSize


