         })
     }
     
+    func updateScore() {
+        currentScore += 1
+        scoreNode.text = generateScore()
+        
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: {
+            if (self.shouldUpdateScore) {
+                self.updateScore()
+            }
+        })
+    }
+    
     func startGame() {
         srand48(Int(arc4random()))
         

    
    let titleNode = SKLabelNode(fontNamed: "Courier")
    let subtitleNode = SKLabelNode(fontNamed: "Courier")
    
    override func didMove(to view: SKView) {
        print("c")

        canJump = false
        continueSpawnObstacle = false
        gameStarted = false
        shouldUpdateScore = false
        for node in self.children {
            if (node.physicsBody?.categoryBitMask == PhysicsCategory.Obstacle) {
                node.physicsBody?.velocity = CGVector(dx:0, dy:0)
