<commit_before>const module = {
  preload(game) {
    this.game = game;
    this.game.load.image('gun', '/assets/shotgun.png');
    this.game.load.image('bullet', '/assets/bullet.png');

  },

  create(player, cursors) {
    this.player = player;
    this.cursors = cursors;
    this.gun = this.game.add.sprite(this.player.x + this.player.width, this.player.y, 'gun');
    this.gun.anchor.set(0.5, 1);
    this.gun.name = "gun";

    this.bullets = this.game.add.group();
    this.bullets.enableBody = true;
    this.bullets.createMultiple(50, 'bullet');
    this.bullets.setAll('checkWorldBounds', true);
    this.bullets.setAll('outOfBoundsKill', true);

    this.fireTimer = 0;
    this.fireRate = 200;
    this.speed = 800;
  },

  fire() {
    if (this.game.time.now > this.fireTimer && this.bullets.countDead() > 5) {
      this.fireTimer = this.game.time.now + this.fireRate;
      let angle = this.player.rotation-(3.14159/2); // Use player rotation offset -90 degrees to account for righthand starting polar coordinate system
      for (let i = 0; i < 3; i++) {
        let bullet = this.bullets.getFirstDead();
        bullet.reset(this.gun.x, this.gun.y);
        bullet.body.velocity.x = Math.cos(angle+(3.14/4)*i)*this.speed;
        bullet.body.velocity.y = Math.sin(angle+(3.14/4)*i)*this.speed;
        let bullet2 = this.bullets.getFirstDead();
        bullet2.reset(this.gun.x, this.gun.y);
        bullet2.body.velocity.x = Math.cos(angle-(3.14/4)*i)*this.speed;
        bullet2.body.velocity.y = Math.sin(angle-(3.14/4)*i)*this.speed;
      }
    }
  },

  update() {
    this.gun.x = this.player.x + this.player.width;
    this.gun.y = this.player.y;
    if (this.cursors.up.isDown || this.cursors.right.isDown || this.cursors.left.isDown || this.cursors.down.isDown) {
      this.fire();
    }
  },


  getBullets() {
    return this.bullets;
  },

  getCursors() {
    return this.cursors;
  },

  getItemType() {<commit_msg>Bullets now disappear after a certain distance<commit_after>const module = {
  preload(game) {
    this.game = game;
    this.game.load.image('gun', '/assets/shotgun.png');
    this.game.load.image('bullet', '/assets/bullet.png');

  },

  create(player, cursors) {
    this.player = player;
    this.cursors = cursors;
    this.gun = this.game.add.sprite(this.player.x + this.player.width, this.player.y, 'gun');
    this.gun.anchor.set(0.5, 1);
    this.gun.name = "gun";

    this.bullets = this.game.add.group();
    this.bullets.enableBody = true;
    this.bullets.createMultiple(50, 'bullet');
    this.bullets.setAll('checkWorldBounds', true);
    this.bullets.setAll('outOfBoundsKill', true);

    this.fireTimer = 0;
    this.fireRate = 200;
    this.speed = 800;
  },

  fire() {
    if (this.game.time.now > this.fireTimer && this.bullets.countDead() > 5) {
      this.fireTimer = this.game.time.now + this.fireRate;
      let angle = this.player.rotation-(3.14159/2); // Use player rotation offset -90 degrees to account for righthand starting polar coordinate system
      for (let i = 0; i < 3; i++) {
        let bullet = this.bullets.getFirstDead();
        bullet.reset(this.gun.x, this.gun.y);
        bullet.body.velocity.x = Math.cos(angle+(3.14/4)*i)*this.speed;
        bullet.body.velocity.y = Math.sin(angle+(3.14/4)*i)*this.speed;
        let bullet2 = this.bullets.getFirstDead();
        bullet2.reset(this.gun.x, this.gun.y);
        bullet2.body.velocity.x = Math.cos(angle-(3.14/4)*i)*this.speed;
        bullet2.body.velocity.y = Math.sin(angle-(3.14/4)*i)*this.speed;
      }
    }
  },

  update() {
    this.gun.x = this.player.x + this.player.width;
    this.gun.y = this.player.y;
    if (this.cursors.up.isDown || this.cursors.right.isDown || this.cursors.left.isDown || this.cursors.down.isDown) {
      this.fire();
    }
    this.bullets.children.forEach((bullet) => {
      if (this.game.physics.arcade.distanceBetween(this.gun, bullet) > 375) {
        bullet.kill();
      }
    });
  },


  getBullets() {
    return this.bullets;
  },

  getCursors() {
    return this.cursors;
  },

  getItemType() {
{'fraction_non_alphanumeric': 0.17269174401563264, 'fraction_numerical': 0.022227650219833903, 'mean_word_length': 2.7227272727272727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3059867', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1447, 'n_words': 232}