<commit_before>(function () {
    "use strict";

    var levelWidth = window.innerWidth;
    var levelHeight = window.innerHeight;

    // Keep the game window sensible dimensions.
    if (levelHeight < 800) {
        levelHeight = 800;
    }

    // Setup pixi.
    var stage = new PIXI.Container();
    var renderer = PIXI.autoDetectRenderer(levelWidth, levelHeight);
    document.body.appendChild(renderer.view);

    // Setup world.
    var world = new hitagi.World();

    // Setup rooms.
    var rooms = new hitagi.Rooms(world);

    // Setup controls.
    var controls = new hitagi.Controls();
    controls.bind('m1', 'flap');
    controls.bind('m1', 'start');

    // Register systems.
    var renderSystem = new hitagi.systems.PixiRenderSystem(stage);
    world.register(renderSystem);
    renderSystem.load(['flappybird.png', 'pipe.png', 'floor.png'], function () {

    var velocitySystem = new hitagi.systems.VelocitySystem();
    world.register(velocitySystem);

    var collisionSystem = new hitagi.systems.CollisionSystem();
    world.register(collisionSystem);

    var soundSystem = new hitagi.systems.SoundSystem();
    world.register(soundSystem);
    soundSystem.volume = 1;

    var GravitySystem = function () {
        this.update = {
            gravity: function (entity, dt) {
                // Accelerate entity until it reaches terminal velocity.
                if (entity.c.velocity.yspeed < entity.c.gravity.terminal) {
                    entity.c.velocity.yspeed += hitagi.utils.delta(entity.c.gravity.magnitude, dt);
                }
            }
        };
    };
    world.register(new GravitySystem());

    var BirdSystem = function (world, rooms, controls, collisionSystem, soundSystem) {
        var that = this;
        var score = null;

        this.build = {
            score: function (entity) {
                score = entity;
            }
        };

        this.update = {
            bird: function (entity, dt) {
                // Flap wings if clicking,
                if (controls.check('flap', true)) {
                    entity.c.velocity.yspeed = -entity.c.bird.flapSpeed;
                    soundSystem.play('flap.ogg');
                }

                // Score if we hit a goal.
                if (score) {
                    test = collisionSystem.collide(entity, 'goal', x, y);

                    if (test.hit) {
                        if (!test.entity.c.goal.done) {
                            test.entity.c.goal.done = true;
                            score.c.cleared = test.entity.c.goal.n;
                            score.c.graphic.copy = test.entity.c.goal.n;
                            soundSystem.play('clear.ogg');
                        }
                    }
                }

                // Rotate bird depending on velocity.
                entity.c.graphic.rotation = entity.c.velocity.yspeed/15;

                // Stop bird from leaving the top of the screen.
                if (entity.c.position.y < 0) {
                    entity.c.position.y = 0;
                    entity.c.velocity.yspeed = 0;
                }

                // Test for hitting something which kills you.
                var x = entity.c.position.x;
                var y = entity.c.position.y;

                var test = collisionSystem.collide(entity, 'kill', x, y);
                if (test.hit) {
                    rooms.loadRoom('start');
                    soundSystem.play('die.ogg');
                    return;
                }
            }
        };
    };

    var birdSystem = new BirdSystem(
        world,
        rooms,
        controls,
        collisionSystem,
        soundSystem
    );
    world.register(birdSystem);

    var Goal, Pipe; // PipeSystem needs these entities defined.
    var PipeSystem = function (world) {
        this.update = {
            pipe: function (entity) {<commit_msg>Flappy bird example: added death system<commit_after>(function () {
    "use strict";

    var levelWidth = window.innerWidth;
    var levelHeight = window.innerHeight;

    // Keep the game window sensible dimensions.
    if (levelHeight < 800) {
        levelHeight = 800;
    }

    // Setup pixi.
    var stage = new PIXI.Container();
    var renderer = PIXI.autoDetectRenderer(levelWidth, levelHeight);
    document.body.appendChild(renderer.view);

    // Setup world.
    var world = new hitagi.World();

    // Setup rooms.
    var rooms = new hitagi.Rooms(world);

    // Setup controls.
    var controls = new hitagi.Controls();
    controls.bind('m1', 'flap');
    controls.bind('m1', 'start');

    // Register systems.
    var renderSystem = new hitagi.systems.PixiRenderSystem(stage);
    world.register(renderSystem);
    renderSystem.load(['flappybird.png', 'pipe.png', 'floor.png'], function () {

    var velocitySystem = new hitagi.systems.VelocitySystem();
    world.register(velocitySystem);

    var collisionSystem = new hitagi.systems.CollisionSystem();
    world.register(collisionSystem);

    var soundSystem = new hitagi.systems.SoundSystem();
    world.register(soundSystem);
    soundSystem.volume = 1;

    var GravitySystem = function () {
        this.update = {
            gravity: function (entity, dt) {
                // Accelerate entity until it reaches terminal velocity.
                if (entity.c.velocity.yspeed < entity.c.gravity.terminal) {
                    entity.c.velocity.yspeed += hitagi.utils.delta(entity.c.gravity.magnitude, dt);
                }
            }
        };
    };
    world.register(new GravitySystem());

    var BirdSystem = function (controls, collisionSystem, soundSystem) {
        var that = this;
        var score = null;

        this.build = {
            score: function (entity) {
                score = entity;
            }
        };

        this.update = {
            bird: function (entity, dt) {
                // Flap wings if clicking,
                if (controls.check('flap', true)) {
                    entity.c.velocity.yspeed = -entity.c.bird.flapSpeed;
                    soundSystem.play('flap.ogg');
                }

                // Stop bird from leaving the top of the screen.
                if (entity.c.position.y < 0) {
                    entity.c.position.y = 0;
                    entity.c.velocity.yspeed = 0;
                }

                // Rotate bird sprite depending on velocity.
                entity.c.graphic.rotation = entity.c.velocity.yspeed/15;

                // Score if we hit a goal.
                if (score) {
                    var x = entity.c.position.x;
                    var y = entity.c.position.y;

                    var test = collisionSystem.collide(entity, 'goal', x, y);

                    if (test.hit) {
                        if (!test.entity.c.goal.done) {
                            test.entity.c.goal.done = true;
                            score.c.cleared = test.entity.c.goal.n;
                            score.c.graphic.copy = test.entity.c.goal.n;
                            soundSystem.play('clear.ogg');
                        }
                    }
                }
            }
        };
    };
    world.register(new BirdSystem(controls, collisionSystem, soundSystem));

    var DeathSystem = function (rooms, collisionSystem, soundSystem) {
        this.update = {
            bird: function (entity, dt) {
                // Test for hitting something which kills you.
                var x = entity.c.position.x;
                var y = entity.c.position.y;

                var test = collisionSystem.collide(entity, 'kill', x, y);
                if (test.hit) {
                    rooms.loadRoom('start');
                    soundSystem.play('die.ogg');
                    return;
                }
            }
        };
    };
    world.register(new DeathSystem(rooms, collisionSystem, soundSystem));

    var Goal, Pipe; // PipeSystem needs these entities defined.
    var PipeSystem = function (world) {
        this.update = {
            pipe: function (entity) {
{'fraction_non_alphanumeric': 0.11134479772361747, 'fraction_numerical': 0.0034640603736236547, 'mean_word_length': 1.502011761064686, 'pattern_counts': {'":': 0, '<': 9, '<?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': '749997', 'n_tokens_mistral': 2282, 'n_tokens_neox': 2113, 'n_words': 492}