<commit_before><!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Template</title>

<style>
* {
	padding: 0;
	margin: 0;
}

body {
	overflow: hidden;
	background: #e4e6e8;
}

#canvas {
	display: block;
	margin: 0px auto 0px;
	background: #9b59b6;
	box-shadow: 2px 2px 8px 0px rgba(0,0,0,0.1);
    -webkit-user-select: none;
}

h2 {
    text-align: center;
    margin-top: 40px;
}

</style>

</head>

<body>
<h2>Box Jump</h2>

<canvas id="canvas" width="600" height="200"></canvas>

<script src="../lib/quintus-all.js"></script>

<script>
"use strict";

var line;

var map = [
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

    [0, 0, 5, 5, 5, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0],
    [0, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 3],
    [0, 0, 0, 0, 2, 3, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 2, 2, 0, 0],
    [0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0],
    [0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2],

    [0, 0, 5, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 2],
    [0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 2, 2, 0, 0, 5],
    [0, 0, 0, 0, 2, 3, 2, 0, 0, 0, 5, 5, 0, 0, 0, 2, 3, 2, 0, 0, 0, 0],
    [0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 5, 0, 0, 0, 0, 2],
    [0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0],

    [0, 0, 0, 0, 4, 0, 0, 0, 0, 5, 0, 0, 0, 3, 3, 0, 0, 0, 0, 5, 0, 0],
    [0, 0, 0, 0, 0, 5, 0, 0, 2, 2, 0, 0, 0, 0, 5, 5, 0, 0, 0, 4, 0, 0],
    [0, 0, 0, 0, 1, 4, 1, 0, 0, 0, 0, 1, 4, 1, 0, 0, 0, 0, 0, 1, 4, 1],
    [0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 2, 0, 0]];


window.onload = function() {
	var Q = Quintus({development: true, audioSupported: ['wav']})
		.include("Sprites, Input, Scenes, Audio, Touch, UI")
		.setup('canvas')
		.enableSound()
		.controls()
        .touch();

    Q.Sprite.extend("Cube", {
        init: function(p) {
            this._super(p, {
                asset: 'cube.png',
                type: Q.SPRITE_DEFAULT | Q.SPRITE_ENEMY
            });
        },
        draw: function(ctx) {
            ctx.drawImage(Q.asset(this.p.asset), -this.p.cx, -this.p.cy, this.p.w, this.p.h);
        }
    });

    Q.Sprite.extend("Pixel", {
        init: function(p) {
            this._super(p, {
                asset: 'pixel.png',
                vx: 0,
                vy: 0,
                vr: 500,
                alive: true,
                life: 30,
                type: Q.SPRITE_NONE
            });
        },
        step: function(dt) {
            this.p.x += this.p.vx * dt;
            this.p.y += this.p.vy * dt;

            this.p.angle += this.p.vr * dt;

            this.p.alive = this.p.life-- > 0;
            if(!this.p.alive) this.destroy();
        }
    });

	Q.Sprite.extend("Player", {
		init: function(p) {
			this._super(p, {
				asset: 'player.png',
				x: 60,
				y: Math.floor(2*Q.height/3) - 40,
				vx: 0,
				vy: 0,
				vr: 0,
				gravity: 620,
				canJump: false,
				jumpForce: -230,
				alive: true,
                type: Q.SPRITE_DEFAULT | Q.SPRITE_FRIENDLY
			});
            this.on('hit', this, 'hitTest');
            // Q.input.on('fire', this, 'jump');
		},
        // jump: function() {
        //     if(this.p.canJump) {
        //         this.p.canJump = false;
        //         this.p.vy = this.p.jumpForce;
        //         this.p.vr = 460;
        //         Q.audio.play('jump.wav');
        //     }
        // },
		step: function(dt) {
            this.stage.collide(this, {collisionMask: Q.SPRITE_ENEMY});

            if(Q.inputs['fire'] && this.p.canJump) {
                this.p.canJump = false;
                this.p.vy = this.p.jumpForce;
                this.p.vr = 460;
                Q.audio.play('jump.wav');
            }

		    this.p.angle += this.p.vr * dt;

		    this.p.x += this.p.vx * dt;
		    this.p.y += this.p.vy * dt;

		    if(this.p.x + this.p.w/2 > line.p.x + line.p.w/2) {
		        this.reset();
                // Q.state.inc("level", 1);
		        if(Q.state.get('level') < 20) {
                    Q.state.inc("level", 1);
                    drawLevel(map[Q.state.get('level')-1]);
		        }
		        else {
                    this.alive = false;
                    Q.audio.stop("music.wav");
                    Q.clearStage(1);
                    Q.stageScene('EndGame');
		        }
		    }

		    if(this.p.y + this.p.h/2 > line.p.y - line.p.h/2) {
		        this.p.y = line.p.y + line.p.h/2 - this.p.h/2;
		        this.p.vy = -this.p.gravity * dt;
		        this.p.vx = 170;
		        this.p.vr = 0;
		        this.p.angle = 0;
		        this.p.canJump = true;
		    }

		    this.p.vy += this.p.gravity * dt;
		},
        hitTest: function(col) {
            // if(col.obj.isA("Cube")) {
                createExplosion(this.p.x, this.p.y);
                this.reset();
                Q.state.inc("hits", 1);
                Q.audio.play('hit.wav');
            // }
        },
		reset: function() {
		    this.p.x = 60;
		    this.p.y = Math.floor(2*Q.height/3) - 40;
		    this.p.canJump = false;
		    this.p.vx = 0;
		    this.p.angle = 0;
		    this.p.vr = 0;
		}
	});

    function drawLevel(maap) {
        Q('Cube').destroy();

        var y = Math.floor(Q.height * 2 / 3);

        for (var i = 0; i < maap.length; i++) {
            var x = 110 + i * 20;

            if (maap[i] == 1) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 3, w: 20, h: 20 * 0.3}));
            }
            else if (maap[i] == 2) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 10, w: 20, h: 20 * 1}));
            }
            else if (maap[i] == 3) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 15, w: 20, h: 20 * 1.5}));
            }
            else if (maap[i] == 4) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 18, w: 20, h: 20 * 1.8}));
            }
            else if (maap[i] == 5) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 27, w: 20, h: 20 * 0.5}));
            }
        }
    }

    function createExplosion(x, y) {
        for(var i = 0; i < 10; i++) {
            var radius = Math.random() * 100;
            var angle = Math.random() * (2 * Math.PI);
            var vx = Math.cos(angle) * radius;
            var vy = Math.sin(angle) * radius;
            var life = Math.random() * 10 + 30
            Q.stage().insert(new Q.Pixel({x: x, y: y, vx: vx, vy: vy, life: life}));
        }
    }

	Q.scene('main', function(stage) {
	    line = stage.insert(new Q.Sprite({
	        asset: "line.png",
	        x: Q.width/2,
	        y: Math.floor(2*Q.height/3),
            type: Q.SPRITE_NONE
	    }));

	    var player = stage.insert(new Q.Player());
 	});

    Q.scene("EndGame", function(stage) {
        stage.insert(new Q.UI.Text({
            label: "you finished the game! :-D",
            x: Q.width/2,
            y: Q.height/2 - 26,
            color: "white",
            size: 30,
            weight: 400
        }));

        stage.insert(new Q.UI.Text({
            label: 'and died '+Q.state.get("hits")+' times\ncan you do better?',
            x: Q.width/2,
            y: Q.height/2 + 20,
            color: "white",
            size: 20,
            weight: 400
        }));
    });

    Q.scene("Hud", function(stage) {
        var hitsTxt = stage.insert(new Q.UI.Text({
            label: "Hits: " + Q.state.get("hits"),
            x: 100,
            y: Q.height - 35,
            color: "white",
            size: 18,
            weight: 400,
            align: 'center'
        }));
        Q.state.on("change.hits", hitsTxt, function(val) {
            this.p.label = "Hits: " + val;
        });

        stage.insert(new Q.UI.Text({
            label: "press space to jump",
            x: Q.width/2,
            y: Q.height - 35,
            color: "white",
            size: 18,
            weight: 400,
            align: 'center'
        }));

        var levelTxt = stage.insert(new Q.UI.Text({
            label: "Level: "+Q.state.get("level")+'/'+ map.length,
            x: Q.width - 100 + 0.5,
            y: Q.height - 35,
            color: "white",
            size: 18,
            weight: 400,
            align: 'center'
        }));
        Q.state.on("change.level", levelTxt, function(val) {
            this.p.label = "Level: " + val +'/'+ map.length;
        });
    });

	Q.load(["player.png", "cube.png", "pixel.png", "line.png", "hit.wav", "jump.wav", "music.wav"], function() {
        Q.stageScene('main');
        Q.state.reset({ hits: 0, level: 1 });
        Q.stageScene('Hud', 1);
        Q.audio.play('music.wav', { loop: true });
        drawLevel(map[Q.state.get("level")-1]);
	});
};

</script>
</body>
</html>
<commit_msg>lessmilk.com credit<commit_after><!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Template</title>

<style>
* {
	padding: 0;
	margin: 0;
}

body {
	overflow: hidden;
	background: #e4e6e8;
}

#canvas {
	display: block;
	margin: 0px auto 0px;
	background: #9b59b6;
	box-shadow: 2px 2px 8px 0px rgba(0,0,0,0.1);
    -webkit-user-select: none;
}

h2 {
    text-align: center;
    margin-top: 40px;
}

</style>

</head>

<body>
<h2>Box Jump</h2>

<canvas id="canvas" width="600" height="200"></canvas>

<script src="../lib/quintus-all.js"></script>

<script>
"use strict";

// Original BoxJump at lessmilk.com

var line;

var map = [
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [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, 0, 0, 4, 0, 0, 0, 0, 5, 0, 0, 0, 3, 3, 0, 0, 0, 0, 5, 0, 0],
    [0, 0, 0, 0, 0, 5, 0, 0, 2, 2, 0, 0, 0, 0, 5, 5, 0, 0, 0, 4, 0, 0],
    [0, 0, 0, 0, 1, 4, 1, 0, 0, 0, 0, 1, 4, 1, 0, 0, 0, 0, 0, 1, 4, 1],
    [0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 2, 0, 0]];


window.onload = function() {
	var Q = Quintus({development: true, audioSupported: ['wav']})
		.include("Sprites, Input, Scenes, Audio, Touch, UI")
		.setup('canvas')
		.enableSound()
		.controls()
        .touch();

    Q.Sprite.extend("Cube", {
        init: function(p) {
            this._super(p, {
                asset: 'cube.png',
                type: Q.SPRITE_DEFAULT | Q.SPRITE_ENEMY
            });
        },
        draw: function(ctx) {
            ctx.drawImage(Q.asset(this.p.asset), -this.p.cx, -this.p.cy, this.p.w, this.p.h);
        }
    });

    Q.Sprite.extend("Pixel", {
        init: function(p) {
            this._super(p, {
                asset: 'pixel.png',
                vx: 0,
                vy: 0,
                vr: 500,
                alive: true,
                life: 30,
                type: Q.SPRITE_NONE
            });
        },
        step: function(dt) {
            this.p.x += this.p.vx * dt;
            this.p.y += this.p.vy * dt;

            this.p.angle += this.p.vr * dt;

            this.p.alive = this.p.life-- > 0;
            if(!this.p.alive) this.destroy();
        }
    });

	Q.Sprite.extend("Player", {
		init: function(p) {
			this._super(p, {
				asset: 'player.png',
				x: 60,
				y: Math.floor(2*Q.height/3) - 40,
				vx: 0,
				vy: 0,
				vr: 0,
				gravity: 620,
				canJump: false,
				jumpForce: -230,
				alive: true,
                type: Q.SPRITE_DEFAULT | Q.SPRITE_FRIENDLY
			});
            this.on('hit', this, 'hitTest');
            // Q.input.on('fire', this, 'jump');
		},
        // jump: function() {
        //     if(this.p.canJump) {
        //         this.p.canJump = false;
        //         this.p.vy = this.p.jumpForce;
        //         this.p.vr = 460;
        //         Q.audio.play('jump.wav');
        //     }
        // },
		step: function(dt) {
            this.stage.collide(this, {collisionMask: Q.SPRITE_ENEMY});

            if(Q.inputs['fire'] && this.p.canJump) {
                this.p.canJump = false;
                this.p.vy = this.p.jumpForce;
                this.p.vr = 460;
                Q.audio.play('jump.wav');
            }

		    this.p.angle += this.p.vr * dt;

		    this.p.x += this.p.vx * dt;
		    this.p.y += this.p.vy * dt;

		    if(this.p.x + this.p.w/2 > line.p.x + line.p.w/2) {
		        this.reset();
                // Q.state.inc("level", 1);
		        if(Q.state.get('level') < 20) {
                    Q.state.inc("level", 1);
                    drawLevel(map[Q.state.get('level')-1]);
		        }
		        else {
                    this.alive = false;
                    Q.audio.stop("music.wav");
                    Q.clearStage(1);
                    Q.stageScene('EndGame');
		        }
		    }

		    if(this.p.y + this.p.h/2 > line.p.y - line.p.h/2) {
		        this.p.y = line.p.y + line.p.h/2 - this.p.h/2;
		        this.p.vy = -this.p.gravity * dt;
		        this.p.vx = 170;
		        this.p.vr = 0;
		        this.p.angle = 0;
		        this.p.canJump = true;
		    }

		    this.p.vy += this.p.gravity * dt;
		},
        hitTest: function(col) {
            // if(col.obj.isA("Cube")) {
                createExplosion(this.p.x, this.p.y);
                this.reset();
                Q.state.inc("hits", 1);
                Q.audio.play('hit.wav');
            // }
        },
		reset: function() {
		    this.p.x = 60;
		    this.p.y = Math.floor(2*Q.height/3) - 40;
		    this.p.canJump = false;
		    this.p.vx = 0;
		    this.p.angle = 0;
		    this.p.vr = 0;
		}
	});

    function drawLevel(maap) {
        Q('Cube').destroy();

        var y = Math.floor(Q.height * 2 / 3);

        for (var i = 0; i < maap.length; i++) {
            var x = 110 + i * 20;

            if (maap[i] == 1) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 3, w: 20, h: 20 * 0.3}));
            }
            else if (maap[i] == 2) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 10, w: 20, h: 20 * 1}));
            }
            else if (maap[i] == 3) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 15, w: 20, h: 20 * 1.5}));
            }
            else if (maap[i] == 4) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 18, w: 20, h: 20 * 1.8}));
            }
            else if (maap[i] == 5) {
                Q.stage().insert(new Q.Cube({x: x, y: y - 27, w: 20, h: 20 * 0.5}));
            }
        }
    }

    function createExplosion(x, y) {
        for(var i = 0; i < 10; i++) {
            var radius = Math.random() * 100;
            var angle = Math.random() * (2 * Math.PI);
            var vx = Math.cos(angle) * radius;
            var vy = Math.sin(angle) * radius;
            var life = Math.random() * 10 + 30
            Q.stage().insert(new Q.Pixel({x: x, y: y, vx: vx, vy: vy, life: life}));
        }
    }

	Q.scene('main', function(stage) {
	    line = stage.insert(new Q.Sprite({
	        asset: "line.png",
	        x: Q.width/2,
	        y: Math.floor(2*Q.height/3),
            type: Q.SPRITE_NONE
	    }));

	    var player = stage.insert(new Q.Player());
 	});

    Q.scene("EndGame", function(stage) {
        stage.insert(new Q.UI.Text({
            label: "you finished the game! :-D",
            x: Q.width/2,
            y: Q.height/2 - 26,
            color: "white",
            size: 30,
            weight: 400
        }));

        stage.insert(new Q.UI.Text({
            label: 'and died '+Q.state.get("hits")+' times\ncan you do better?',
            x: Q.width/2,
            y: Q.height/2 + 20,
            color: "white",
            size: 20,
            weight: 400
        }));
    });

    Q.scene("Hud", function(stage) {
        var hitsTxt = stage.insert(new Q.UI.Text({
            label: "Hits: " + Q.state.get("hits"),
            x: 100,
            y: Q.height - 35,
            color: "white",
            size: 18,
            weight: 400,
            align: 'center'
        }));
        Q.state.on("change.hits", hitsTxt, function(val) {
            this.p.label = "Hits: " + val;
        });

        stage.insert(new Q.UI.Text({
            label: "press space to jump",
            x: Q.width/2,
            y: Q.height - 35,
            color: "white",
            size: 18,
            weight: 400,
            align: 'center'
        }));

        var levelTxt = stage.insert(new Q.UI.Text({
            label: "Level: "+Q.state.get("level")+'/'+ map.length,
            x: Q.width - 100 + 0.5,
            y: Q.height - 35,
            color: "white",
            size: 18,
            weight: 400,
            align: 'center'
        }));
        Q.state.on("change.level", levelTxt, function(val) {
            this.p.label = "Level: " + val +'/'+ map.length;
        });
    });

	Q.load(["player.png", "cube.png", "pixel.png", "line.png", "hit.wav", "jump.wav", "music.wav"], function() {
        Q.stageScene('main');
        Q.state.reset({ hits: 0, level: 1 });
        Q.stageScene('Hud', 1);
        Q.audio.play('music.wav', { loop: true });
        drawLevel(map[Q.state.get("level")-1]);
	});
};

</script>
</body>
</html>

{'fraction_non_alphanumeric': 0.2066003370847605, 'fraction_numerical': 0.07013537758930027, 'mean_word_length': 1.4013054830287206, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, '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': '66124', 'n_tokens_mistral': 8965, 'n_tokens_neox': 7438, 'n_words': 1991}