<commit_before>var snake, apple, squareSize, score, speed,
  updateDelay, direction, new_direction,
  addNew, cursors, scoreTextValue, speedTextValue,
  textStyle_Key, textStyle_Value;

var score;
var gameHighScore;
var freeManLevel;
var platforms;
var player;
var cursors;
var scoreText;
var debugText;
var ground;
var config;
var nextFreeManAt;
var Game = {
  scoreChange: function(delta){
    score += delta;
    scoreText.text = "score: " + score;
    // update game high score to determine free mans etc
    if (score > gameHighScore) {
      gameHighScore = score;
    }
    this.reapRewards();
  },
  reapRewards: function () {
    if (gameHighScore > nextFreeManAt) {
      // add free man
      console.log("player lives before: " + player.lives.length);
      player.lives.push(
        game.add.sprite(game.world.width - ((player.lives.length)*(player.width+16)), game.world.height - player.height - 16, 'hero')
      );
    console.log("player lives after: " + player.lives.length);
      nextFreeManAt += config.freeManThreshold;

      // todo: check level change
    }
  },
  makeBaddie: function (type, args)
  {
      args = args || {};
      var self = this;
      var image = type;
      var rollForSmall = function(){ return (Math.floor((Math.random() * 9) + 1)); };
      switch (type)
      {
        case "big":
          image = "big" + (Math.floor((Math.random() * 5) + 1));
          break;
        case "small":
          image = "small" + (args.idx || rollForSmall());
          break;
      }

      //blindmode!
      switch (type)
      {
        case "big":
          image = game.add.bitmapData(64,32);
          break;
        case "small":
          image = game.add.bitmapData(32,32);
          // image.context.fillStyle = '#FF6900';
          // image.circle(16,16,15)
          //replace color! http://www.phaser.io/examples/v2/bitmapdata/replace-color
          break;
      }

      var baddie = game.add.sprite(0, -64, image);
      var padding = 16;
      baddie.anchor.set(0.5,0.5);
      baddie.x = args.x || Math.floor((Math.random() * (game.world.width - baddie.offsetX - (padding * 2)))) + padding;
      baddie.y = args.y || -64;
      game.physics.arcade.enable(baddie);
      this.baddies.push(baddie);
      switch(type)
      {
        case "big":
          baddie.body.velocity.y = 75 + Math.floor((Math.random() * (80 * this.difficultyMultiplier)));
          baddie.body.velocity.x = Math.ceil((Math.random() * (config.baddieDriftMax * 2))) - config.baddieDriftMax;
          baddie.baseScore = config.bigBaddieBaseScore;
          baddie.shotUp = function() {
            if (self.baddies.livingCount() <=  3) { 
              //if (true) {
              //must use livingCount, as the array is likely not trimmed yet, as this will occur during shot
              //maybe use a sprite group? or something else where we we're not calculating this ourselves? *shrug*
              var idx = rollForSmall();
              self.makeBaddie("small", {big: baddie, idx: idx, x:baddie.x,y:baddie.y, velocityy: baddie.body.velocity.y, velocityx: baddie.body.velocity.x - (baddie.body.velocity.y * 0.8) });
              self.makeBaddie("small", {big: baddie, idx: idx, x:baddie.x,y:baddie.y, velocityy: baddie.body.velocity.y, velocityx: baddie.body.velocity.x + (baddie.body.velocity.y * 0.8) });
            }
          };
          break;
        case "small":
          baddie.body.velocity.y = args.velocityy || 75 + Math.floor((Math.random() * (80 * this.difficultyMultiplier)));
          baddie.body.velocity.x = args.velocityx || Math.ceil((Math.random() * (config.baddieDriftMax * 2))) - config.baddieDriftMax;
          baddie.baseScore = config.smallBaddieBaseScore;
          break;
        case "seaker":
          var speed = 75 + Math.floor((Math.random() * 80));
          baddie.baseScore = config.seekerBaseScore;
          baddie.body.velocity.y = speed;
          baddie.animations.add('pulse', [0,0,0,1,2,2,2,1], 30, true);
          baddie.animations.play('pulse');
          baddie.think = function(){
            var delta = player.x - baddie.x;
            var qty = Math.abs(delta);
            if (qty > 3) //solve unknown shudder issue
            {
              var direction = delta / qty; // -1 or +1
              baddie.body.velocity.x = direction * speed;
            } else {
              baddie.body.velocity.x = 0;
            }
          };
          break;
      }
      if (typeof baddie.think === 'undefined')
        baddie.think = function(){};
      if (typeof baddie.hitGround === 'undefined')
        baddie.hitGround = function () {
          self.scoreChange(-1 * (baddie.baseScore * self.levelMultiplier)/2);
        };
      if (typeof baddie.shotUp === 'undefined')<commit_msg>made debris code suck less<commit_after>var snake, apple, squareSize, score, speed,
  updateDelay, direction, new_direction,
  addNew, cursors, scoreTextValue, speedTextValue,
  textStyle_Key, textStyle_Value;

var score;
var gameHighScore;
var freeManLevel;
var platforms;
var player;
var cursors;
var scoreText;
var debugText;
var ground;
var config;
var nextFreeManAt;
var Game = {
  scoreChange: function(delta){
    score += delta;
    scoreText.text = "score: " + score;
    // update game high score to determine free mans etc
    if (score > gameHighScore) {
      gameHighScore = score;
    }
    this.reapRewards();
  },
  reapRewards: function () {
    if (gameHighScore > nextFreeManAt) {
      // add free man
      console.log("player lives before: " + player.lives.length);
      player.lives.push(
        game.add.sprite(game.world.width - ((player.lives.length)*(player.width+16)), game.world.height - player.height - 16, 'hero')
      );
    console.log("player lives after: " + player.lives.length);
      nextFreeManAt += config.freeManThreshold;

      // todo: check level change
    }
  },
  makeBaddie: function (type, args)
  {
      args = args || {};
      var self = this;
      var image = type;
      var rollForSmall = function(){ return (Math.floor((Math.random() * 9) + 1)); };
      switch (type)
      {
        case "big":
          image = "big" + (Math.floor((Math.random() * 5) + 1));
          break;
        case "small":
          image = "small" + rollForSmall();
          break;
        case "debris":
          image = "small" + args.idx;
          break;
      }

      //blindmode!
      switch (type)
      {
        case "big":
          image = game.add.bitmapData(64,32);
          break;
        case "small":
          image = game.add.bitmapData(32,32);
          // image.context.fillStyle = '#FF6900';
          // image.circle(16,16,15)
          //replace color! http://www.phaser.io/examples/v2/bitmapdata/replace-color
          break;
      }

      var baddie = game.add.sprite(0, -64, image);
      var padding = 16;
      baddie.anchor.set(0.5,0.5);
      baddie.x = args.x || Math.floor((Math.random() * (game.world.width - baddie.offsetX - (padding * 2)))) + padding;
      baddie.y = args.y || -64;
      game.physics.arcade.enable(baddie);
      this.baddies.push(baddie);
      switch(type)
      {
        case "big":
          baddie.body.velocity.y = 75 + Math.floor((Math.random() * (80 * this.difficultyMultiplier)));
          baddie.body.velocity.x = Math.ceil((Math.random() * (config.baddieDriftMax * 2))) - config.baddieDriftMax;
          baddie.baseScore = config.bigBaddieBaseScore;
          baddie.shotUp = function() {
            if (self.baddies.livingCount() <=  3) { 
              //if (true) {
              //must use livingCount, as the array is likely not trimmed yet, as this will occur during shot
              //maybe use a sprite group? or something else where we we're not calculating this ourselves? *shrug*
              var idx = rollForSmall();
              self.makeBaddie("debris", {big: baddie, idx: idx, direction: -1 });
              self.makeBaddie("debris", {big: baddie, idx: idx, direction: +1 });
            }
          };
          break;          
        case "small":
          baddie.body.velocity.y = 75 + Math.floor((Math.random() * (80 * this.difficultyMultiplier)));
          baddie.body.velocity.x = Math.ceil((Math.random() * (config.baddieDriftMax * 2))) - config.baddieDriftMax;
          baddie.baseScore = config.smallBaddieBaseScore;
          break;
        case "debris":
          baddie.x = args.big.x + args.direction * 2;
          baddie.y = args.big.y + args.direction * 2;
          baddie.body.velocity.y = args.big.body.velocity.y;
          baddie.body.velocity.x = args.big.body.velocity.x + (args.big.body.velocity.y * 0.8 * args.direction);
          baddie.baseScore = config.smallBaddieBaseScore;
          break;
        case "seaker":
          var speed = 75 + Math.floor((Math.random() * 80));
          baddie.baseScore = config.seekerBaseScore;
          baddie.body.velocity.y = speed;
          baddie.animations.add('pulse', [0,0,0,1,2,2,2,1], 30, true);
          baddie.animations.play('pulse');
          baddie.think = function(){
            var delta = player.x - baddie.x;
            var qty = Math.abs(delta);
            if (qty > 3) //solve unknown shudder issue
            {
              var direction = delta / qty; // -1 or +1
              baddie.body.velocity.x = direction * speed;
            } else {
              baddie.body.velocity.x = 0;
            }
          };
          break;
      }
      if (typeof baddie.think === 'undefined')
        baddie.think = function(){};
      if (typeof baddie.hitGround === 'undefined')
        baddie.hitGround = function () {
          self.scoreChange(-1 * (baddie.baseScore * self.levelMultiplier)/2);
        };
      if (typeof baddie.shotUp === 'undefined')
{'fraction_non_alphanumeric': 0.14126317944518374, 'fraction_numerical': 0.015354693417954755, 'mean_word_length': 2.0947101678808995, 'pattern_counts': {'":': 16, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1648136', 'n_tokens_mistral': 3276, 'n_tokens_neox': 3139, 'n_words': 680}