<commit_before>var Stage01 = extend(Stage, function(game) {

  var self = this,
      ship = new SpaceShip(game.boundaries);

  Stage.call(this, 'images/stages/witchBroomNebula.jpg',
                   'Witch Broom Nebula',
                   game.boundaries().height,
                   0.6);

  window.stage = this;

  this.update = function() {
    self.parent.update.call(this);
    ship.update();
  };

  this.render = function(context) {
    self.parent.render.call(this, context);
    ship.render(context);
  };

  this.readInput = function(input) {
    if(input.pressed('left_arrow')) {
      ship.moveLeft();
    }
    if(input.pressed('right_arrow')) {
      ship.moveRight();
    }
    if(input.pressed('up_arrow')) {
      ship.moveUp();
    }
    if(input.pressed('down_arrow')) {
      ship.moveDown();
    }
    if(input.pressed('space')){
      ship.shoot();
    }
  };

  this.addEnemy = function () {
    var self = this;
    setInterval(function () {
      self.enemies.push(new Enemy('images/enemies/enemy01.png'));
      self.enemies = self.enemies.filter(function (enemy) {
        return enemy.y < enemy.maxPosition.height;
      });
    }, 1000);
  };
  this.isComplete = function() {
    return false;
  };
});<commit_msg>Starting point for a stage01<commit_after>var Stage01 = extend(Stage, function(game) {

  var self = this,
      enemies = [],
      enemyInterval = null,
      boundaries = game.boundaries(),
      ship = new SpaceShip(boundaries),
      movePatterns = new MovePatterns();

  Stage.call(
    this,
    'images/stages/witchBroomNebula.jpg',
    'Witch Broom Nebula',
    boundaries.height,
    0.6
  );

  function deployEnemies(enemyFactory) {
    return function(amount) {
      var handler = setInterval(function() {
        if(amount == 0) {
          clearInterval(handler);
        }
        enemies.push(enemyFactory());
        amount--;
      }, 300)
    };
  }
  // window.setTimeout(function(){
  //   enemyInterval = setInterval(function () {
  //       enemies.push(new Enemy(boundaries, {
  //         image: 'images/enemies/enemy01.png',
  //         speed: 3,
  //         movePattern: movePatterns.select()
  //       }));
  //     }, 500);
  // }, 2000);

  this.stairsWave = deployEnemies(function() {
    return new Enemy(boundaries, {
            image: 'images/enemies/enemy01.png',
            speed: 4,
            movePattern: movePatterns.stairs
           });
    });

  this.circleWave = deployEnemies(function() {
    return new Enemy(boundaries, {
             image: 'images/enemies/enemy01.png',
             speed: 5,
             movePattern: movePatterns.circle
           });
    });
  this.bouncingCircleWave = deployEnemies(function(){
    return new Enemy(boundaries, {
      image: 'images/enemies/enemy01.png',
      speed: 5,
      movePattern: movePatterns.bouncingCircle,
      position: {
        x: boundaries.width,
        y: 30
      }
    });
  });

  window.stage = this;
  window.setTimeout(self.stairsWave, 10000, 20);
  window.setTimeout(self.circleWave, 1000, 20);
  window.setTimeout(self.stairsWave, 50000, 20);

  this.update = function() {
    this.parent.update.call(this);
    enemies =
      enemies.map(function(enemy){
        enemy.update(ship);
        return enemy;
      })
      .filter(function(enemy) {
        return enemy.y < boundaries.height;
      });

    ship.update();
  };

  this.render = function(context) {
    this.parent.render.call(this, context);
    ship.render(context);
    enemies.forEach(function(enemy) {
      enemy.render(context);
    });
  };

  this.readInput = function(input) {
    if(input.pressed('left_arrow')) {
      ship.moveLeft();
    }
    if(input.pressed('right_arrow')) {
      ship.moveRight();
    }
    if(input.pressed('up_arrow')) {
      ship.moveUp();
    }
    if(input.pressed('down_arrow')) {
      ship.moveDown();
    }
    if(input.pressed('space')){
      ship.shoot();
    }
  };

  this.isComplete = function() {
    return false;
  };

  this.resize = function(newBoundaries) {
    boundaries = newBoundaries;
    ship.boundaries = newBoundaries;
    enemies.forEach(function(enemy){
      enemy.boundaries = newBoundaries;
    });
  };

});
{'fraction_non_alphanumeric': 0.14939530471899454, 'fraction_numerical': 0.014465259663267727, 'mean_word_length': 2.3238770685579198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6519153', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1353, 'n_words': 209}