<commit_before>AndRes.Level1 = function(){};

AndRes.Level1.prototype = {
  preload: function(){

  },

  BOOSTER_FUEL: 0.0002,
  MANEUVER_FUEL: 0.00006,

  create: function(){

    this.map = this.game.add.tilemap('level0');
    this.map.addTilesetImage('level0');
    this.backgroundLayer = this.map.createLayer('backgroundLayer');
    this.collisionLayer = this.map.createLayer('collisionLayer');

    this.backgroundLayer.resizeWorld();

    this.map.setCollisionBetween(0, 100, true, 'collisionLayer');

    delete this.personGroup;
    delete this.fuelGroup;

    this.loadObjects();

    this.personGroup.forEach(function(person){
      person.body.setSize(15, 19, 9, 13 );
    });

    this.boostBottom = this.game.add.sprite(10, 29, 'boost-bottom');
    this.boostLeft = this.game.add.sprite(-7, 11, 'boost-left');
    this.boostRight = this.game.add.sprite(31, 11, 'boost-right');

    this.boostBottom.visible = false;
    this.boostLeft.visible = false;
    this.boostRight.visible = false;

    this.ship = this.game.add.sprite(250,415, 'level0', 11);


    this.ship.addChild(this.boostBottom);
    this.ship.addChild(this.boostLeft);
    this.ship.addChild(this.boostRight);

    this.game.physics.arcade.enable(this.ship);
    this.game.camera.follow(this.ship);

    this.cursors = this.game.input.keyboard.createCursorKeys();

    this.ship.body.gravity.y = 100;
    this.ship.fuel = 1;


    this.fuelText = this.game.add.bitmapText(10, 10, 'spacefont', "Fuel: " + this.ship.fuel, 18 );
    this.fuelText.fixedToCamera = true;
    this.startTime = this.game.time.now;
    this.duration = 0;
    this.previousPauses = this.game.time.pauseDuration;

    this.durationText = this.game.add.bitmapText(10, 32, 'spacefont', "Time: " + this.displayDuration(), 18 );
    this.durationText.fixedToCamera = true;
  },

  displayDuration: function(){
    var durationInSec = parseInt(this.duration / 1000);

    var mod = durationInSec % 60;
    if (mod < 10){
      mod  = "0" + '' + mod;
    }
    return (parseInt(durationInSec / 60)) + ":" + mod;
  },

  update: function(){

    this.duration = this.game.time.now - this.startTime - this.game.time.pauseDuration + this.previousPauses;;
    this.durationText.setText("Time: " + this.displayDuration());

    this.ship.body.acceleration.x = 0;
    this.ship.body.acceleration.y = 0;


    this.ship.currentFrameVelocityX = this.ship.body.velocity.x;
    this.ship.currentFrameVelocityY = this.ship.body.velocity.y;

    this.game.physics.arcade.overlap(this.ship, this.collisionLayer, this.playerHit, null, this);


    if(this.cursors.up.isDown && this.ship.fuel > 0){
      this.boostBottom.visible = true;
      this.ship.body.acceleration.y = -200;
      this.ship.fuel -= this.BOOSTER_FUEL;

    } else {
      this.boostBottom.visible = false;
    }

    if(this.cursors.right.isDown && this.ship.fuel > 0){
      this.boostLeft.visible = true;
      this.ship.body.acceleration.x += 20;
      this.ship.fuel -= this.MANEUVER_FUEL;
    } else {
      this.boostLeft.visible = false;
    }


    if(this.cursors.left.isDown && this.ship.fuel > 0){
      this.boostRight.visible = true;
      this.ship.body.acceleration.x += -20;
      this.ship.fuel -= this.MANEUVER_FUEL;

    } else {
      this.boostRight.visible = false;
    }

    this.game.physics.arcade.overlap(this.ship, this.personGroup, this.collectPerson, null, this);

    this.fuelText.setText("Fuel: " + this.massagedFuelText());
  },

  loadObjects: function(){
    this.map.objects['objectLayer'].forEach(function(item){
      if (item.name == 'ship') { return;}

      var groupName = item.name + "Group";
      if (!this[groupName]) {
        this[groupName] = this.game.add.group();
        this[groupName].enableBody = true;
      }

      this[groupName].create(item.x, item.y - this.map.tileHeight, 'level0', item.gid - 1);
    },this);
  },

  playerHit: function(player, tile){
    if(Math.abs(player.currentFrameVelocityX) > 30 || Math.abs(player.currentFrameVelocityY) > 30){
      this.game.state.start('level1');
    }
  },

  collectPerson: function(player, human){
    human.destroy();
  },

  massagedFuelText: function() {
    return Math.ceil(this.ship.fuel * 100);
  },

  render: function(){
    //if (this.personGroup) {
    //  this.personGroup.forEachAlive(this.game.debug.body, this.game.debug);
    //}
  }
};<commit_msg>Track humans and saved humans<commit_after>AndRes.Level1 = function(){};

AndRes.Level1.prototype = {
  preload: function(){

  },

  BOOSTER_FUEL: 0.0002,
  MANEUVER_FUEL: 0.00006,

  create: function(){

    this.map = this.game.add.tilemap('level0');
    this.map.addTilesetImage('level0');
    this.backgroundLayer = this.map.createLayer('backgroundLayer');
    this.collisionLayer = this.map.createLayer('collisionLayer');

    this.backgroundLayer.resizeWorld();

    this.map.setCollisionBetween(0, 100, true, 'collisionLayer');

    delete this.personGroup;
    delete this.fuelGroup;

    this.loadObjects();

    this.personGroup.forEach(function(person){
      person.body.setSize(15, 19, 9, 13 );
    });

    this.boostBottom = this.game.add.sprite(10, 29, 'boost-bottom');
    this.boostLeft = this.game.add.sprite(-7, 11, 'boost-left');
    this.boostRight = this.game.add.sprite(31, 11, 'boost-right');

    this.boostBottom.visible = false;
    this.boostLeft.visible = false;
    this.boostRight.visible = false;

    this.ship = this.game.add.sprite(250,415, 'level0', 11);


    this.ship.addChild(this.boostBottom);
    this.ship.addChild(this.boostLeft);
    this.ship.addChild(this.boostRight);

    this.game.physics.arcade.enable(this.ship);
    this.game.camera.follow(this.ship);

    this.cursors = this.game.input.keyboard.createCursorKeys();

    this.ship.body.gravity.y = 100;
    this.ship.fuel = 1;


    this.fuelText = this.game.add.bitmapText(10, 10, 'spacefont', "Fuel: " + this.ship.fuel, 18 );
    this.fuelText.fixedToCamera = true;
    this.startTime = this.game.time.now;
    this.duration = 0;
    this.previousPauses = this.game.time.pauseDuration;

    this.humansSaved = 0;
    this.humansText = this.game.add.bitmapText(10, 50, 'spacefont', "" + this.personGroup.length, 18);
    this.humansText.fixedToCamera = true;
    this.updateHumansSaved();

    this.durationText = this.game.add.bitmapText(10, 30, 'spacefont', "Time: " + this.displayDuration(), 18 );
    this.durationText.fixedToCamera = true;
  },

  updateHumansSaved: function(){
    this.humansText.setText("Humans: " + this.humansSaved + "/" + this.personGroup.length);
  },

  displayDuration: function(){
    var durationInSec = parseInt(this.duration / 1000);

    var mod = durationInSec % 60;
    if (mod < 10){
      mod  = "0" + '' + mod;
    }
    return (parseInt(durationInSec / 60)) + ":" + mod;
  },

  update: function(){

    this.duration = this.game.time.now - this.startTime - this.game.time.pauseDuration + this.previousPauses;;
    this.durationText.setText("Time: " + this.displayDuration());

    this.ship.body.acceleration.x = 0;
    this.ship.body.acceleration.y = 0;


    this.ship.currentFrameVelocityX = this.ship.body.velocity.x;
    this.ship.currentFrameVelocityY = this.ship.body.velocity.y;

    this.game.physics.arcade.overlap(this.ship, this.collisionLayer, this.playerHit, null, this);


    if(this.cursors.up.isDown && this.ship.fuel > 0){
      this.boostBottom.visible = true;
      this.ship.body.acceleration.y = -200;
      this.ship.fuel -= this.BOOSTER_FUEL;

    } else {
      this.boostBottom.visible = false;
    }

    if(this.cursors.right.isDown && this.ship.fuel > 0){
      this.boostLeft.visible = true;
      this.ship.body.acceleration.x += 20;
      this.ship.fuel -= this.MANEUVER_FUEL;
    } else {
      this.boostLeft.visible = false;
    }


    if(this.cursors.left.isDown && this.ship.fuel > 0){
      this.boostRight.visible = true;
      this.ship.body.acceleration.x += -20;
      this.ship.fuel -= this.MANEUVER_FUEL;

    } else {
      this.boostRight.visible = false;
    }

    this.game.physics.arcade.overlap(this.ship, this.personGroup, this.collectPerson, null, this);

    this.fuelText.setText("Fuel: " + this.massagedFuelText());
  },

  loadObjects: function(){
    this.map.objects['objectLayer'].forEach(function(item){
      if (item.name == 'ship') { return;}

      var groupName = item.name + "Group";
      if (!this[groupName]) {
        this[groupName] = this.game.add.group();
        this[groupName].enableBody = true;
      }

      this[groupName].create(item.x, item.y - this.map.tileHeight, 'level0', item.gid - 1);
    },this);
  },

  playerHit: function(player, tile){
    if(Math.abs(player.currentFrameVelocityX) > 30 || Math.abs(player.currentFrameVelocityY) > 30){
      this.game.state.start('level1');
    }
  },

  collectPerson: function(player, human){
    human.kill();
    this.humansSaved += 1;
    this.updateHumansSaved();
  },

  massagedFuelText: function() {
    return Math.ceil(this.ship.fuel * 100);
  },

  render: function(){
    //if (this.personGroup) {
    //  this.personGroup.forEachAlive(this.game.debug.body, this.game.debug);
    //}
  }
};
{'fraction_non_alphanumeric': 0.15813598166539344, 'fraction_numerical': 0.021826912583215105, 'mean_word_length': 3.1020590868397493, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 13, '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': '2832695', 'n_tokens_mistral': 3421, 'n_tokens_neox': 3100, 'n_words': 467}