         return if not @startedGame
         @stopGame()
         @gameManager.gameWon()
-        return 
+        return
 
     gameLost: =>
         return if not @startedGame
-        @stopGame()          
+        @stopGame()
         @gameManager.gameLost()
         return
 
     stopGame: =>
-        clearInterval clockHandle if clockHandle?   
-        clockHandle=null 
+        clearInterval clockHandle if clockHandle?
+        clockHandle=null
         @startedGame = false
         return
 

if not deepcopy?
    deepcopy = (src) -> $.extend(true, {},src)

class window.PaintGameState
    clockHandle = null

    constructor: (@gameManager, waitForCode) ->
        @gameConfig = deepcopy @gameManager.config.game
        @gameCommands = new PaintGameCommands @
        @visual = @gameManager.visual

        return

    getGameCommands: ->
        ###
            External Function (used by something outside of this file)

            Returns a handle to this games commands (a class).
        ###
        return @gameCommands

    clock: =>
        ###
            Internal Function (used only by the code in this file)

            The main engine behind the game.
            This function is called every X milliseconds via setInterval.
            Each time it is called it updates the visual and every Y times
            it is called it checks for events and executes the next command
            in the queue.
        ###
        if @startedGame == true
            if @tick % 30 == 0
                @checkEvents()
