<commit_before>/**
 * The game's global configuration.
 */
var Smc = {
    // The Phaser event handlers. Keys are event names, and values are arrays of functions that take no arguments.
    phaserEventHandlers: {
        preload: [],
        create: [],
        update: []
    },
    playerTypes: {}
};

var game = new Phaser.Game(640,480, Phaser.AUTO, 'world', {
    preload: buildPhaserEventHandler("preload"),
    create: buildPhaserEventHandler("create"),
    update: buildPhaserEventHandler("update")
});

/**
 * A game player.
 *
 * @param {string} name
 * @param {Phaser.Sprite} phaserObject
 * @constructor
 */
Smc.playerTypes.Player = function (name, phaserObject) {
    this._defense = 1;
    this._name = name;
    this._isGoingUp = false;
    this._phaserObject = phaserObject;
    game.physics.arcade.enable(this._phaserObject);
    this._phaserObject.animations.add('left', ['left1', 'left2','left3', 'left4','left5', 'left6','left7', 'left8','left9']);
    this._phaserObject.animations.add('right', ['right1', 'right2','right3', 'right4','right5', 'right6','right7', 'right8', 'right9']);
    this._phaserObject.animations.add('up', ['up1', 'up2','up3', 'up4','up5', 'up6','up7', 'up8','up9']);
    this._phaserObject.animations.add('down', ['down1', 'down2']);
    this._phaserObject.animations.add('stop');
    this._phaserObject.animations.play('stop', 5, true);
    this._phaserObject.animations.play('stop', 5, true);
    this._phaserObject.body.gravity.set(0, 180);
    this._phaserObject.body.collideWorldBounds = true;
    this._phaserObject.anchor.setTo(0.5, 0.5);

    this._weaponMountPhaserObject = game.add.sprite( 600,480, 'pixel');
    game.physics.arcade.enable(this._weaponMountPhaserObject);
    this._weaponMountPhaserObject.body.enable          = true;
    this._weaponMountPhaserObject.body.allowRotation   = true;

    //  Creates 30 bullets, using the 'bullet' graphic
    this._weaponPhaserObject = game.add.weapon(30, 'bullet');
    game.physics.arcade.enable(this._weaponPhaserObject);
    //  The bullet will be automatically killed when it leaves the world bounds
    this._weaponPhaserObject.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS;
    //  The speed at which the bullet is fired
    this._weaponPhaserObject.bulletSpeed = 600;
    //  Speed-up the rate of fire, allowing them to shoot 1 bullet every 60ms
    this._weaponPhaserObject.fireRate = 100;
    //  Tell the Weapon to track the player
    //  With no offsets from the position
    //  But the 'true' argument tells the weapon to track sprite rotation
    this._weaponPhaserObject.trackSprite(this._weaponMountPhaserObject, 0, 0, true);


    this._id                  = 1;
    this._phaserObject.maxHealth = 100;
    this._phaserObject.health= 100;
    this._phaserObject.hud = Phaser.Plugin.HUDManager.create(this._phaserObject.game, this._phaserObject, 'smc.player.hud.' + this._id);
    this._healthHud           =this._phaserObject.hud.addBar(0, -20, 32, 2, this._phaserObject.maxHealth, 'health', this._phaserObject, Phaser.Plugin.HUDManager.HEALTHBAR, false);
    this._healthHud.bar.anchor.setTo(0.5, 0.5);
    this._phaserObject.addChild(this._healthHud.bar);

    game.physics.arcade.enable(this._phaserObject)

    // Set up the trail blaze.
    this._trailBlazeEmitter = game.add.emitter(game.world.centerX, game.world.centerY, 400);
    this._trailBlazeEmitter.makeParticles( [ 'fire1', 'fire2', 'fire3', 'smoke' ] );
    this._trailBlazeEmitter.gravity = 800;
    this._trailBlazeEmitter.setAlpha(1, 0, 3000);
}

/**
 * Hits the player.
 */
Smc.playerTypes.Player.prototype.hit = function() {
    this._phaserObject.health = this._phaserObject.health - (10 / this._defense);
    if  (this._phaserObject.health<=0){
        this._kill();
    }
}

/**
 * Kills the player.<commit_msg>Ensure the character itself is never hidden by the other sprites that belong to it.<commit_after>/**
 * The game's global configuration.
 */
var Smc = {
    // The Phaser event handlers. Keys are event names, and values are arrays of functions that take no arguments.
    phaserEventHandlers: {
        preload: [],
        create: [],
        update: []
    },
    playerTypes: {}
};

var game = new Phaser.Game(640,480, Phaser.AUTO, 'world', {
    preload: buildPhaserEventHandler("preload"),
    create: buildPhaserEventHandler("create"),
    update: buildPhaserEventHandler("update")
});

/**
 * A game player.
 *
 * @param {string} name
 * @param {Phaser.Sprite} phaserObject
 * @constructor
 */
Smc.playerTypes.Player = function (name, phaserObject) {
    this._defense = 1;
    this._name = name;
    this._isGoingUp = false;
    this._phaserObject = phaserObject;
    game.physics.arcade.enable(this._phaserObject);
    this._phaserObject.animations.add('left', ['left1', 'left2','left3', 'left4','left5', 'left6','left7', 'left8','left9']);
    this._phaserObject.animations.add('right', ['right1', 'right2','right3', 'right4','right5', 'right6','right7', 'right8', 'right9']);
    this._phaserObject.animations.add('up', ['up1', 'up2','up3', 'up4','up5', 'up6','up7', 'up8','up9']);
    this._phaserObject.animations.add('down', ['down1', 'down2']);
    this._phaserObject.animations.add('stop');
    this._phaserObject.animations.play('stop', 5, true);
    this._phaserObject.animations.play('stop', 5, true);
    this._phaserObject.body.gravity.set(0, 180);
    this._phaserObject.body.collideWorldBounds = true;
    this._phaserObject.anchor.setTo(0.5, 0.5);

    this._weaponMountPhaserObject = game.add.sprite( 600,480, 'pixel');
    game.physics.arcade.enable(this._weaponMountPhaserObject);
    this._weaponMountPhaserObject.body.enable          = true;
    this._weaponMountPhaserObject.body.allowRotation   = true;

    //  Creates 30 bullets, using the 'bullet' graphic
    this._weaponPhaserObject = game.add.weapon(30, 'bullet');
    game.physics.arcade.enable(this._weaponPhaserObject);
    //  The bullet will be automatically killed when it leaves the world bounds
    this._weaponPhaserObject.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS;
    //  The speed at which the bullet is fired
    this._weaponPhaserObject.bulletSpeed = 600;
    //  Speed-up the rate of fire, allowing them to shoot 1 bullet every 60ms
    this._weaponPhaserObject.fireRate = 100;
    //  Tell the Weapon to track the player
    //  With no offsets from the position
    //  But the 'true' argument tells the weapon to track sprite rotation
    this._weaponPhaserObject.trackSprite(this._weaponMountPhaserObject, 0, 0, true);


    this._id                  = 1;
    this._phaserObject.maxHealth = 100;
    this._phaserObject.health= 100;
    this._phaserObject.hud = Phaser.Plugin.HUDManager.create(this._phaserObject.game, this._phaserObject, 'smc.player.hud.' + this._id);
    this._healthHud           =this._phaserObject.hud.addBar(0, -20, 32, 2, this._phaserObject.maxHealth, 'health', this._phaserObject, Phaser.Plugin.HUDManager.HEALTHBAR, false);
    this._healthHud.bar.anchor.setTo(0.5, 0.5);
    this._phaserObject.addChild(this._healthHud.bar);

    game.physics.arcade.enable(this._phaserObject)

    // Set up the trail blaze.
    this._trailBlazeEmitter = game.add.emitter(game.world.centerX, game.world.centerY, 400);
    this._trailBlazeEmitter.makeParticles( [ 'fire1', 'fire2', 'fire3', 'smoke' ] );
    this._trailBlazeEmitter.gravity = 800;
    this._trailBlazeEmitter.setAlpha(1, 0, 3000);

    // Ensure the character itself is never hidden by the other sprites that belong to it.
    this._phaserObject.bringToTop();
}

/**
 * Hits the player.
 */
Smc.playerTypes.Player.prototype.hit = function() {
    this._phaserObject.health = this._phaserObject.health - (10 / this._defense);
    if  (this._phaserObject.health<=0){
        this._kill();
    }
}

/**
 * Kills the player.
{'fraction_non_alphanumeric': 0.1418702827171549, 'fraction_numerical': 0.026096968146347703, 'mean_word_length': 3.6954954954954955, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3155656', 'n_tokens_mistral': 2714, 'n_tokens_neox': 2579, 'n_words': 521}