     
     func randomCGFloat() -> CGFloat {
         return CGFloat(Float(arc4random()) / Float(UINT32_MAX))
+    }
+    
+    func lengthOf(s: CGPoint, e: CGPoint) -> CGFloat {
+        let xDiff = e.x - s.x
+        let yDiff = e.y - s.y
+        return sqrt(xDiff * xDiff + yDiff * yDiff)
     }
     
     /**

            } else {
                s = lastE
                e = CGPointMake(randomCGFloat(), randomCGFloat())
            }
            lastE = e
            let line : SKNode = drawLine(s, e:e).0;
            let ball1 = drawLine(s, e:e).1;
            let ball2 = drawLine(s, e:e).2;

        self.runAction(SKAction.repeatActionForever(
            SKAction.sequence([
                SKAction.runBlock({
                    self.generateRandomLinesAndBalls(self.lineCap);
                    self.drawLinesAndBallsOffCanvas(self.lines, balls: self.balls, duration: self.gameSpeed);
                }),
                SKAction.waitForDuration(gameSpeed / (3 / 0.8))
