<commit_before>
import luxe.Input;
import luxe.Sprite;
import luxe.Vector;
import luxe.Color;
import phoenix.Shader;

class Main extends luxe.Game {

	var sprite1 : Sprite;
	var sprite2 : Sprite;
	var sprite3 : Sprite;

	var shader1 : Shader;
	var shader2 : Shader;
	var shader3 : Shader;

	var loaded : Bool = false;

    public function ready() {

    	var tex = Luxe.loadTexture('assets/luxe.png');
    	var tex2 = Luxe.loadTexture('assets/level.png');
    	var tex3 = Luxe.loadTexture('assets/distort.png');
    		tex2.filter = phoenix.Texture.FilterType.nearest;    	

    	var sprite1 = new Sprite({
    		texture : tex,
    		pos : new Vector(150,320)
    	});

    	var sprite2 = new Sprite({
    		texture : tex,
    		pos : new Vector(430,320)
    	});

    	var sprite3 = new Sprite({
    		texture : tex2,
    		pos : new Vector(480,320)
    	});

    	tex3.onload = function(tt) {

    		sprite1.scale = new Vector(0.5,0.5);
	    	sprite2.scale = new Vector(0.5,0.5);
	    	sprite3.scale = new Vector(4,4);

	    		//we do this separately so we can set the uniforms
	    	shader1 = Luxe.loadShader('assets/gray_tilt_shift.glsl');
	    	shader2 = Luxe.loadShader('assets/huechange.glsl');
	    	shader3 = Luxe.loadShader('assets/distort.glsl');

	    	sprite3.shader = shader1;
	    	sprite2.shader = shader2;
	    	sprite1.shader = shader3;

	    		//move to second slot
	    	tex3.slot = 1;
	    		//set the uniform
	    	shader3.set_uniform_texture('tex1', tex3);

	    	loaded = true;
    	}	



    } //ready

    public function onmousemove( e:MouseEvent ) {

    	if(loaded) {
	    	var percent = e.pos.x / Luxe.screen.w;
    		var hue = (Math.PI*2) * percent;

    		shader3.set_uniform_float('distortamount', percent);
    		shader2.set_uniform_float('in_hue', hue);
    	}

    }

    public function onkeyup( e:KeyEvent ) {

        if(e.key == KeyValue.escape) {
            Luxe.shutdown();
        }
        
    } //onkeyup

    public function update(dt:Float) {

    } //update

} //Main<commit_msg>Cleanup loading race conditions on html5, and making sure things are scaled on create etc<commit_after>
import luxe.Input;
import luxe.Sprite;
import luxe.Vector;
import luxe.Color;
import phoenix.Shader;

class Main extends luxe.Game {

	var distort_sprite : Sprite;
	var hue_sprite : Sprite;
	var level_sprite : Sprite;

	var level_tiltshift : Shader;
	var hue_shader : Shader;
	var distort_shader : Shader;

	var loaded : Bool = false;
	var loaded_logo : Bool = false;

    public function ready() {

    	var luxe_tex = Luxe.loadTexture('assets/luxe.png');
    	
    	var level_texture = Luxe.loadTexture('assets/level.png');
    		level_texture.filter = phoenix.Texture.FilterType.nearest;

    	var distort_map = Luxe.loadTexture('assets/distort.png');
    		

    	distort_sprite = new Sprite({
    		texture : luxe_tex,
    		pos : new Vector(150,320)
    	});

    	hue_sprite = new Sprite({
    		texture : luxe_tex,
    		pos : new Vector(430,320)
    	});

    	level_sprite = new Sprite({
    		texture : level_texture,
    		pos : new Vector(480,320)
    	});

    		//for the logo blocks image
    	luxe_tex.onload = function(tt) {

    		distort_sprite.scale = new Vector(0.5,0.5);
	    	hue_sprite.scale = new Vector(0.5,0.5);

	    	hue_shader = Luxe.loadShader('assets/huechange.glsl');
	    	hue_sprite.shader = hue_shader;

	    	loaded_logo = true;
    	} //luxe_tex on load

    	level_texture.onload = function(tt) {
    		level_sprite.scale = new Vector(4,4);
    		level_tiltshift = Luxe.loadShader('assets/gray_tilt_shift.glsl');
	    	level_sprite.shader = level_tiltshift;
    	} //level tex on load

    	distort_map.onload = function(tt) {
	    	
	    	distort_shader = Luxe.loadShader('assets/distort.glsl');
	    	distort_sprite.shader = distort_shader;

	    		//move to second slot
	    	distort_map.slot = 1;
	    		//set the uniform
	    	distort_shader.set_uniform_texture('tex1', distort_map);

	    	loaded = true;

    	}	


    } //ready

    public function onmousemove( e:MouseEvent ) {

    	if(loaded && loaded_logo) {

	    	var percent = e.pos.x / Luxe.screen.w;
    		var hue = (Math.PI*2) * percent;

    			//distort based on mouse x
    		distort_shader.set_uniform_float('distortamount', percent);
    			//hue based on mouse x 
    		hue_shader.set_uniform_float('in_hue', hue);
    	}

    }

    public function onkeyup( e:KeyEvent ) {

        if(e.key == KeyValue.escape) {
            Luxe.shutdown();
        }
        
    } //onkeyup

    public function update(dt:Float) {

    } //update

} //Main
{'fraction_non_alphanumeric': 0.11636522118108521, 'fraction_numerical': 0.020483765526258444, 'mean_word_length': 2.427931292008962, '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': '6487869', 'n_tokens_mistral': 1795, 'n_tokens_neox': 1675, 'n_words': 343}