/**
Ninjas are presented with the for loop, which they will use to build a scene, 
and then create a game utilizing the remove function.
*/

//************************Scene Object: Initialize When Scene Starts***************//
if($this.scene.state() == "PLAY" ) {
    var brickX = 4;
    var nbrick;
    $this.score = 0

    //for() loop to create the bricks across the screen
    for (var brickCount = 1; brickCount <= 9; brickCount++) {
        nbrick = brick.clone();
        nbrick.x(brickX + 80 * brickCount);
        nbrick.y(150)
    }
}

//************************brick Object: Update Every Frame Event*******************//
if($this.isTouching(ball)) {
    ball.speedY(-ball.speedY()); //bounce the ball in opposite direction
    $this.remove(); //remove brick
    $this.scene.score += 10; //score update
    lblScore.text(parseInt($this.scene.score));
}

