/**
This activity is a combination of several functions from previous lessons.
*/

//*****************Scene Object: Initialize When Scene Starts***********************//
if($this.scene.state() == "PLAY") {
    createTimer(1000, function() {
        var nship = enemy.clone();
        nship.x(31);
        nship.y(12);
    })
}

//*****************enemy Object: Update Every Frame********************************//
moveX($this);
if($this.isTouching(beam) && beam.visible()) {
    $this.remove()
} 
// ninjas may experiment with the conditions to make enemy move towards base 
if ($this.x() >= 700 || $this.x() <= 0) {
    $this.speedX(-$this.speedX());
    $this.y($this.y() + 100);
}