//everything in this is private, copyright : me 1973-2150 ... well myeah
class Scene1 extends Phaser.Scene {
    constructor(){
        super("bootGame");
    }

preload(){

    this.canvas = this.sys.game.canvas;

    var progress = this.add.graphics();
    var loadingtext = this.add.text(0,0,"Files loaded:");
    var loadertext = this.add.text(0,15,"loading assets - ...");
    loadertext.setStyle({color: '#000000'}).setAlpha(0.5);
    
    this.load.on('filecomplete', function(key,type,texture){loadertext.text += "\n" + key + " " + type;},this);

    this.load.on('fileprogress', function (map, value){

        progress.clear();
        progress.fillStyle(0xffffff, 0.5);
        progress.fillRect(0, 270, this.scene.canvas.width * value, 60);
    });

    this.load.on('complete', function(){

        loadingtext.destroy();
        progress.destroy();
        loadertext.destroy();
    });


    this.load.spritesheet('pic', '/media/nftyr/freestyle/or_20190627_twinmoons.png', {frameWidth: 40, frameHeight : 40});
    this.load.image('puk','/media/nftyr/freestyle/or_20190627_twinmoons.png');
    this.load.image('jogo','/media/logos/thumbs/jogo_waitsort2.png');
    this.load.image('jogse','/media/logos/thumbs/log_syntaxerror.png');
    this.load.image('jogzd','/media/logos/thumbs/log_zerodesign.png');
    this.load.image('jogac','/media/logos/thumbs/log_blenderalleycatgimped64.png');
    this.load.image('jogmr','/media/logos/thumbs/jogo_mehmalice.png');
    this.load.audio('bglup','/media/sound/unclebobberxenon.ogg'); 
    
    this.quotxt = 'JoG 2022\nUncle Bobber\nXenon is de Alverman miks\n\nall loaders\nxept older snippets\nare made on a 4K screen\nwith no regard for crotter\nyou wont run a c64 demo on a gameboy either\n use ctrl+/- or something if it doesnt fit\nthis is not a scroller\nbut a text object\nenjoy the wait\nwhile the universe\n2d-prints\nplanet JoG\nand\nits twin moons\nIshtar and Freyja\ntho\nsome say\nskitzo and psycho\nwhat do they know\n...\nmundanes ....';

}

create(){


    let cw = this.canvas.width
    let ch = this.canvas.height
    
    
    this.bg =this.add.image(0,ch,'puk').setOrigin(0,0).setScale(1,0).setAlpha(0).setTint('0xff0000');
    this.bglup = this.sound.add('bglup'); // huh ?
    this.bglup.loop = true;
    
    this.jogo =this.add.image(cw/2,ch,'jogo').setOrigin(0.5,0).setScale(0.5);
    this.jogse =this.add.image(cw/2,ch+300,'jogse').setOrigin(0.5,0).setScale(0.5);;
    this.jogzd =this.add.image(cw/2,ch+600,'jogzd').setOrigin(0.5,0).setScale(0.5);;
    this.jogac =this.add.image(cw/2,ch+900,'jogac').setOrigin(0.5,0).setScale(0.5);;
    this.jogmr =this.add.image(cw/2,ch+1200,'jogmr').setOrigin(0.5,0).setScale(0.5);;
    
    this.demoquote = this.add.text(cw-300,ch, this.quotxt,quotationstyle).setVisible(1);
	this.demoquote.setStroke('#444444',10);
	console.log(this.demoquote);
	this.tweens.add({


        targets:  this.demoquote,
        duration: 15000,
        y: this.demoquote.height*-1,
        ease : "Linear.easeOut",
        delay: 103000,
        repeat: -1
    });
    
    this.tweens.add({


        targets:  [this.jogo,this.jogse,this.jogzd,this.jogac,this.jogmr],
        duration: 10000,        
        y: -900,
        ease : "Bounce.easeInOut",
        delay: function(target,targetKey,value,targetIndex,totalTargets,tween){return targetIndex*1100+108000;},
        repeat: -1
    });
        
    this.tweens.add({


        targets:  [this.jogo,this.jogse,this.jogzd,this.jogac,this.jogmr],
        duration: 1000,
        scale:3,
        ease : "Elastic.easeInOut",
        delay: function(target,targetKey,value,targetIndex,totalTargets,tween){return targetIndex*666+110000;},//delay: 110000,
        yoyo:true,
        repeat: 2
    });
    
	this.tweens.add({


        targets:  [this.jogo,this.jogzd,this.jogmr],
        duration: 2666,
        x: cw+256,
        scale: 0.75,
        ease : "Sine.easeInOut",
        delay: 119000,
        yoyo: true,
        repeat: -1
    });

	this.tweens.add({


        targets:  [this.jogse,this.jogac],
        duration: 2666,
        x: 0-256,
        scale: 0.75,
        ease : "Sine.easeInOut",
        delay: 119000,
        yoyo:true,
        repeat: -1
    });


    
    this.tweens.add({

			targets: this.bg,
			duration: 2000,
			alpha:0.1,
			y:0,
			scaleY: 1,
			ease : "Bounce.easeInOut",
			yoyo: true,
			repeat: 0
		});
    
	let lus,lus2;
	this.sprites=[];
	
	for(lus=0;lus<600;lus++){

		this.sprites[lus] = this.add.sprite(20+lus*40,ch,'pic').setFrame(lus);
		
	}
	for(lus=0;lus<600;lus++){
	
		
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			alpha:0,
			x: 20+lus*40,
			y: (lus/20)*40,
			ease : "Bounce.easeInOut",
			yoyo: true,
			delay: lus*10,
			repeat: 0
		});

		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			alpha:1,
			x: Math.floor(Math.random()*cw),
			y: Math.floor(Math.random()*ch),
			ease : "Elastic.easeInOut",
			yoyo: false,
			delay: 5000+lus*1,
			repeat: 0
		});

		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			alpha:0.5,
			//x: 0,
			y: Math.floor(Math.random()*lus),
			ease : "Cubic.easeOut",
			yoyo: false,
			delay: 7700+lus*10,
			repeat: 0
		});

		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			alpha:0,
			x: Math.random()*128,
			y: Math.random()*128,
			ease : "Bounce.easeOut",
			delay: 11000+(lus*10),
			repeat: 0
		});

			this.tweens.add({

			targets:  this.sprites[lus],
			duration: 1000,
			alpha:1,
			x: 0,
			y: 0,
			//ease : "Bounce.easeOut",
			delay: 14000+(lus*10),
			repeat: 0
		});
	}
/*
	
	

		

	
	
*/	
	for(lus2=0;lus2<30;lus2++){

		for(lus=0;lus<20;lus++){

			this.tweens.add({

				targets:  this.sprites[lus+lus2*20],
				duration: 2000,
				alpha:1,
				scale:2,
				x: 20+lus*40,
				y: 20+lus2*40,
				ease : "Sine.easeInOut",
				delay: 20000+(lus*500)+20+lus2*40,
				repeat: 0
			});

		}
	}

	for(lus=0;lus<600;lus++){

		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			alpha:0.1,
			scale:3,
			rotation:360,
			ease : "Bounce.easeOut",
			delay: 29400+(lus*10),
			repeat: 0
		});
	}
	
	for(lus2=0;lus2<30;lus2++){

		for(lus=0;lus<20;lus++){

			this.tweens.add({

				targets:  this.sprites[lus+lus2*20],
				duration: 1500,
				alpha:1,
				scale:0.1,
				x: 20+lus*40,
				y: 20+lus2*40,
				ease : 'Cubic.easeInOut',
				delay: 36400+(lus*200),
				repeat: 0
			});

		}
	}
//suckin
		for(lus=0;lus<600;lus++){

		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 6000,
			alpha:0.1,
			scale:3,
			rotation:0,
			x: cw/2,
			y: ch/2,
			ease : "Bounce.easeOut",
			delay: 42400,
			repeat: 0
		});
	}

	for(lus=0;lus<600;lus++){
	
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			rotation: 45,
			scale: function(target,targetKey,value,targetIndex,totalTargets,tween){return targetIndex/100;},//0.1,
			ease : "Elastic.easeInOut",
			delay: 48000+(lus*10),
			repeat: 0
		});
		}
		
		for(lus=0;lus<600;lus++){
	
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 1000,
			scale: 2.5,//function(target,targetKey,value,targetIndex,totalTargets,tween){return targetIndex*100;},//2.5,
			ease : "Elastic.easeInOut",
			delay: 49500+(lus*10),
			repeat: 0
		});
		}



	for(lus=0;lus<600;lus++){
	
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 4000,
			x: cw/2,
			y: ch/2,
			scale:0.1,
			rotation: 360,
			ease : "Elastic.easeInOut",
			delay: 50000+(lus*10),
			repeat: 0
		});
		}


	for(lus=0;lus<600;lus++){

			this.tweens.add({

			targets:  this.sprites[lus],
			duration: 1000,
			alpha:0.25,
			x: 0,
			y: Math.round((lus/20))*40,
			ease : "Cubic.easeOut",
			delay: 50200+(lus*10),
			repeat: 0
		});
	}


	for(lus=0;lus<600;lus++){
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 4000,
			x: cw/2,
			y: ch/2,
			scale:0.1,
			rotation: 360,
			ease : "Elastic.easeInOut",
			delay: 50800+(lus*10),
			repeat: 0
		});
	}

	for(lus=0;lus<600;lus++){
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 4000,
			alpha:1,
			ease : "Elastic.easeInOut",
			delay: 53300+(lus*10),
			repeat: 0
		});
	}

	for(lus2=0;lus2<30;lus2++){

		for(lus=0;lus<20;lus++){

			this.tweens.add({

				targets:  this.sprites[lus+lus2*20],
				duration: 2000,
				alpha:0.5,
				rotation:0,
				x: 20+lus*40,
				y: 20+lus2*40,
				ease : "Quadratic.easeOut",
				delay: 62500,
				repeat: 0
			});
		}
	}
	
	for(lus=0;lus<600;lus++){
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			scale:2,
			ease : "Bounce.easeInOut",
			delay: 62500,
			yoyo:true,
			repeat: 0
		});
	}
	
	for(lus=0;lus<600;lus++){
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			scale:1,
			ease : "Bounce.easeInOut",
			delay: 63000,
			yoyo:true,
			repeat: 1
		});
	}
	
		for(lus2=0;lus2<30;lus2++){

		for(lus=0;lus<20;lus++){

			this.tweens.add({

				targets:  this.sprites[lus+lus2*20],
				duration: 2000,
				alpha:0.3,
				scale:4,
				rotation:-360,
				x: cw/2,//20+lus*40,
				y: ch/2,//20+lus2*40,
				ease : "Bounce.easeInOut",
				delay: 65000+(lus*500),
				yoyo:true,
				repeat: 0
			});
		}
	}

	
	for(lus2=0;lus2<30;lus2++){

		for(lus=0;lus<20;lus++){

			this.tweens.add({

				targets:  this.sprites[lus+lus2*20],
				duration: 8000,
				alpha:0.4,
				x: cw + (20 + lus*40),
				y: 20+lus2*40,
				ease : 'Elastic.easeInOut',
				delay: 79000,
				repeat: 0
				
			});

		}
	}
	//movleft
	for(lus2=0;lus2<30;lus2++){

		for(lus=0;lus<20;lus++){
			
			this.tweens.add({

				targets:  this.sprites[lus+lus2*20],
				duration: 4000,
				alpha:0.4,
				x: -cw - (20 - lus*40),
				y: 20+lus2*40,
				ease : 'Quadratic.easeInOut',
				delay: 88000,
				repeat: 0
				
			});
		}
	}
	//movbakrite
	for(lus2=0;lus2<30;lus2++){

		for(lus=0;lus<20;lus++){
			
			this.tweens.add({

				targets:  this.sprites[lus+lus2*20],
				duration: 1000,
				x: 20 + lus*40,
				y: 20+lus2*40,
				ease : 'Bounce.easeOut',
				delay: 93000,
				repeat: 0
				
			});
		}
	}

	
	for(lus=0;lus<600;lus++){
			this.tweens.add({

			targets:  this.sprites[lus],
			duration: 1000,
			alpha:0.4,
			scale:10,
			x: cw+(20+lus*40),
			y: ch,//Math.round((lus/20))*40,
			ease : "Cubic.easeOut",
			
			delay: 98000+(lus*1500),
			yoyo:true,
			repeat: 0
		});
	}


		for(lus=0;lus<600;lus++){
		this.tweens.add({

			targets:  this.sprites[lus],
			duration: 2000,
			alpha:1,
			scale:1,
			
			
			ease : "Bounce.easeInOut",
			delay: 100000+(lus*1500),
			repeat: 0
		});
	}
	
	this.bglup.play();

}

update(){

}        


}//this is the EOF-1
