<commit_before>/// <reference path="~/phaser.js" />

// Global objects
var zombie;

var balloon;

var player;

var torso;

var shotgun;

var temp;

// Global helper members
var weights = [0.01, 0.03, 0.07, 0.3, 0.59];

// bool to check if zombie has any balloons left
var hasBallon;

// bool to check if zombie has reached the Man's cloud
var atCloud;


// Initialize Phaser, and create a 400x490px game
var game = new Phaser.Game(400, 490, Phaser.AUTO, 'gameDiv');


// Create our 'main' state that will contain the game
var mainState = {

    preload: function () 
    {
        // This function will be executed at the beginning     
        // That's where we load the game's assets  

        // Change the background color of the game
        game.stage.backgroundColor = '#71c5cf';

        // Load the image of Cloud
        game.load.image('cloud', 'assets/cloud.png');

        // Load the player sprite
        game.load.image('man', 'assets/man.png');

        // Load the zombie sprite
        game.load.image('zombie', 'assets/zombie.png');

        // Load the Red Balloon sprite
        game.load.image('redBalloon', 'assets/redBalloon.png');
    },


    // This function is called after the preload function     
    // Here we set up the game, display sprites, etc.  
    create: function () 
    {
        // Set the physics system
        game.physics.startSystem(Phaser.Physics.ARCADE);

        /*
        Cloud Object
        */
        this.cloud = this.game.add.sprite(-100, 200, 'cloud');

        game.physics.arcade.enable(this.cloud);

        this.cloud.body.immovable = true;


        // PLAYER
        // Display the player on the screen
        this.man = this.game.add.sprite(100, 210, 'man');

        // Add gravity to the man to make it fall
        game.physics.arcade.enable(this.man);


        // Call the 'shoot' function when the spacekey is hit
        var spaceKey =
            this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

        spaceKey.onDown.add(this.shoot, this);


        // Main Holder Sprite :: ZOMBIE
        this.zombie = game.add.group();

        // Torso
        this.zombie.torso = game.add.sprite(0, 0, 'zombie');
        this.zombie.torso.anchor.setTo(0.5);
        this.zombie.addChild(this.zombie.torso);

        game.physics.arcade.enable(this.zombie.torso);


        //  Balloon 
        this.zombie.balloon = game.add.sprite(0, -100, 'redBalloon');
        this.zombie.balloon.anchor.setTo(0.15, 0.5);
        this.zombie.addChild(this.zombie.balloon);

        game.physics.arcade.enable(this.zombie.balloon);

        this.zombie.createMultiple(100, 'zombie');
        this.zombie.createMultiple(100, 'redBalloon');
       

        // Add timer :: call addRowOfPipes() every 1.5sec
        this.timer = game.time.events.loop(3500, this.addZombieHorde, this);

        // Add timer :: Increase stats every 1.5sec
        //this.gameplayTimer = game.time.events.loop(10000, this.increaseStats, this);


        /*
        Player Score :: Label
        */ 

        // Create the Score object
        this.score = 0;
        
        this.labelScore = game.add.text(20, 20, "0", {
            font:
                "30px Arial", fill: "#ffffff" });
    },

    update: function () 
    {
        // This function is called 60 times per second    
        // It contains the game's logic   

        //TODO: Fix this to move the zombie left and fall onto the cloud
        // If the bird is out of the world (too high or too low), call the 
        //'restartGame' function
        //if (this.zombie.inWorld == false)
        //    this.restartGame();

        // call restartGame() each time the bird collides with a pipe
        game.physics.arcade.overlap(this.man, this.pipes, this.restartGame,
            null, this);
    },

    // TODO: Create shotgun
    // TODO: Create pivot on shotgun
    // TODO: Create projectile
    // TODO: Make the projectile shoot from Shotgun 
    //Make the player shoot
    shoot: function () {
        // Add a vertical velocity to the bird
        this.man.body.velocity.y = -350;
    },

    // Restart the game
    restartGame: function () 
    {
        // Start the 'main'state, which restarts the game
        game.state.start('main');
    },

    addOneZombie: function (x, y) 
    {
        currentZombie = this.zombie;

        currentZombie.xy(x, y);
<commit_msg>This has two groups: grpZombies and grpBalloon which is about to be condensed, using only this.zombie (which is the container holding torso and balloon) to call getAt(index) to try and get the torso and the baloon sprites to render. All this inside addOneZombie().<commit_after>/// <reference path="~/phaser.js" />

// Global objects
var zombie;

var balloon;

var player;

var torso;

var shotgun;

var temp;

// Global helper members
var weights = [0.01, 0.03, 0.07, 0.3, 0.59];

// bool to check if zombie has any balloons left
var hasBallon;

// bool to check if zombie has reached the Man's cloud
var atCloud;


// Initialize Phaser, and create a 400x490px game
var game = new Phaser.Game(400, 490, Phaser.AUTO, 'gameDiv');


// Create our 'main' state that will contain the game
var mainState = {

    preload: function () 
    {
        // This function will be executed at the beginning     
        // That's where we load the game's assets  

        // Change the background color of the game
        game.stage.backgroundColor = '#71c5cf';

        // Load the image of Cloud
        game.load.image('cloud', 'assets/cloud.png');

        // Load the player sprite
        game.load.image('man', 'assets/man.png');

        // Load the zombie sprite
        game.load.image('zombie', 'assets/zombie.png');

        // Load the Red Balloon sprite
        game.load.image('redBalloon', 'assets/redBalloon.png');
    },


    // This function is called after the preload function     
    // Here we set up the game, display sprites, etc.  
    create: function () 
    {
        // Set the physics system
        game.physics.startSystem(Phaser.Physics.ARCADE);

        /*
        Cloud Object
        */
        this.cloud = this.game.add.sprite(-100, 200, 'cloud');

        game.physics.arcade.enable(this.cloud);

        this.cloud.body.immovable = true;


        // PLAYER
        // Display the player on the screen
        this.man = this.game.add.sprite(100, 210, 'man');

        // Add gravity to the man to make it fall
        game.physics.arcade.enable(this.man);


        // Call the 'shoot' function when the spacekey is hit
        var spaceKey =
            this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

        spaceKey.onDown.add(this.shoot, this);


        // Main Holder Sprite :: ZOMBIE
        this.zombie = game.add.group();

        // Torso
        this.zombie.torso = game.add.sprite(0, 0, 'zombie');
        this.zombie.torso.anchor.setTo(0.5);
        this.zombie.addChild(this.zombie.torso);

        game.physics.arcade.enable(this.zombie.torso);


        //  Balloon 
        this.zombie.balloon = game.add.sprite(0, -100, 'redBalloon');
        this.zombie.balloon.anchor.setTo(0.15, 0.5);
        this.zombie.addChild(this.zombie.balloon);

        game.physics.arcade.enable(this.zombie.balloon);

        this.grpZombie = game.add.group();

        this.grpZombie.add(this.zombie);
        this.grpZombie.createMultiple(100, 'zombie');
        this.grpZombie.createMultiple(100, 'redBalloon');
       

        // Add timer :: call addRowOfPipes() every 1.5sec
        this.timer = game.time.events.loop(3500, this.addZombieHorde, this);

        // Add timer :: Increase stats every 1.5sec
        //this.gameplayTimer = game.time.events.loop(10000, this.increaseStats, this);


        /*
        Player Score :: Label
        */ 

        // Create the Score object
        this.score = 0;
        
        this.labelScore = game.add.text(20, 20, "0", {
            font:
                "30px Arial", fill: "#ffffff" });
    },

    update: function () 
    {
        // This function is called 60 times per second    
        // It contains the game's logic   

        //TODO: Fix this to move the zombie left and fall onto the cloud
        // If the bird is out of the world (too high or too low), call the 
        //'restartGame' function
        //if (this.zombie.inWorld == false)
        //    this.restartGame();

        // call restartGame() each time the bird collides with a pipe
        game.physics.arcade.overlap(this.man, this.pipes, this.restartGame,
            null, this);
    },

    // TODO: Create shotgun
    // TODO: Create pivot on shotgun
    // TODO: Create projectile
    // TODO: Make the projectile shoot from Shotgun 
    //Make the player shoot
    shoot: function () {
        // Add a vertical velocity to the bird
        this.man.body.velocity.y = -350;
    },

    // Restart the game
    restartGame: function () 
    {
        // Start the 'main'state, which restarts the game
        game.state.start('main');
    },

    addOneZombie: function (x, y) 
    {
        currentZombie = this.grpZombie.getFirstDead();
        currentZombie.reset(x, y);

        currentBalloon = this.grpBalloon.getFirstDead();
        currentBalloon.reset(x, y);

       // currentZombie.setAll('visible', true);
        //currentZombie.setAll('x', x);
        //currentZombie.setAll('y', y);
        //currentZombie.setAll('velocity', -20);

{'fraction_non_alphanumeric': 0.11987281399046106, 'fraction_numerical': 0.018441971383147855, 'mean_word_length': 2.030186255619782, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5402935', 'n_tokens_mistral': 3169, 'n_tokens_neox': 2889, 'n_words': 813}