//*************Scene Object - Initialize When Scene Starts Event *********************//
if ($this.scene.state() == "PLAY") {
    // initialize points
    $this.points = 0;


    // spawn a ninja every few seconds
    createTimer(2000, function() {
    // clone the ninja and give it a random x velocity
    var clonedNinja = ninja.clone();
    clonedNinja.velocityX = random(80,200);
    clonedNinja.velocityY = -50;
    // spawn the ninja off the left of the scene
    clonedNinja.x(-60);
    // give it a random y position
    clonedNinja.y(random(100, 300));
});
    // after the timer is created, remove the original ninja
    ninja.remove(); 
    
}

//*******************trampoline Object - Update Every Frame *************************//
$this.x(getMouseX() -190 / 2 ); 

//*******************ninja Object - Update Every Frame*******************************//
// spin the ninja every frame
$this.spin(60);

// change the y velocity due to gravity
$this.velocityY += 4;

// move the ninja based on its velocity
$this.moveX($this.velocityX);
$this.moveY($this.velocityY);

// bounce the ninja
if ($this.isTouching(trampoline)) {
    $this.velocityY = -300;
}

if($this.x() > 800) {
    $this.remove();
    $this.scene.points += 1;
    pointsLabel.text($this.scene.points);
}

if($this.y() > 600) {
    $this.scene.cleanupTimers();
    $this.scene.stopCode();
}

//