<commit_before>window.DEBUG_PROJECTILES = true;

var Projectile = function(firedBy) {
    this.position = { x: 0, y: 0 };
    this.velocity = { x: 0, y: 0 };
    this.size = { w: 11, h: 7 };
    this.renderSize = { w: 6, h: 4 };
    this.firedBy = firedBy;
    this.lifetime = 30;

    this.txBody = new Image();
    this.txBody.src = 'assets/textures/bullet.png';

    this.draw = function(ctx) {
        ctx.save();

        if (this.velocity.x < 0) {
            ctx.translate(this.position.x + this.renderSize.w, this.position.y);
            ctx.scale(-1, 1);
        } else {
            ctx.translate(this.position.x, this.position.y);
        }

        ctx.drawImage(this.txBody, 0, 0, this.size.w, this.size.h, 0, 0, this.renderSize.w, this.renderSize.h);
        ctx.restore();

        if (window.DEBUG_PROJECTILES) {
            var sq = this.getRect();

            ctx.beginPath();
            ctx.rect(sq.left, sq.top, sq.width, sq.height);
            ctx.lineWidth = 1;
            ctx.strokeStyle = 'yellow';
            ctx.stroke();
        }
    };

    this.update = function() {
        this.position.x += this.velocity.x;
        this.position.y += this.velocity.y;

        /*** Check collisions with entities ***/
        var ourBox = this.getRect();

        for (var i = 0; i < Map.entities.length; i++) {<commit_msg>Projectiles: Make velocity a bit more random<commit_after>window.DEBUG_PROJECTILES = false;

var Projectile = function(firedBy) {
    this.position = { x: 0, y: 0 };
    this.velocity = { x: 0, y: 0 };
    this.size = { w: 11, h: 7 };
    this.renderSize = { w: 6, h: 4 };
    this.firedBy = firedBy;
    this.lifetime = 30;

    this.txBody = new Image();
    this.txBody.src = 'assets/textures/bullet.png';

    this.configured = false;

    this.draw = function(ctx) {
        ctx.save();

        if (this.velocity.x < 0) {
            ctx.translate(this.position.x + this.renderSize.w, this.position.y);
            ctx.scale(-1, 1);
        } else {
            ctx.translate(this.position.x, this.position.y);
        }

        ctx.drawImage(this.txBody, 0, 0, this.size.w, this.size.h, 0, 0, this.renderSize.w, this.renderSize.h);
        ctx.restore();

        if (window.DEBUG_PROJECTILES) {
            var sq = this.getRect();

            ctx.beginPath();
            ctx.rect(sq.left, sq.top, sq.width, sq.height);
            ctx.lineWidth = 1;
            ctx.strokeStyle = 'yellow';
            ctx.stroke();
        }
    };

    this.update = function() {
        if (!this.configured) {
            this.velocity.x += Math.random() - 0.5;
            this.velocity.y += Math.random() - 0.5;
            this.configured = true;
        }

        this.position.x += this.velocity.x;
        this.position.y += this.velocity.y;

        /*** Check collisions with entities ***/
        var ourBox = this.getRect();

        for (var i = 0; i < Map.entities.length; i++) {
{'fraction_non_alphanumeric': 0.15696288729996596, 'fraction_numerical': 0.0149812734082397, 'mean_word_length': 1.8413926499032882, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3676095', 'n_tokens_mistral': 1042, 'n_tokens_neox': 965, 'n_words': 204}