<commit_before><!doctype html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>Space Invaders</title>

        <style>
            html,
            body {
                height: 100%;
                background-color: black;
                margin: 0;
            }

            canvas {
                margin: 0 auto;
            }
        </style>
    </head>
    <body>

    <script src="js/phaser.min.js"></script>
    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">

    window.onload = function() {

        var player;
        var playerHealth = 100;

        // groups
        var aliens;
        var bullets;
        var explosions;
        var mines;
        var meteors;
        var enemyBullets;
        var livingEnemies = [];

        // time related vars
        var bulletTime = 0;
        var mineTime = 0;
        var firingTimer = 0;
        var meteorTimer = 0;

        // control keys
        var cursors;
        var fireButton;
        var dropButton;

        // sounds
        var s_laser;
        var s_explosion;

        var starfield;
        var backgroundScrollSpeed = 2;
        var speedInc = 0.0005;

        var WINDOW_HEIGHT = $(window).height();
        var CANVAS_WIDTH = 600;
        var CANVAS_HEIGHT = WINDOW_HEIGHT;
        var PLAYER_SHIP_WIDTH = 28;

        var game = new Phaser.Game(CANVAS_WIDTH, CANVAS_HEIGHT, Phaser.AUTO, 'Space Invaders', { preload: preload, create: create, update: update, render: render });

        function preload () {

            game.load.image('starfield', 'assets/starfield.png');
            game.load.image('ship', 'assets/player_.png');
            game.load.image('bullet', 'assets/bullet.png');
            game.load.spritesheet('invader', 'assets/invader32x32x4.png', 32, 32);
            game.load.spritesheet('explosion', 'assets/explode.png', 128, 128);
            game.load.image('mine', 'assets/mine.png');
            game.load.image('enemyBullet', 'assets/enemy-bullet.png');
            game.load.image('smallMeteor', 'assets/meteor-small.png');

            game.load.audio('s_laser', 'assets/audio/laser.wav');
            game.load.audio('s_explosion', 'assets/audio/explode.wav');

        }

        function create () {

            //  The scrolling starfield background
            starfield = game.add.tileSprite(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, 'starfield');

            //  The hero!
            player = game.add.sprite(CANVAS_WIDTH/2, 550, 'ship');
            player.anchor.setTo(0.5, 0.5);

            //  Our bullet group
            bullets = game.add.group();
            bullets.createMultiple(30, 'bullet');
            bullets.setAll('anchor.x', 0.5);
            bullets.setAll('anchor.y', 1);
            bullets.setAll('outOfBoundsKill', true);

            //  The enemy's bullets
            enemyBullets = game.add.group();
            enemyBullets.createMultiple(30, 'enemyBullet');
            enemyBullets.setAll('anchor.x', 0.5);
            enemyBullets.setAll('anchor.y', 1);
            enemyBullets.setAll('outOfBoundsKill', true);

            //  Our mines group
            mines = game.add.group();
            mines.createMultiple(30, 'mine');
            mines.setAll('anchor.x', 0.5);
            mines.setAll('anchor.y', 1);
            mines.setAll('outOfBoundsKill', true);

            //  group of meteors
            meteors = game.add.group();
            meteors.createMultiple(30, 'smallMeteor');
            meteors.setAll('anchor.x', 0.5);
            meteors.setAll('anchor.y', 1);
            meteors.setAll('outOfBoundsKill', true);

            //  The enemies
            aliens = game.add.group();
            createAliens();

            //  Explosion pool
            explosions = game.add.group();
            explosions.createMultiple(30, 'explosion');
            explosions.forEach(setupInvader, this);

            //  Controls to play the game
            cursors = game.input.keyboard.createCursorKeys();
            fireButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
            dropButton = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);

            // sounds
            s_laser = game.add.audio('s_laser');
            s_explosion = game.add.audio('s_explosion');

        }

        function update () {

            //  Scroll the background
            backgroundScrollSpeed += speedInc;
            starfield.tilePosition.y += backgroundScrollSpeed;

            //  Reset the player, then check the movement keys
            player.body.velocity.setTo(0, 0);

            if (cursors.left.isDown) {
                player.body.velocity.x = -200;
            } else if (cursors.right.isDown) {
                player.body.velocity.x = 200;
            }

            // Check if is firing
            if (fireButton.isDown) {
                fireBullet();
            }

            //  Check if it's dropping a mine
            if (dropButton.isDown) {
                dropMine();
            }

            if (game.time.now > firingTimer) {
                enemyFires();
            }

            if (game.time.now > meteorTimer) {
                sendMeteor();
            }

            //  Check if hero has moved to the other side
            if ((player.x + PLAYER_SHIP_WIDTH / 2) < 0) {
                player.x = CANVAS_WIDTH + (PLAYER_SHIP_WIDTH / 2) - 2;  //  -2 just to see the tip of the wing
            }  
            else if ((player.x - PLAYER_SHIP_WIDTH / 2) > CANVAS_WIDTH) {
                player.x = 0 - (PLAYER_SHIP_WIDTH / 2) + 2;  //  + 2 just to see the tip of the wing
            }
<commit_msg>Re-added free movement to the hero's ship<commit_after><!doctype html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>Space Invaders</title>

        <style>
            html,
            body {
                height: 100%;
                background-color: black;
                margin: 0;
            }

            canvas {
                margin: 0 auto;
            }
        </style>
    </head>
    <body>

    <script src="js/phaser.min.js"></script>
    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">

    window.onload = function() {

        var player;
        var playerHealth = 100;

        // groups
        var aliens;
        var bullets;
        var explosions;
        var mines;
        var meteors;
        var enemyBullets;
        var livingEnemies = [];

        // time related vars
        var bulletTime = 0;
        var mineTime = 0;
        var firingTimer = 0;
        var meteorTimer = 0;

        // control keys
        var cursors;
        var fireButton;
        var dropButton;

        // sounds
        var s_laser;
        var s_explosion;

        var starfield;
        var backgroundScrollSpeed = 2;
        var speedInc = 0.0005;

        // constants
        var WINDOW_HEIGHT = $(window).height();
        var CANVAS_WIDTH = 960;
        var CANVAS_HEIGHT = WINDOW_HEIGHT;
        var PLAYER_SHIP_WIDTH = 28;
        var BOTTOM_LIMIT = WINDOW_HEIGHT - 300;

        var game = new Phaser.Game(CANVAS_WIDTH, CANVAS_HEIGHT, Phaser.AUTO, 'Space Invaders', { preload: preload, create: create, update: update, render: render });

        function preload () {

            game.load.image('starfield', 'assets/starfield.png');
            game.load.image('ship', 'assets/player_.png');
            game.load.image('bullet', 'assets/bullet.png');
            game.load.spritesheet('invader', 'assets/invader32x32x4.png', 32, 32);
            game.load.spritesheet('explosion', 'assets/explode.png', 128, 128);
            game.load.image('mine', 'assets/mine.png');
            game.load.image('enemyBullet', 'assets/enemy-bullet.png');
            game.load.image('smallMeteor', 'assets/meteor-small.png');

            game.load.audio('s_laser', 'assets/audio/laser.wav');
            game.load.audio('s_explosion', 'assets/audio/explode.wav');

        }

        function create () {

            //  The scrolling starfield background
            starfield = game.add.tileSprite(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, 'starfield');

            //  The hero!
            player = game.add.sprite(CANVAS_WIDTH/2, CANVAS_HEIGHT - 320, 'ship');
            player.anchor.setTo(0.5, 0.5);

            //  Our bullet group
            bullets = game.add.group();
            bullets.createMultiple(30, 'bullet');
            bullets.setAll('anchor.x', 0.5);
            bullets.setAll('anchor.y', 1);
            bullets.setAll('outOfBoundsKill', true);

            //  The enemy's bullets
            enemyBullets = game.add.group();
            enemyBullets.createMultiple(30, 'enemyBullet');
            enemyBullets.setAll('anchor.x', 0.5);
            enemyBullets.setAll('anchor.y', 1);
            enemyBullets.setAll('outOfBoundsKill', true);

            //  Our mines group
            mines = game.add.group();
            mines.createMultiple(30, 'mine');
            mines.setAll('anchor.x', 0.5);
            mines.setAll('anchor.y', 1);
            mines.setAll('outOfBoundsKill', true);

            //  group of meteors
            meteors = game.add.group();
            meteors.createMultiple(30, 'smallMeteor');
            meteors.setAll('anchor.x', 0.5);
            meteors.setAll('anchor.y', 1);
            meteors.setAll('outOfBoundsKill', true);

            //  The enemies
            aliens = game.add.group();
            createAliens();

            //  Explosion pool
            explosions = game.add.group();
            explosions.createMultiple(30, 'explosion');
            explosions.forEach(setupInvader, this);

            //  Controls to play the game
            cursors = game.input.keyboard.createCursorKeys();
            fireButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
            dropButton = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);

            // sounds
            s_laser = game.add.audio('s_laser');
            s_explosion = game.add.audio('s_explosion');

        }

        function update () {

            //  Scroll the background
            backgroundScrollSpeed += speedInc;
            starfield.tilePosition.y += backgroundScrollSpeed;

            //  Reset the player, then check the movement keys
            player.body.velocity.setTo(0, 0);

            if (cursors.left.isDown) {
                player.body.velocity.x = -200;
                if (cursors.up.isDown) {
                    player.body.velocity.y = -200;
                } else if (cursors.down.isDown) {
                    if (player.y < BOTTOM_LIMIT) {
                        player.body.velocity.y = 200;
                    }
                }
            } else if (cursors.right.isDown) {
                player.body.velocity.x = 200;
                if (cursors.up.isDown) {
                    player.body.velocity.y = -200;
                } else if (cursors.down.isDown) {
                    if (player.y < BOTTOM_LIMIT) {
                        player.body.velocity.y = 200;
                    }
                }
            } else if (cursors.up.isDown) {
                player.body.velocity.y = -200;
            } else if (cursors.down.isDown) {
                if (player.y < BOTTOM_LIMIT) {
                    player.body.velocity.y = 200;
                }
            }

            // Check if is firing
            if (fireButton.isDown) {
                fireBullet();
            }

            //  Check if it's dropping a mine
            if (dropButton.isDown) {
                dropMine();
            }

            if (game.time.now > firingTimer) {
                enemyFires();
            }

            if (game.time.now > meteorTimer) {
                sendMeteor();
            }

            //  Check if hero has moved to the other side
            if ((player.x + PLAYER_SHIP_WIDTH / 2) < 0) {
                player.x = CANVAS_WIDTH + (PLAYER_SHIP_WIDTH / 2) - 2;  //  -2 just to see the tip of the wing
            }  
            else if ((player.x - PLAYER_SHIP_WIDTH / 2) > CANVAS_WIDTH) {
                player.x = 0 - (PLAYER_SHIP_WIDTH / 2) + 2;  //  + 2 just to see the tip of the wing
            }

{'fraction_non_alphanumeric': 0.12103769760843129, 'fraction_numerical': 0.016781516011349817, 'mean_word_length': 1.5002026753141466, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 39, 'https://': 2, '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': '1483076', 'n_tokens_mistral': 3897, 'n_tokens_neox': 3568, 'n_words': 735}