<commit_before>var player, enemies = [], attacking=[], currentlevel, interval;
function Entity(sprite,ai){
  this.sprite = sprite;
  this.ai = ai;
  this.direction = 1;
  this.dead = false;
  this.setDirection = function(d){
    if(d === this.direction)
      return;
    this.sprite.setX(this.sprite.getX()-0.65*d*this.sprite.getWidth());
    this.sprite.setScaleX(d);
    this.direction = d;
  };
  this.die = function(){
    this.sprite.setAnimation('death');
    this.dead = true;
    var self = this;
    this.sprite.afterFrame(self.sprite.getAnimations().death.length - 1,function(){
      self.sprite.setAnimation('death_stay');
    });
  };
  this.attack = function(){
    this.sprite.setAnimation('attack');
    var self = this;
    this.sprite.afterFrame(self.sprite.getAnimations().attack.length - 1,function(){
      attacking.push(self);
      self.sprite.setAnimation('idle');
    });
  };
}
function makeEnemy(){
  var i = Math.floor(Math.random()*400);
  var frame = Math.floor(Math.random()*pirateanimation.walk.length);
  var sprite = new Kinetic.Sprite({
    x: i,
    y: 200,
    image: piratesheet,
    animation: 'walk',
    animations: pirateanimation,
    frameRate: 8,
    index: frame,
    width: 128,
    height:128
  });
  var temp =new Entity(sprite,enemyAI);
  temp.speed =  Math.random()*2+3;
  temp.setDirection((i%2)?1:-1);
  return temp;
}
function enemyAI(){
  if(this.sprite.getAnimation()==='walk'){
    this.sprite.setX(this.sprite.getX()+this.speed*this.direction);
    var temp = this.sprite.getX()+this.direction*this.sprite.getWidth();
    if(temp>1.1*stage.getWidth() || temp< -0.1*stage.getWidth())
      this.setDirection(-this.direction);
    this.sprite.setY(getYofFloor(this.sprite.getX()+0.45*this.direction*this.sprite.getWidth()-20));
  }
}
function getYofFloor(x){
  if(x > 945)
    return 155;
  else if(x > 900)
    return -(x-900)+200;
  else if(x > 133)
    return 200;
  else if(x > 69)
    return (x-69)+145;
  else
    return 145;
}
function init_game(){
  stage.add(background);
  stage.add(ship);
  stage.add(people);
  stage.add(main);
  pirateship = new Kinetic.Image({
          x: -500,
          y: -450,
          image: shipsheet,
          width: shipsheet.width,
          height: shipsheet.height
        });
  ship.add(pirateship);
  ship.batchDraw();
  back= new Kinetic.Image({
          x: 0,
          y: -125,
          image: backsheet,
          width: backsheet.width,
          height: backsheet.height
        });
  background.add(back);
  background.batchDraw();
  for(var i = 0; i < 8; i++){
    enemies[i] = makeEnemy();
  }<commit_msg>fixed height<commit_after>var player, enemies = [], attacking=[], currentlevel, interval;
function Entity(sprite,ai){
  this.sprite = sprite;
  this.ai = ai;
  this.direction = 1;
  this.dead = false;
  this.setDirection = function(d){
    if(d === this.direction)
      return;
    this.sprite.setX(this.sprite.getX()-0.65*d*this.sprite.getWidth());
    this.sprite.setScaleX(d);
    this.direction = d;
  };
  this.die = function(){
    this.sprite.setAnimation('death');
    this.dead = true;
    var self = this;
    this.sprite.afterFrame(self.sprite.getAnimations().death.length - 1,function(){
      self.sprite.setAnimation('death_stay');
    });
  };
  this.attack = function(){
    this.sprite.setAnimation('attack');
    var self = this;
    this.sprite.afterFrame(self.sprite.getAnimations().attack.length - 1,function(){
      attacking.push(self);
      self.sprite.setAnimation('idle');
    });
  };
}
function makeEnemy(){
  var i = Math.floor(Math.random()*400);
  var frame = Math.floor(Math.random()*pirateanimation.walk.length);
  var sprite = new Kinetic.Sprite({
    x: i,
    y: 200,
    image: piratesheet,
    animation: 'walk',
    animations: pirateanimation,
    frameRate: 8,
    index: frame,
    width: 128,
    height:128
  });
  var temp =new Entity(sprite,enemyAI);
  temp.speed =  Math.random()*2+3;
  temp.setDirection((i%2)?1:-1);
  return temp;
}
function enemyAI(){
  if(this.sprite.getAnimation()==='walk'){
    this.sprite.setX(this.sprite.getX()+this.speed*this.direction);
    var temp = this.sprite.getX()+this.direction*this.sprite.getWidth();
    if(temp>1.1*stage.getWidth() || temp< -0.1*stage.getWidth())
      this.setDirection(-this.direction);
    this.sprite.setY(getYofFloor(this.sprite.getX()+0.45*this.direction*this.sprite.getWidth()-20));
  }
}
function getYofFloor(x){
  if(x > 945)
    return 160;
  else if(x > 900)
    return -(x-900)+205;
  else if(x > 133)
    return 205;
  else if(x > 69)
    return (x-69)+155;
  else
    return 160;
}
function init_game(){
  stage.add(background);
  stage.add(ship);
  stage.add(people);
  stage.add(main);
  pirateship = new Kinetic.Image({
          x: -500,
          y: -450,
          image: shipsheet,
          width: shipsheet.width,
          height: shipsheet.height
        });
  ship.add(pirateship);
  ship.batchDraw();
  back= new Kinetic.Image({
          x: 0,
          y: -125,
          image: backsheet,
          width: backsheet.width,
          height: backsheet.height
        });
  background.add(back);
  background.batchDraw();
  for(var i = 0; i < 8; i++){
    enemies[i] = makeEnemy();
  }
{'fraction_non_alphanumeric': 0.1671436748712078, 'fraction_numerical': 0.02900209883609998, 'mean_word_length': 2.9652042360060515, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2517706', 'n_tokens_mistral': 2000, 'n_tokens_neox': 1868, 'n_words': 329}