    let imgWhite=GPSD~"img\white.png";
    let imgSquare=GPSD~"img\iddyeasquare.png";
    let imgIddyea=GPSD~"img\iddyea.png";

    let drawlogic=0;
    let winglogic=0;
    let bginit=0;

    let IddyeaBlurX=[0,0,0,0,0,0,0,0];
    let IddyeaBlurY=[0,0,0,0,0,0,0,0];
    let IddyeaBlurO=[0,0,0,0,0,0,0,0];
    let IddyeaBlurXV=[0,0,0,0,0,0,0,0];
    let IddyeaBlurYV=[0,0,0,0,0,0,0,0];
    let blurno=0;
    let idloop=0;
    let previousx=GetX;
    let previousy=GetY;
    let IddyeaAura=[0,0,0];
    let IddyeaAuraT=[0,20,40];
    let IddyeaAuraA=[rand(0,360),rand(0,360),rand(0,360)];

function IddyeaDrawLogic{
	drawlogic++;
	if(drawlogic%2==0){
		IddyeaBlurX[blurno]=GetX;
		IddyeaBlurY[blurno]=GetY;
		IddyeaBlurO[blurno]=255;
		IddyeaBlurXV[blurno]=previousx-GetX;
		IddyeaBlurYV[blurno]=previousy-GetY;
		blurno=(blurno+1)%8;
	}


	winglogic+=  (((GetY-previousy)^2+(GetX-previousx)^2)^0.5)*3  +5;

	previousx=GetX;
	previousy=GetY;
	idloop=0;
	loop(8){
		IddyeaBlurO[idloop]=IddyeaBlurO[idloop]-(255/(2*8));
		IddyeaBlurX[idloop]=IddyeaBlurX[idloop]+IddyeaBlurXV[idloop];
		IddyeaBlurY[idloop]=IddyeaBlurY[idloop]+IddyeaBlurYV[idloop];
		idloop++;
	}
	idloop=0;
	loop(3){
		IddyeaAuraT[idloop]=IddyeaAuraT[idloop]+1;
		if(IddyeaAuraT[idloop]>=60){
			IddyeaAura[idloop]=rand_int(0,3);
			IddyeaAuraT[idloop]=0;
			IddyeaAuraA[idloop]=rand(0,360);
		}
		idloop++;
	}
}

function iddc(colorindex,row,max){
	return Rainbow(colorindex,drawlogic-row*20)*(max*0.75)+(max*0.25);
}
sub IddyeaDrawLoop{

	//spellsquare

	SetTexture(imgSquare);
	SetGraphicRect(0,0,128,128);
	SetRenderState(ADD);

	SetColor(iddc(0,0,255),iddc(1,0,255),iddc(2,0,255));
	SetGraphicScale(1.5,1.5);
	SetGraphicAngle(0,0,drawlogic);
	DrawGraphic(GetX,GetY);

	SetColor(iddc(0,1,205),iddc(1,1,205),iddc(2,1,205));
	SetGraphicScale(1.125,1.125);
	SetGraphicAngle(0,0,-drawlogic*1.2);
	DrawGraphic(GetX,GetY);

	SetColor(iddc(0,2,155),iddc(1,2,155),iddc(2,2,155));
	SetGraphicScale(0.843,0.843);
	SetGraphicAngle(0,0,drawlogic*1.4);
	DrawGraphic(GetX,GetY);

	SetColor(iddc(0,3,105),iddc(1,3,105),iddc(2,3,105));
	SetGraphicScale(0.632,0.632);
	SetGraphicAngle(0,0,-drawlogic*1.6);
	DrawGraphic(GetX,GetY);


	//background aura (blur)
	SetTexture(imgIddyea);
	SetRenderState(ALPHA);
	SetColor(255,255,255);
	SetGraphicRect(0,0,128,128);
	SetGraphicScale(1,1);
	SetGraphicAngle(0,0,0);

	idloop=blurno;
	loop(8){
		SetAlpha(IddyeaBlurO[idloop%8]);
		DrawGraphic(IddyeaBlurX[idloop%8],IddyeaBlurY[idloop%8]);
		idloop++;
	}

	//wings
	SetAlpha(255);
	SetGraphicScale(1.2,1.2);
	SetGraphicAngle(cos(winglogic)*50,0,0);

	SetGraphicRect(128,0,256,128);
	DrawGraphic(GetX+5,GetY+5);//left
	SetGraphicRect(256,0,384,128);
	DrawGraphic(GetX-5,GetY+5);//right

	//Iddyea


	SetGraphicScale(1,1);
	SetGraphicAngle(0,0,0);
	SetGraphicRect(0,0,128,128);
	SetAlpha(255);
	DrawGraphic(GetX,GetY);

	//foreground aura

	SetGraphicScale(2,2);

	idloop=0;
	loop(3){
		SetAlpha(255*(sin(IddyeaAuraT[idloop]*(180/60))));

		SetGraphicRect(IddyeaAura[idloop]*128,128,IddyeaAura[idloop]*128+128,256);
		DrawGraphic(GetX+cos(IddyeaAuraA[idloop])*IddyeaAuraT[idloop]/2,GetY+sin(IddyeaAuraA[idloop])*IddyeaAuraT[idloop]/2);
		idloop++;
	}
}

function LaserSound{SE("laser4");}
function LaserSound2{SE("laser3");}


task AppearEffect(rx,ry,time){
	if(!OffScreen(rx,ry,0)){
//		rx+=rand(-2,2);
//		ry+=rand(-2,2);
		let speed=rand(2,5);
		let angle=rand_int(0,359);
		let angvel=rand(-8,8);
		let obj=Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,rx,ry);
		ObjEffect_SetTexture(obj,imgSquare);
		ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetScale(obj,1,1);
		ObjEffect_SetAngle(obj,0,0,rand(0,360));
		ObjEffect_SetLayer(obj,4);
		ObjEffect_CreateVertex(obj,4);
		ObjEffect_SetRenderState(obj,ADD);
		Obj_SetAutoDelete(obj,false);

		ObjEffect_SetVertexUV(obj, 0, 0,  0);
		ObjEffect_SetVertexUV(obj, 1, 0,  128);
		ObjEffect_SetVertexUV(obj, 2, 128, 128);
		ObjEffect_SetVertexUV(obj, 3, 128, 0);
		ObjEffect_SetVertexXY(obj, 0, -64,-64);
		ObjEffect_SetVertexXY(obj, 1, -64,64);
		ObjEffect_SetVertexXY(obj, 2, 64,64);
		ObjEffect_SetVertexXY(obj, 3, 64,-64);

		let alphaadd=255/time;
		let alpha=255;
		loop(time){
			rx+=cos(angle)*speed;
			ry+=sin(angle)*speed;
			Obj_SetPosition(obj,rx,ry);
			alpha-=alphaadd;
			angle+=angvel;
			ObjEffect_SetAngle(obj,0,0,angle);
			ObjEffect_SetScale(obj,alpha/600,alpha/600);
			ObjEffect_SetAlpha(obj,4,196);
			yield;
		}
		Obj_Delete(obj);
	}
}

task AppearEffectMove(rx,ry,xv,yv,size,time){
	if(!OffScreen(rx,ry,0)){
//		rx+=rand(-2,2);
//		ry+=rand(-2,2);
		let speed=rand(2,5);
		let angle=rand(0,360);
		let angvel=rand(-8,8);
		let obj=Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,rx,ry);
		ObjEffect_SetTexture(obj,imgSquare);
		ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetScale(obj,1,1);
		ObjEffect_SetAngle(obj,0,0,rand(0,360));
		ObjEffect_SetLayer(obj,4);
		ObjEffect_CreateVertex(obj,4);
		ObjEffect_SetRenderState(obj,ADD);
		Obj_SetAutoDelete(obj,false);

		ObjEffect_SetVertexUV(obj, 0, 0,  0);
		ObjEffect_SetVertexUV(obj, 1, 0,  128);
		ObjEffect_SetVertexUV(obj, 2, 128, 128);
		ObjEffect_SetVertexUV(obj, 3, 128, 0);
		ObjEffect_SetVertexXY(obj, 0, -64,-64);
		ObjEffect_SetVertexXY(obj, 1, -64,64);
		ObjEffect_SetVertexXY(obj, 2, 64,64);
		ObjEffect_SetVertexXY(obj, 3, 64,-64);

		let alphaadd=255/time;
		let alpha=255;
		loop(time){
			rx+=xv;
			ry+=yv;
			Obj_SetPosition(obj,rx,ry);
			alpha-=alphaadd;
			angle+=angvel;
			ObjEffect_SetAngle(obj,0,0,angle);
			ObjEffect_SetScale(obj,alpha/600*size,alpha/600*size);
			ObjEffect_SetAlpha(obj,4,196);
			yield;
		}
		Obj_Delete(obj);
	}
}


task AppearEffectAngle(rx,ry,a,time){
	a+=rand_int(0,1)*180;
	let speed=rand(0,5);
	let obj=Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj,rx,ry);
	ObjEffect_SetTexture(obj,imgSquare);
	ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLEFAN);
	ObjEffect_SetScale(obj,1,1);
	ObjEffect_SetAngle(obj,0,0,rand(0,360));
	ObjEffect_SetLayer(obj,4);
	ObjEffect_CreateVertex(obj,4);
	ObjEffect_SetRenderState(obj,ADD);
	Obj_SetAutoDelete(obj,false);

	ObjEffect_SetVertexUV(obj, 0, 0,  0);
	ObjEffect_SetVertexUV(obj, 1, 0,  128);
	ObjEffect_SetVertexUV(obj, 2, 128, 128);
	ObjEffect_SetVertexUV(obj, 3, 128, 0);
	ObjEffect_SetVertexXY(obj, 0, -64,-64);
	ObjEffect_SetVertexXY(obj, 1, -64,64);
	ObjEffect_SetVertexXY(obj, 2, 64,64);
	ObjEffect_SetVertexXY(obj, 3, 64,-64);

	let alphaadd=255/time;
	let alpha=255;
	let randnum=0;
	loop(time){
		rx+=cos(a)*speed;
		ry+=sin(a)*speed;
		Obj_SetPosition(obj,rx,ry);
		alpha-=alphaadd;
		ObjEffect_SetScale(obj,0.2,0.2);
		randnum=rand(0,360);
		ObjEffect_SetAlphaColor(obj,4,alpha,[Rainbow(0,randnum)*196+63,Rainbow(1,randnum)*196+63,Rainbow(2,randnum)*196+63]);
		yield;
	}
	Obj_Delete(obj);
}

function ObjEffect_SetAlphaColor(obj,vertices,alpha,color){
let k=0;
loop(vertices){
	ObjEffect_SetVertexColor(obj,k,alpha,color[0],color[1],color[2]);
	k++;
}
}
sub IddyeaInit{
}
sub IddyeaFinalize{
}