
var Demo = function() {
}
var sippeKerroin=0;
var cubeNumber;
	var bpm = 115;
	var beat = 60/bpm;
	var pattern = beat*8;
	var tick = beat/4;
	var hittingOrder = 0;
var flashtexts = [
		"data/kiky.png",
		"data/chempolis.png",
		"data/yle.png",
		"data/koulutuslupaus.png",
		"data/terrafame.png",
		"data/vakuutuskuori.png",
		"data/suomi.png",
		"data/jumalauta.png"
		
];
	var currentText = 0;

Demo.prototype.init = function()
{

			this.loader.addAnimation([
		{
			"start": 0, "duration":60
			,"layer": 666666, "image": ["data/vignette.png"]
	
			,"scale":[{"x":1,"y":1}]
		}]);
		
this.earth(0*pattern,60);

// car end

this.fullScreenNoise(0,pattern*40,40000,0.15);
this.brightnessContrast(0,pattern*38.5,0,50004,50007,0.1,1.5);
//this.distortion(0,pattern*38.5,0,50000,50002);
this.hackGlow(0,pattern*38.5,50006,50008,50012);

}


Demo.prototype.earth = function(startTime, duration)
{
				this.loader.addAnimation([
					{
					"start": startTime, "duration": duration, "object":"data/earth.obj"
					,"layer": 22001
					,"position": [{"z":-2,"y":-0.45,"x":0.0}]
					,"color":[{"r":255,"g":255,"b":255,"a":255}
					,{"duration":15,"r":255,"g":255,"b":255,"a":255}
					,{"duration":35,"r":155,"g":100,"b":0,"a":255}
					,{"duration":10,"r":0,"g":0,"b":0,"a":255}]
					,"angle": [{"degreesX":15,"degreesZ":0,"degreesY":"{return getSceneTimeFromStart()*50}"}]

					,"scale": [{"x":-0.46,"y":-0.46,"z":0.46}
					,{"duration":60,"x":-0.16,"y":-0.16,"z":0.16}]
						
					}]);


					
				this.loader.addAnimation([
					{
					"start": startTime+15, "duration": duration-14, "object":"data/burn.obj"
					,"layer": 22001
					,"image": ["data/noise.png","data/noise.png"]
					,"position": [{"z":-2,"y":-0.45,"x":0.0}]
					
					,"angle": [{"degreesX":15,"degreesZ":180,"degreesY":"{return -30-getSceneTimeFromStart()*50}"}]

					,"scale": [{"x":-0.385,"y":-0.385,"z":0.385}
					,{"duration":45,"x":-0.16,"y":-0.16,"z":0.16}]
						     ,"shader":{
						"name":"data/shader/fire.fs",
						"variable":[
						{"name":"time","value":["{return 10+getSceneTimeFromStart();}"]}
						]
        }
					}]);
					

	
						this.loader.addAnimation([
    {
         "start": startTime, "duration":duration
        ,"layer": 13331, "image": ["data/empty.png"]
		,"scale":[{"x":1,"y":1}]
     ,"shader":{
            "name":"data/shader/starfield2.fs",
            "variable":[
                  {"name":"time","value":["{return -4.0*getSceneTimeFromStart();}"]},

            ]
        }
		
    }
]);
					
}

Demo.prototype.explosion = function(startTime, duration, positionX, positionY, positionZ, scale)
{

	for(ie=0;ie<100;ie++)
	{
	
	cubeNumber++;
	var randomScale = Math.random();
				this.loader.addAnimation([
						{
						"start": startTime, "duration": duration,  "object":"cubes"+cubeNumber,"shape":{"type":"CUBE"}
						,"layer": 39100
						
						,"position": [{"x":positionX+Math.random()*.2-Math.random()*.2,"y":positionY+Math.random()*.2-Math.random()*.2,"z":positionZ+Math.random()*.2-Math.random()*.2}
						,{"duration":duration, "x":positionX+Math.random()*3-Math.random()*3,"y":positionY+Math.random()*3-Math.random()*3,"z":positionZ+Math.random()*3-Math.random()*3}]
						,"scale":[{"x":scale*randomScale,"y":scale*randomScale,"z":scale*randomScale}]
						,"color":[{"r":255,"g":255,"b":255,"a":255}
						,{"duration":duration, "a":0}
						]
					}]);
	}
}
Demo.prototype.car = function(startTime, duration)
{
			this.loader.addAnimation([
					{
					"start": startTime, "duration": duration, "object":"data/car.obj"
					,"layer": 20000
					,"position": [{"z":-5,"y":-1.0,"x":0.0}
					, {"duration":4*pattern,"z":-13,"y":-2.0,"x":-1.0}]
					,"angle": [{"degreesZ":0,"degreesZ":0,"degreesY":"{return 300-(Math.sin(getSceneTimeFromStart()*.05))*360}"}]

					,"scale": [{"x":1.5,"y":1.5,"z":1.5}]
						
					}]);
					
					
			this.loader.addAnimation([
					{
					"start": startTime, "duration": duration, "object":"data/roadobject.obj"
					,"layer": 19000
				,"position": [{"z":-5,"y":0.0,"x":0.0}
					, {"duration":4*pattern,"z":-20,"y":-1.0,"x":0.0}]
					,"angle": [{"degreesZ":0,"degreesZ":0,"degreesY":"{return 300-(Math.sin(getSceneTimeFromStart()*.05))*360}"}]

					,"scale": [{"x":3.5,"y":3.5,"z":3.5}]
						     ,"shader":{
            "name":"data/shader/scroll.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart();}"]}
				 ,{"name":"speedX","value":[0.0]}
				 ,{"name":"speedY","value":[-5.4]}
            ]
        }
					}]);
}

/*
Demo.prototype.cityScene = function(startTime, duration)
{
	var randomi;
	for(var ii=0; ii < 2; ii++)
	{
		for(var i=0; i < 200; i++)
		{
		randomi=Math.random();
			sceneLoader.addAnimation([
		{
			"start": sceneStartTime, "duration":sceneEndTime-sceneStartTime, "object":"cubes2"+i,"shape":{"type":"CUBE"}
			,"layer": "00001"
			,"camera": "Cam01"
			,"scale":[
				{"x":0.5+randomi,"z":0.5+randomi,"y":5.5+randomi}
			]
			,"color":[
			{"r":0,"g":Math.random()*155+100,"b":0,"a":Math.random()*205+50}
			]
			
			,"position":[
			{"x":-4+8*ii,"y":0,"z":50-2*i}
		]
		}]);
	}
	}
}
*/
Demo.prototype.syncPattern1 = function(startTime, characterScale, xPosition, yPosition)
{
this.attack(startTime,beat,characterScale,xPosition,yPosition);

this.attack(startTime+beat,beat,characterScale,xPosition,yPosition);

this.attack(startTime+beat*2,beat,characterScale,xPosition,yPosition);

this.attack(startTime+beat*3,tick,characterScale,xPosition,yPosition);
this.attack(startTime+beat*3+tick,tick,characterScale,xPosition,yPosition); 
this.attack(startTime+beat*3+tick*2,tick,characterScale,xPosition,yPosition); 
this.attack(startTime+beat*3+tick*3,tick,characterScale,xPosition,yPosition); 
this.attack(startTime+beat*4,beat,characterScale,xPosition,yPosition);
this.attack(startTime+beat*5,beat,characterScale,xPosition,yPosition);
this.attack(startTime+beat*6,beat,characterScale,xPosition,yPosition);
this.attack(startTime+beat*7,beat,characterScale,xPosition,yPosition);
}

Demo.prototype.syncPattern0 = function(startTime, characterScale, xPosition, yPosition,i2)
{
this.attackTrain(startTime,beat,characterScale,xPosition,yPosition,i2);

this.attackTrain(startTime+beat,beat,characterScale,xPosition,yPosition,i2);

this.attackTrain(startTime+beat*2,beat,characterScale,xPosition,yPosition,i2);

this.attackTrain(startTime+beat*3,tick,characterScale,xPosition,yPosition,i2);
this.attackTrain(startTime+beat*3+tick,tick,characterScale,xPosition,yPosition,i2); 
this.attackTrain(startTime+beat*3+tick*2,tick,characterScale,xPosition,yPosition,i2); 
this.attackTrain(startTime+beat*3+tick*3,tick,characterScale,xPosition,yPosition,i2); 
this.attackTrain(startTime+beat*4,beat,characterScale,xPosition,yPosition,i2);
this.attackTrain(startTime+beat*5,beat,characterScale,xPosition,yPosition,i2);
this.attackTrain(startTime+beat*6,beat,characterScale,xPosition,yPosition,i2);
this.attackTrain(startTime+beat*7,beat,characterScale,xPosition,yPosition,i2);
}

Demo.prototype.syncPattern2 = function(startTime, characterScale, xPosition, yPosition)
{
this.fistAttack(startTime,beat,characterScale,xPosition,yPosition);
this.fistAttack(startTime+beat,beat,characterScale,xPosition,yPosition);
this.fistAttack(startTime+beat*2,beat,characterScale,xPosition,yPosition);
this.fistAttack(startTime+beat*3,beat,characterScale,xPosition,yPosition);
this.fistAttack(startTime+beat*4,beat,characterScale,xPosition,yPosition);
this.fistAttack(startTime+beat*5,beat,characterScale,xPosition,yPosition);
this.fistAttack(startTime+beat*6,beat,characterScale,xPosition,yPosition);
this.fistAttack(startTime+beat*7,beat,characterScale,xPosition,yPosition);
}

Demo.prototype.character1neutral = function(startTime, duration, characterScale, xPosition, yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_neutral.png"
			,"scale":[{"x":characterScale,"y":characterScale}]
			,"position":[{"x":xPosition-40*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.character1damage = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_damage.png"
			,"scale":[{"x":characterScale,"y":characterScale}]
			,"position":[{"x":xPosition-40*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.character2damage = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_damage.png"
			,"scale":[{"x":-characterScale,"y":characterScale}]
			,"position":[{"x":xPosition+40*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.character1punch1 = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_punch1.png"
			,"scale":[{"x":characterScale,"y":characterScale}]
			,"position":[{"x":xPosition-8*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.character1punch2 = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_punch2.png"
			,"scale":[{"x":characterScale,"y":characterScale}]
			,"position":[{"x":xPosition-8*characterScale,"y":yPosition-8*characterScale}]
		}]);
}

Demo.prototype.character1kick1 = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_kick1.png"
			,"scale":[{"x":characterScale,"y":characterScale}]
			,"position":[{"x":xPosition-40*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.character1kick2 = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_kick2.png"
			,"scale":[{"x":characterScale,"y":characterScale}]
			,"position":[{"x":xPosition-28*characterScale,"y":yPosition}]
		}]);
}

//---

Demo.prototype.character1block = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_block.png"
			,"scale":[{"x":characterScale,"y":characterScale}]
			,"position":[{"x":xPosition-96*characterScale,"y":yPosition-12*characterScale}]
		}]);
}

Demo.prototype.character1crouch = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_crouch.png"
			,"scale":[{"x":characterScale,"y":characterScale}]
			,"position":[{"x":xPosition-40*characterScale,"y":yPosition}]
		}]);
}
//---

Demo.prototype.character2punch1 = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_punch1.png"
			,"scale":[{"x":-characterScale,"y":characterScale}]
			,"position":[{"x":xPosition+8*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.character2punch2 = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_punch2.png"
			,"scale":[{"x":-characterScale,"y":characterScale}]
			,"position":[{"x":xPosition+8*characterScale,"y":yPosition-8*characterScale}]
		}]);
}

Demo.prototype.character2kick1 = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_kick1.png"
			,"scale":[{"x":-characterScale,"y":characterScale}]
			,"position":[{"x":xPosition+40*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.character2kick2 = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_kick2.png"
			,"scale":[{"x":-characterScale,"y":characterScale}]
			,"position":[{"x":xPosition+28*characterScale,"y":yPosition}]
		}]);
}


Demo.prototype.character2neutral = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_neutral.png"
			,"scale":[{"x":-characterScale,"y":characterScale}]
			,"position":[{"x":xPosition+40*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.character2block = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_block.png"
			,"scale":[{"x":-characterScale,"y":characterScale}]
			,"position":[{"x":xPosition+96*characterScale,"y":yPosition-12*characterScale}]
		}]);
}

Demo.prototype.character2crouch = function(startTime, duration, characterScale,xPosition,yPosition)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": "data/character_crouch.png"
			,"scale":[{"x":-characterScale,"y":characterScale}]
			,"position":[{"x":xPosition+40*characterScale,"y":yPosition}]
		}]);
}

Demo.prototype.kuva = function(startTime, duration, pic)
{
	this.loader.addAnimation([
		{
			"start": startTime, "duration":duration
			,"layer": 39000, "image": [pic]
			,"scale":[{"x":1.5,"y":1.5}]
		}]);
}

//--

Demo.prototype.attackTrain = function(startTime, duration, characterScale,xPosition,yPosition,i2)
{
neutralDuration=tick;

if(i2==0)
{
	ii=Math.round(Math.random()*3);
	switch(ii) {
	case 0:
		this.character1kick1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character1kick2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 2:
		this.character1punch1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 3:
		this.character1punch2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
	
	this.character1neutral(startTime+duration*.75,duration*0.25, characterScale,xPosition,yPosition);
}
if(i2==1)
{
	ii=Math.round(Math.random()*3);
	switch(ii) {
	case 0:
		this.character2kick1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character2kick2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 2:
		this.character2punch1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 3:
		this.character2punch2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
	this.character2neutral(startTime+duration*.75,duration*0.25, characterScale,xPosition,yPosition);
}




}

//--
Demo.prototype.attack = function(startTime, duration, characterScale,xPosition,yPosition)
{
neutralDuration=tick;
i2=Math.round(Math.random());

if(i2==0)
{
	ii=Math.round(Math.random()*3);
	switch(ii) {
	case 0:
		this.character1kick1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character1kick2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 2:
		this.character1punch1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 3:
		this.character1punch2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
	iii=Math.round(Math.random()*2);
	switch(iii) {
	case 0:
		this.character2block(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character2damage(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 2:
		this.character2crouch(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
}
if(i2==1)
{
	ii=Math.round(Math.random()*3);
	switch(ii) {
	case 0:
		this.character2kick1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character2kick2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 2:
		this.character2punch1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 3:
		this.character2punch2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
	iii=Math.round(Math.random()*2);
	switch(iii) {
	case 0:
		this.character1block(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character1damage(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 2:
		this.character1crouch(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
}

this.character1neutral(startTime+duration*.75,duration*0.25, characterScale,xPosition,yPosition);
this.character2neutral(startTime+duration*.75,duration*0.25, characterScale,xPosition,yPosition);

}


Demo.prototype.fistAttack = function(startTime, duration, characterScale,xPosition,yPosition, i2)
{
neutralDuration=tick;
i2=Math.round(Math.random());

if(hittingOrder==0)
{
	hittingOrder=01;
	ii=Math.round(Math.random());
	switch(ii) {
	case 0:
		this.character1punch1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character1punch2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;

	}
	iii=Math.round(Math.random()*2);
	switch(iii) {
	case 0:
		this.character2block(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character2damage(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 2:
		this.character2crouch(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
}
else
{
	hittingOrder=0;
	ii=Math.round(Math.random());
	switch(ii) {
	case 0:
		this.character2punch1(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character2punch2(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
	iii=Math.round(Math.random()*2);
	switch(iii) {
	case 0:
		this.character1block(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 1:
		this.character1damage(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	case 2:
		this.character1crouch(startTime,duration*.75, characterScale,xPosition,yPosition);
		 break;
	}
}

this.character1neutral(startTime+duration*.75,duration*0.25, characterScale,xPosition,yPosition);
this.character2neutral(startTime+duration*.75,duration*0.25, characterScale,xPosition,yPosition);

}
/*
	this.loader.addAnimation([
    {
         "start": startTime, "duration":6*pattern
        ,"layer": 40000, "image": ["data/noise.png","data/noise.png"]
		,"scale":[{"x":1.0,"y":1.0}]
     ,"shader":{
            "name":"data/shader/fire.fs",
            "variable":[
                  {"name":"time","value":["{return "{return getSceneTimeFromStart();}"]}
            ]
        }
		
    }
]);
*/


Demo.prototype.distortion = function(startTime, duration, startLayer, endLayer, layer)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fbodist","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fbodist","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	{
		 "start": startTime, "duration": duration
		,"image": "fbodist.color.fbo"
		,"layer": layer
		,"shader":{"name":"data/shader/distortion.fs",
			"variable":[
				 {"name":"time","value":["{return getSceneTimeFromStart();}"]}
				,{"name":"timeMultiplier","value":[3.9]}
				,{"name":"pixelSize","value":["{return Math.random()*0.02;}",0.001]}
				,{"name":"noiseWaveSpeed","value":[-1]}
				,{"name":"noiseWaveSize","value":[1]}
				,{"name":"noiseLuminance","value":[1]}
				,{"name":"noiseAlpha","value":[0.0]}
				,{"name":"colorComponentDistortionX","value":[0.005,0.005,0.005,0.005]}
				,{"name":"colorComponentDistortionY","value":[0.01,0.01,0.01,0.01]}
			]
			}
		}]);
}

Demo.prototype.scanline = function(startTime, duration, startLayer, endLayer, layer)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fboscan","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fboscan","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	{
		 "start": startTime, "duration": duration
		,"image": "fboscan.color.fbo"
		,"layer": layer
		,"shader":{"name":"data/shader/scanline.fs",
			"variable":[
				 {"name":"time","value":["{return getSceneTimeFromStart();}"]}
			]
			}
		}]);
}

Demo.prototype.brightnessContrast = function (startTime, duration, startLayer, endLayer, layer, brightness, contrast)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fbobc","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fbobc","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	    {
	         "start": startTime, "duration":duration
	        ,"layer": layer, "image": ["fbobc.color.fbo"]
		 ,"initFunction":"{fboBcImage = imageLoadImage('fbobc.color.fbo'); setTextureSizeToScreenSize(fboBcImage.ptr); }"
		 ,"runFunction":"{setTextureSizeToScreenSize(fboBcImage.ptr);}"
		 ,"brightness": brightness
		 ,"contrast": contrast
		 ,"beat": beat
	     ,"shader":{
	            "name":"data/shader/brightnesscontrast.fs",
	            "variable":[
	                  {"name":"time","value":["{return getSceneTimeFromStart();}"]}
          ,{"name":"brightness","value":[brightness]}
					 ,{"name":"contrast","value":[contrast]}
	            ]
	        }
	    }
	]);
	
	
}

Demo.prototype.edgeGlow = function (startTime, duration, startLayer, endLayer, layer)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fboeg","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fboeg","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	    {
	         "start": startTime, "duration":duration
	        ,"layer": layer, "image": ["fboeg.color.fbo"]
		 ,"initFunction":"{fboegImage = imageLoadImage('fboeg.color.fbo'); setTextureSizeToScreenSize(fboegImage.ptr); }"
		 ,"runFunction":"{setTextureSizeToScreenSize(fboegImage.ptr);}"
	     ,"shader":{
	            "name":"data/shader/edgeglow.fs",
	            "variable":[
	                  {"name":"time","value":["{return getSceneTimeFromStart();}"]}
	            ]
	        }
	    }
	]);
}

Demo.prototype.piikkiPallo = function (startTime)
{
		for(var i=0;i<4;i++)
		{
		this.pomppuObu(startTime+i*beat,200, 0, 0, "data/spikeball.obj");
		}
		
		for(var i=0;i<4;i++)
		{
		this.pomppuObu(4*beat+startTime+i*beat,180, -200, 0, "data/triplatorus.obj");
		this.pomppuObu(4*beat+startTime+i*beat,180, 200, 0, "data/triplatorus.obj");
		}
		
		for(var i=0;i<4;i++)
		{
		this.pomppuObu(8*beat+startTime+i*beat,200, -200, -200, "data/spikeball.obj");
		this.pomppuObu(8*beat+startTime+i*beat,200, 200, -200, "data/spikeball.obj");
		this.pomppuObu(8*beat+startTime+i*beat,200, -200, 200, "data/spikeball.obj");
		this.pomppuObu(8*beat+startTime+i*beat,200, 200, 200, "data/spikeball.obj");
		}
		for(var i=0;i<4;i++)
		{
		this.pomppuObu(12*beat+startTime+i*beat,150, -150, -150, "data/triplatorus.obj");
		this.pomppuObu(12*beat+startTime+i*beat,150, 150, -150, "data/spikeball.obj");
		this.pomppuObu(12*beat+startTime+i*beat,150, -150, 150, "data/spikeball.obj");
		this.pomppuObu(12*beat+startTime+i*beat,150, 150, 150, "data/triplatorus.obj");
		this.pomppuObu(12*beat+startTime+i*beat,150, -450, -150, "data/spikeball.obj");
		this.pomppuObu(12*beat+startTime+i*beat,150, 450, -150, "data/triplatorus.obj");
		this.pomppuObu(12*beat+startTime+i*beat,150, -450, 150, "data/triplatorus.obj");
		this.pomppuObu(12*beat+startTime+i*beat,150, 450, 150, "data/spikeball.obj");
		}
}

Demo.prototype.pomppuObu = function(startTime, scale, positionX, positionY, obu)
{
			this.loader.addAnimation([
					{
					"start": startTime, "duration": 3*tick, "object":obu
					,"layer": 20000
					,"position": [{"z":-900,"y":positionY,"x":positionX}]
					,"angle": [{"degreesX":Math.random()*720-360,"degreesY":Math.random()*720-360,"degreesZ":"{return (Math.sin(getSceneTimeFromStart()*.5))*360}"}]

					,"scale": [
							{"x":scale,"y":scale,"z":scale}
							, {"duration":beat,"x":scale*.25,"y":scale*.25,"z":scale*.25}
						]
					}]);
}

Demo.prototype.fullScreenNoise = function (sceneStartTime, duration, layer, alpha)
{
	this.loader.addAnimation([
    {
         "start": sceneStartTime, "duration":duration
        ,"layer": layer, "image": ["data/empty.png"]
     ,"shader":{
            "name":"data/shader/noise.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart();}"]},
				  {"name":"alphaBlending","value":[alpha]}
            ]
        }
    }
]);
}

Demo.prototype.hackGlow = function (startTime, duration, startLayer, endLayer, layer)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fbohg","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fbohg","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	    {
	         "start": startTime, "duration":duration
	        ,"layer": layer, "image": ["fbohg.color.fbo"]
		 ,"initFunction":"{fbohgImage = imageLoadImage('fbohg.color.fbo'); setTextureSizeToScreenSize(fbohgImage.ptr); }"
		 ,"runFunction":"{setTextureSizeToScreenSize(fbohgImage.ptr);}"
	     ,"shader":{
	            "name":"data/shader/hackglow.fs",
	            "variable":[
	                  {"name":"time","value":["{return getSceneTimeFromStart();}"]}
	            ]
	        }
	    }
	]);
}



function sippeScrollX()
{
sippeKerroin++;
if(sippeKerroin>11)sippeKerroin=0;
print(sippeKerroin);
return ((sippeKerroin*.090909090909091+(.7*getSceneTimeFromStart()))%1.1*(1280));

}
function sippeScrollY()
{
return (Math.abs(Math.sin(sippeKerroin+getSceneTimeFromStart())))*360+180;
}