<commit_before>function Turret(game, ammo, player) {
    Phaser.Sprite.call(this, game, 0, 0, 'turret');

    this.game = game;
    this.ammo = ammo;
    this.player = player;
    this.anchor.setTo(0.5, 0.5);
    this.scale.setTo(0.3, 0.3);
    this.game.physics.enable(this, Phaser.Physics.ARCADE);

    this.spawnTimer = this.game.time.events.add(200, this.fireWeapon.bind(this));

}
Turret.prototype = Object.create(Phaser.Sprite.prototype);
Turret.constructor = Turret;

Turret.prototype.fireWeapon = function () {
    var bullet = this.ammo.getFirstExists(false);
    if (bullet) {
        bullet.reset(this.body.x + this.width / 2, this.body.y + this.height / 2);

        console.log("Player is at ", this.player.player.x, this.player.player.y);
        bullet.angle = this.game.physics.arcade.angleToXY(this.player.player.x, this.player.player.y);
        this.game.physics.arcade.velocityFromAngle(bullet.angle, 200, bullet.body.velocity);
        bullet.body.velocity.x += 200;
    }

    this.spawnTimer = this.game.time.events.add(200, this.fireWeapon.bind(this));
};

Turret.prototype.update = function () {
};

Turret.preload = function (game) {
    game.load.image('turret', 'assets/turret.png');
};

module.exports = Turret;
<commit_msg>Made bullets move towards player<commit_after>function Turret(game, ammo, player) {
    Phaser.Sprite.call(this, game, 0, 0, 'turret');

    this.game = game;
    this.ammo = ammo;
    this.player = player;
    this.anchor.setTo(0.5, 0.5);
    this.scale.setTo(0.3, 0.3);
    this.game.physics.enable(this, Phaser.Physics.ARCADE);

    this.spawnTimer = this.game.time.events.add(200, this.fireWeapon.bind(this));

}
Turret.prototype = Object.create(Phaser.Sprite.prototype);
Turret.constructor = Turret;

Turret.prototype.fireWeapon = function () {
    var bullet = this.ammo.getFirstExists(false);
    if (bullet) {
        bullet.reset(this.body.x + this.width / 2, this.body.y + this.height / 2);
        this.game.physics.arcade.moveToObject(bullet, this.player.player, 200);
    }

    this.spawnTimer = this.game.time.events.add(200, this.fireWeapon.bind(this));
};

Turret.prototype.update = function () {
};

Turret.preload = function (game) {
    game.load.image('turret', 'assets/turret.png');
};

module.exports = Turret;

{'fraction_non_alphanumeric': 0.16222125054656755, 'fraction_numerical': 0.019676432006996064, 'mean_word_length': 3.460038986354776, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3339059', 'n_tokens_mistral': 866, 'n_tokens_neox': 820, 'n_words': 126}