<commit_before>/*global game,Phaser*/
var state = {};

var enemy, shots;

state.create = function() {
    shots = game.add.group();
    var background = game.add.tileSprite(0, 0, 800, 600, 'starfield');
    background.update = function() {
        this.tilePosition.y += 1200 * game.time.physicsElapsed;
    };
    var ship = game.add.sprite(0, 0, 'ship');
    game.physics.arcade.enable(ship);
    ship.anchor.set(0.5);
    ship.scale.set(0.4);
    ship.shotTimer = 0;
    ship.update = function() {
        ship.body.velocity.set(0);
        if (game.physics.arcade.distanceToPointer(ship) > 10)
            game.physics.arcade.moveToPointer(ship, 300);
        if ((this.shotTimer += game.time.physicsElapsed) >= .25) {
            this.shotTimer = 0;
            var shot = game.make.sprite(this.x, this.y, 'pix');
            shot.height = 8;
            shot.width = 4;
            shot.anchor.set(0.5);
            shot.tint = 0x00ff00;
            game.physics.arcade.enable(shot);
            shot.body.velocity.y = -600;
            shots.add(shot);
        }
    };

    enemy = game.add.sprite(0, 0, 'pix');
    enemy.height = enemy.width = 40;
    enemy.anchor.set(0.5);
    game.physics.arcade.enable(enemy);
    enemy.x = 300;
    enemy.y = 50;
    game.add.tween(enemy).to({
        y: 300,
        x: 500
    }, 2000, Phaser.Easing.Sinusoidal.InOut, true, 0, -1, true);
};

state.update = function() {
    game.physics.arcade.overlap(enemy, shots, function(enemy, shot) {<commit_msg>Implement shot pooling.<commit_after>/*global game,Phaser*/
var state = {};

var enemies, shots;

state.create = function() {
    shots = game.add.physicsGroup();
    enemies = game.add.physicsGroup();

    var background = game.add.tileSprite(0, 0, 800, 600, 'starfield');
    background.update = function() {
        this.tilePosition.y += 1200 * game.time.physicsElapsed;
    };
    var ship = game.add.sprite(0, 0, 'ship');
    game.physics.arcade.enable(ship);
    ship.anchor.set(0.5);
    ship.scale.set(0.4);
    ship.shotTimer = 0;
    ship.update = function() {
        ship.body.velocity.set(0);
        if (game.physics.arcade.distanceToPointer(ship) > 5)
            game.physics.arcade.moveToPointer(ship, 300);
        if ((this.shotTimer += game.time.physicsElapsed) >= .25) {
            this.shotTimer = 0;
            var shot;
            if ((shot = shots.getFirstDead())) {
                shot.x = this.x;
                shot.y = this.y;
                shot.revive();
            }
            else {
                shot = game.make.sprite(this.x, this.y, 'pix');
                shot.height = 8;
                shot.width = 4;
                shot.anchor.set(0.5);
                shot.tint = 0x00ff00;
                shot.checkWorldBounds = true;
                shot.outOfBoundsKill = true;
                shots.add(shot);
                shot.body.velocity.y = -600;
            }
        }
    };

    var enemy = game.make.sprite(0, 0, 'pix');
    enemy.height = enemy.width = 40;
    enemy.anchor.set(0.5);
    enemy.x = 300;
    enemy.y = 50;
    game.add.tween(enemy).to({
        y: 300,
        x: 500
    }, 2000, Phaser.Easing.Sinusoidal.InOut, true, 0, -1, true);
    enemies.add(enemy);
};

state.update = function() {
    game.physics.arcade.overlap(enemies, shots, function(enemy, shot) {
{'fraction_non_alphanumeric': 0.15536892621475704, 'fraction_numerical': 0.03749250149970006, 'mean_word_length': 1.9409171075837743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1309107', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1140, 'n_words': 204}