<commit_before>(function () {
    'use strict'; 
    
    var player = {
        sprite: null,
        jumpVelocity: -450,
        isJumping: false,
        isDoubleJumping: false,
        setup: function () {
            player.sprite = this.game.add.sprite(this.game.world.centerX, 450, 'player');
            player.sprite.anchor.set(0.5);
            this.game.physics.arcade.enable(player.sprite);
            player.sprite.body.gravity.y = 750;
        },
        jump: function () {
            if(player.sprite.body.touching.down) {
                player.isJumping = true;
                doJump.apply(this);
            }
            else if(!player.isDoubleJumping) {
                player.isDoubleJumping = true;
                doJump.apply(this);
            }

            function doJump() {
                // this.jumpSound.play();
                this.game.add.tween(player.sprite).to({ angle: 360 }, 750, Phaser.Easing.Exponential.Out).start();
                player.sprite.body.velocity.y = player.jumpVelocity || -450;
            }
        },
        groundCollision: function (playerSprite) {
            if(player.isJumping) {
                player.isJumping = false;
                player.isDoubleJumping = false;
                playerSprite.angle = 0;
            }
        },
        bloodCollision: function (player, blood) {
            // this.bloodSound.play();
            blood.kill();

            // this.particleEmitter.x = blood.x;
            // this.particleEmitter.y = blood.y;
            // this.particleEmitter.start(true, 500, null, 10);
        }
    }

    var GameState = function() {
    };

    GameState.prototype.preload = function() {
        this.game.load.image('player', 'assets/img/player.png');
        this.game.load.image('platform', 'assets/img/wallHorizontal.png');
        this.game.load.image('particle', 'assets/img/pixel.png');
        this.game.load.audio('jumpSound', 'assets/audio/jump.ogg');
        this.game.load.image('blood', 'assets/img/blood.png');
        // this.game.load.audio('bloodSound', 'assets/audio/blood.ogg');
        /*------ Parallax ------*/
        this.game.load.image('mountains-back', 'assets/img/mountains-back.png');
        this.game.load.image('mountains-mid1', 'assets/img/mountains-mid1.png');
        this.game.load.image('mountains-mid2', 'assets/img/mountains-mid2.png');
    }

    GameState.prototype.create = function() {
        this.game.physics.startSystem(Phaser.Physics.ARCADE);
        this.game.stage.backgroundColor = '#697e96';

        /*------ Parallax ------*/
        this.mountainsBack = this.game.add.tileSprite(0, 
            this.game.height - this.game.cache.getImage('mountains-back').height, 
            this.game.width, 
            this.game.cache.getImage('mountains-back').height,'mountains-back'
        );
 
        this.mountainsMid1 = this.game.add.tileSprite(0, 
            this.game.height - this.game.cache.getImage('mountains-mid1').height, 
            this.game.width, 
            this.game.cache.getImage('mountains-mid1').height,'mountains-mid1'
        );
 
        this.mountainsMid2 = this.game.add.tileSprite(0, 
            this.game.height - this.game.cache.getImage('mountains-mid2').height, 
            this.game.width, 
            this.game.cache.getImage('mountains-mid2').height,'mountains-mid2'
        );  
        
        // setup initial player properties
        player.setup.apply(this);

        this.platform = this.game.add.sprite(0, this.game.world.height - 100, 'platform');
        this.game.physics.arcade.enable(this.platform);
        this.platform.body.immovable = true;
        this.platform.width = this.game.world.width;
        this.platform.height = 100;
        this.jumpSound = this.game.add.audio('jumpSound');
        // this.bloodSound = this.game.add.audio('bloodSound');

        // blood group
        this.bloods = this.game.add.group();
        this.bloods.enableBody = true;
        this.bloods.create(200, 400, 'blood');
        this.bloods.create(400, 400, 'blood');
        this.bloods.create(600, 400, 'blood');
        this.bloods.setAll('body.immovable', true);

        // this.bloodCount = 3;

        // Emissor de particulas
        // this.particleEmitter = this.game.add.emitter(0, 0, 100);
        // this.particleEmitter.makeParticles('particle');
        
    
        
    }

    GameState.prototype.update = function() {
        /*------ Parallax ------*/
        this.mountainsBack.tilePosition.x -= 0.05;
        this.mountainsMid1.tilePosition.x -= 0.3;
        this.mountainsMid2.tilePosition.x -= 0.75;
        
        handleColliders.apply(this);
        handleInputs.apply(this);
    }    
    
    GameState.prototype.render = function() {
        // this.game.debug.inputInfo(32, 32);
    }

    function handleColliders() {
        this.game.physics.arcade.collide(player.sprite, this.platform, player.groundCollision, null, this);
        this.game.physics.arcade.overlap(player.sprite, this.bloods, player.bloodCollision, null, this);
    }

    function handleInputs() {
        
        this.game.input.keyboard.addKey(Phaser.Keyboard.W).onDown.add(function () {
            player.jump.apply(this);
        }, this);

        if (this.game.input.keyboard.isDown(Phaser.Keyboard.A)) {
            player.sprite.body.velocity.x = -150;
        }
        else if (this.game.input.keyboard.isDown(Phaser.Keyboard.D)) {
            player.sprite.body.velocity.x = 150;
        }
        else {
             player.sprite.body.velocity.x = 0;
        }
    }

    gameManager.addState('game', GameState);

})();<commit_msg>Adicionado evento de touch<commit_after>(function () {
    'use strict'; 
    
    var player = {
        sprite: null,
        jumpVelocity: -450,
        isJumping: false,
        isDoubleJumping: false,
        setup: function () {
            player.sprite = this.game.add.sprite(100, 450, 'player');
            player.sprite.anchor.set(0.5);
            this.game.physics.arcade.enable(player.sprite);
            player.sprite.body.gravity.y = 750;
        },
        jump: function () {
            if(player.sprite.body.touching.down) {
                player.isJumping = true;
                doJump.apply(this);
            }
            else if(!player.isDoubleJumping) {
                player.isDoubleJumping = true;
                doJump.apply(this);
            }

            function doJump() {
                // this.jumpSound.play();
                this.game.add.tween(player.sprite).to({ angle: 360 }, 750, Phaser.Easing.Exponential.Out).start();
                player.sprite.body.velocity.y = player.jumpVelocity || -450;
            }
        },
        groundCollision: function (playerSprite) {
            if(player.isJumping) {
                player.isJumping = false;
                player.isDoubleJumping = false;
                playerSprite.angle = 0;
            }
        },
        bloodCollision: function (player, blood) {
            // this.bloodSound.play();
            blood.kill();

            // this.particleEmitter.x = blood.x;
            // this.particleEmitter.y = blood.y;
            // this.particleEmitter.start(true, 500, null, 10);
        }
    }

    var GameState = function() {
    };

    GameState.prototype.preload = function() {
        this.game.load.image('player', 'assets/img/player.png');
        this.game.load.image('platform', 'assets/img/wallHorizontal.png');
        this.game.load.image('particle', 'assets/img/pixel.png');
        this.game.load.audio('jumpSound', 'assets/audio/jump.ogg');
        this.game.load.image('blood', 'assets/img/blood.png');
        // this.game.load.audio('bloodSound', 'assets/audio/blood.ogg');
        
        // Parallax
        this.game.load.image('mountains-back', 'assets/img/mountains-back.png');
        this.game.load.image('mountains-mid1', 'assets/img/mountains-mid1.png');
        this.game.load.image('mountains-mid2', 'assets/img/mountains-mid2.png');
    }

    GameState.prototype.create = function() {
        this.game.physics.startSystem(Phaser.Physics.ARCADE);
        this.game.stage.backgroundColor = '#697e96';

        /*------ Parallax ------*/
        this.mountainsBack = this.game.add.tileSprite(0, 
            this.game.height - this.game.cache.getImage('mountains-back').height, 
            this.game.width, 
            this.game.cache.getImage('mountains-back').height,'mountains-back'
        );
 
        this.mountainsMid1 = this.game.add.tileSprite(0, 
            this.game.height - this.game.cache.getImage('mountains-mid1').height, 
            this.game.width, 
            this.game.cache.getImage('mountains-mid1').height,'mountains-mid1'
        );
 
        this.mountainsMid2 = this.game.add.tileSprite(0, 
            this.game.height - this.game.cache.getImage('mountains-mid2').height, 
            this.game.width, 
            this.game.cache.getImage('mountains-mid2').height,'mountains-mid2'
        );  
        
        // setup initial player properties
        player.setup.apply(this);

        this.platform = this.game.add.sprite(0, this.game.world.height - 100, 'platform');
        this.game.physics.arcade.enable(this.platform);
        this.platform.body.immovable = true;
        this.platform.width = this.game.world.width;
        this.platform.height = 100;
        this.jumpSound = this.game.add.audio('jumpSound');
        // this.bloodSound = this.game.add.audio('bloodSound');

        // blood group
        this.bloods = this.game.add.group();
        this.bloods.enableBody = true;
        this.bloods.create(200, 400, 'blood');
        this.bloods.create(400, 400, 'blood');
        this.bloods.create(600, 400, 'blood');
        this.bloods.setAll('body.immovable', true);

        // this.bloodCount = 3;

        // Emissor de particulas
        // this.particleEmitter = this.game.add.emitter(0, 0, 100);
        // this.particleEmitter.makeParticles('particle');
        
    }

    GameState.prototype.update = function() {
        // Parallax
        this.mountainsBack.tilePosition.x -= 0.05;
        this.mountainsMid1.tilePosition.x -= 0.3;
        this.mountainsMid2.tilePosition.x -= 0.75;
        
        handleColliders.apply(this);
        handleInputs.apply(this);
    }    
    
    GameState.prototype.render = function() {
        // this.game.debug.inputInfo(32, 32);
    }

    function handleColliders() {
        this.game.physics.arcade.collide(player.sprite, this.platform, player.groundCollision, null, this);
        this.game.physics.arcade.overlap(player.sprite, this.bloods, player.bloodCollision, null, this);
    }

    function handleInputs() {
        
        this.game.input.onDown.add(function () {
            player.jump.apply(this);
        }, this);

    }

    gameManager.addState('game', GameState);

})();
{'fraction_non_alphanumeric': 0.14820936639118457, 'fraction_numerical': 0.017630853994490357, 'mean_word_length': 1.9206221507106462, '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': '2936960', 'n_tokens_mistral': 3586, 'n_tokens_neox': 3305, 'n_words': 413}