#TouhouDanmakufu[Player]
#ScriptVersion[3]
#ID["gt_YoumuTD"]
#Title["Ten Desires Youmu"]
#Text["Half-Human Half-Phantom Gardener[r][r]Ten Desires Youmu[r]Without Spirit System"]
#Image["./img_Cutin.png"]
#ReplayName["YoumuTD"]

/* 
Ten Desires Youmu Player
Version 0.99 (1.0 will be spirit system)
By: gtbot
*/




let MaximumParticles = 24; // Maximum number of particles allowed
let AllowShotDecay = true; // Renders the shot degeneration effect when true
let AllowGrazePart = true; // Renders a particle when you graze when true
let AllowSpecialEffects = true; // Renders special visual effects
let GrazePartNum = 3; // Number of particles created when you graze a single bullet




/*
The following are common datas that this player uses. You may use
this data to further manipulate your scripts (or player) to your needs.

 --- Global Common Data --- 
	+ Common Data that is globally used
	
	- TimeSlow - Set to any value above 1 to slow down processes
					Change to 1 once you want normal time.
	
	- TimeStop - Set to any value above 0 to stop processes
					Change to 0 once you want normal time.
					
	
 --- Common Area Data --- 
	+ Area Common Data that use the area "c_Player_v1"
	GetRenderObject 	- Gets the object that renders the player's
							image + animation
	GetPlayerSpeed		- Returns the player's normal speed in an array
							[Unshift Speed, Shift Speed]
	ForceOptionsOff		- Set to true to hide options and other objects
							that may use this value
							
*/



let TotalParticleCount = 0;

let unshiftspd = 4;
let shiftspd = 1.65;
let playertype = 1;
let playerdead = false;
let TimeSpeed = 1;

let YoumuTrailX = [];
let YoumuTrailY = [];
let OldOffSetX = [];
let OldOffSetY = [];
let IsShift = false;

let shotCount = 1;
let ShotDamage = 0;

let ActivateHitbox = false;
let RefreshOptions = false;
let ForceOptionsOff = false;
let CanShoot = true;
let CanShift = true;
let OptionShift = GetVirtualKeyState(VK_SLOWMOVE)!=KEY_FREE;
let IsTimeStopped = false;
let IsPlayerSpawning = false;


let BasePlayerObj = GetPlayerObjectID;
let objPlayer = ObjPrim_Create(OBJ_SPRITE_2D);
let current = GetCurrentScriptDirectory;

let imgPlayer2 = current ~ "img_Player2.png";
let imgPlayer = current ~ "img_Player.png";
let imgBomb = current ~ "img_Bomb.png";
let imgEffect = current ~ "img_Effect.png";

let chargesnd = ObjSound_Create;

@Initialize{
	LoadPlayerShotData(current ~ "a_shotdata.txt"); 
	CreateCommonDataArea("c_Player_v1");
	SetCommonData("PlayerTimeSync", true);
	SetAreaCommonData("c_Player_v1", "GetRenderObject", objPlayer);
	SetAreaCommonData("c_Player_v1", "GetPlayerSpeed", [unshiftspd, shiftspd]);
	
	ObjPlayer_AddIntersectionCircleA1(BasePlayerObj, 0, 0, 2, 20); 
	
	SetPlayerRebirthFrame(24);
	SetPlayerRebirthLossFrame(4);
	SetPlayerDownStateFrame(45);
	SetPlayerSpeed(unshiftspd,shiftspd);
	SetPlayerAutoItemCollectLine(128);
	
	ShotType;

	LoadSound(current~"se_pldead.wav");
	LoadSound(current~"se_shot.wav");
	LoadSound(current~"se_shot2.wav");
	LoadSound(current~"se_spell.wav");
	LoadSound(current~"se_power.wav");
	LoadSound(current~"se_getlife.wav");
	LoadSound(current~"se_graze.wav");
	LoadSound(current~"se_item.wav");
	LoadSound(current~"se_spark.wav");
	LoadSound(current~"se_chargeidle.wav");
	ObjSound_Load(chargesnd, current~"se_charge.wav");
	
	
	LoadTexture(imgPlayer);
	LoadTexture(imgPlayer2);
	LoadTexture(imgEffect);
	LoadTexture(imgBomb);
	
	Obj_SetValue(objPlayer, "dinv", -1);
	RenderPlayerImage(objPlayer, 0);
	
	ascent(i in 1..5){
		CreateOptionS1(objPlayer, i, 0, 0, -32, 270, 0, -1, 3.25);
	}
	SetPlayerSpell(2);
	Spawn;	
	
		

	ascent(i in 0..45){
		YoumuTrailX = YoumuTrailX ~ [GetPlayerX];
		YoumuTrailY = YoumuTrailY ~ [GetPlayerY];
		OldOffSetX = OldOffSetX ~ [0];
		OldOffSetY = OldOffSetY ~ [0];
	}
}


@MainLoop{
	OptionShift = GetVirtualKeyState(VK_SLOWMOVE)!=KEY_FREE;
	if(GetPlayerState==STATE_DOWN){CanShoot = false;}
	if(GetPlayerState==STATE_NORMAL){CanShoot = true;}
	if(IsPermitPlayerShot==false && GetPlayerState==STATE_NORMAL){CanShoot = false;}
	if(IsPermitPlayerShot==true && GetPlayerState==STATE_NORMAL){CanShoot = true;}
	
	if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH){RenderHitboxImage(objPlayer, 0, 1);}
	
	if(!IsPlayerSpawning){
		SetPlayerClip(11,11,GetStgFrameWidth-11,GetStgFrameHeight-18);
	}
	
			if(!AllKeysFree&&!OptionShift&&GetPlayerState==STATE_NORMAL){
				YoumuTrailX = erase(YoumuTrailX, 0);
				YoumuTrailY = erase(YoumuTrailY, 0);
				YoumuTrailX = YoumuTrailX~[GetPlayerX];
				YoumuTrailY = YoumuTrailY~[GetPlayerY];
			} 
			if(OptionShift){
				if(!IsShift){
					IsShift = true;
					ascent(i in 0..45){
						OldOffSetX[i] = YoumuTrailX[i]-GetPlayerX;
						OldOffSetY[i] = YoumuTrailY[i]-GetPlayerY;
					}
				}
			}else{
				if(IsShift){
					IsShift = false;
					ascent(i in 0..45){
						YoumuTrailX[i] = GetPlayerX+OldOffSetX[i];
						YoumuTrailY[i] = GetPlayerY+OldOffSetY[i];
					}
				}
			}
			if(IsPlayerSpawning || ForceOptionsOff){
				ascent(i in 0..45){
					YoumuTrailX[i] = GetPlayerX;
					YoumuTrailY[i] = GetPlayerY-32;
				}
			}
	
	ForceOptionsOff = GetAreaCommonData("ForceOptionsOff", "c_Player_v1", false);
	
	if(GetCommonData("TimeStop", 0) != 0 && !IsTimeStopped){TimeFrozen(-1);}
	TimeSpeed = GetCommonData("TimeSlow", 1);
	yield;
}

@Finalize{	
	RemoveTexture(imgPlayer);
	RemoveTexture(imgPlayer2);
	RemoveTexture(imgEffect);
	RemoveTexture(imgBomb);
	RemoveSound(current~"se_pldead.wav");
	RemoveSound(current~"se_shot.wav");
	RemoveSound(current~"se_shot2.wav");
	RemoveSound(current~"se_spell.wav");
	RemoveSound(current~"se_power.wav");
	RemoveSound(current~"se_getlife.wav");
	RemoveSound(current~"se_graze.wav");
	RemoveSound(current~"se_item.wav");
	RemoveSound(current~"se_spark.wav");
	RemoveSound(current~"se_chargeidle.wav");
	RemoveSound(current~"se_charge.wav");
	
}

@Event{
	alternative(GetEventType)
	case(EV_REQUEST_SPELL){
		if(GetPlayerSpell >= 1 && !IsTimeStopped){
			SetPlayerInvincibilityFrame(5);
			SetScriptResult(true);
			PlaySE(current~"se_spell.wav");
			SetPlayerSpell(GetPlayerSpell-1);
			YoumuSlash(0);
		}
		else{
			SetScriptResult(false);
		}
	}
	case(EV_PLAYER_SHOOTDOWN){
		CanShoot = false;
		playerdead = true;
	}
	case(EV_HIT){
		PlaySE(current~"se_pldead.wav");
		loop(32){MapleLeaf(GetPlayerX, GetPlayerY, rand(0,360), rand(85, 185), 2.8);}
		DeathExplosion(0);
	}
	case(EV_PLAYER_REBIRTH){
		SetPlayerRebirthFrame(24);
		SetPlayerRebirthLossFrame(4);
		ClearEnemyBullets(GetPlayerX, GetPlayerY, 10, 10, 900, 0);
		SetPlayerInvincibilityFrame(240);
		playerdead = false;
		SetPlayerSpell(2);
		Spawn;
	}
	case(EV_GET_ITEM){
		alternative(GetEventArgument(0))
		case(ITEM_1UP){
			PlaySE(current~"se_getlife.wav");
			SetPlayerLife(GetPlayerLife+1);
		}
		case(ITEM_1UP_S){
			PlaySE(current~"se_getlife.wav");
			SetPlayerLife(GetPlayerLife+1);
		}
		case(ITEM_SPELL){
			PlaySE(current~"se_getlife.wav");
			SetPlayerSpell(GetPlayerSpell+1);
		}
		case(ITEM_SPELL_S){
			PlaySE(current~"se_getlife.wav");
			SetPlayerSpell(GetPlayerSpell+1);
		}
		others{
			PlaySE(current~"se_item.wav");
		}
	}
	case(EV_GRAZE){
		PlaySE(current~"se_graze.wav");
		loop(GrazePartNum){Particle(GetPlayerX, GetPlayerY, rand(0,360), rand(15, 85), 0.8);}
	}
}

task Spawn{
	let obj = GetPlayerObjectID;
	let y = 0;
	ObjRender_SetX(obj, GetStgFrameWidth/2);
	ObjRender_SetY(obj, GetStgFrameHeight-32);
	SetPlayerSpeed(0,0);
	IsPlayerSpawning = true;
	while(y<82){
		if(IsTimeStopped==false){
			SetPlayerClip(11,11,GetStgFrameWidth-11,GetStgFrameHeight+64);	
			SetPlayerSpeed(0,0);
			ObjRender_SetY(obj, GetStgFrameHeight+32-y);
			y+=2/TimeSpeed;
		}
		yield;
	}
	IsPlayerSpawning = false;
	SetPlayerSpeed(unshiftspd,shiftspd);
}

task TimeFrozen(num){
	let Uber = GetPlayerInvincibilityFrame;
	IsTimeStopped = true;
	SetPlayerSpeed(0, 0);
	ObjPlayer_ClearIntersection(BasePlayerObj);
	while(GetCommonData("TimeStop", 0) != 0 || num > 0){
		SetPlayerInvincibilityFrame(Uber);
		SetPlayerSpeed(0, 0);
		num--;
		yield;
	}
	IsTimeStopped = false;
	SetPlayerSpeed(unshiftspd, shiftspd);
	ObjPlayer_AddIntersectionCircleA1(BasePlayerObj, 0, 0, 2, 20); 
}


task RenderPlayerImage(ObjectRender, offset){
	let anim_count = 0;
	let anim_type = 0;
	let Uber = 0;
	let Uberblink = 0;
	
	let x = 32;
	let y = 48;
	let ri = 6;
	let rm = 4;
	let bn = 0;
	
	ObjPrim_SetTexture(ObjectRender, imgPlayer);
	Obj_SetRenderPriority(ObjectRender, 0.45);
	
	while(!Obj_IsDeleted(ObjectRender)){
		if(GetPlayerState!=STATE_DOWN){
			ObjRender_SetAlpha(ObjectRender, 255);
		}
		
		if(GetPlayerState!=STATE_NORMAL || playerdead == true){ObjRender_SetAlpha(ObjectRender, 0);}
		ObjRender_SetPosition(ObjectRender, GetPlayerX, GetPlayerY, 0);
		
		if(IsPlayerSpawning==false){
			if(IsTimeStopped == false){
				Blink;
				if(GetVirtualKeyState(VK_RIGHT) == KEY_FREE && GetVirtualKeyState(VK_LEFT) == KEY_FREE){
					if(anim_type != 0){
						bn = 0;
						anim_count = 0;
						anim_type = 0;
					}
				}
				if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH || GetVirtualKeyState(VK_LEFT) == KEY_HOLD){
					if(GetVirtualKeyState(VK_RIGHT) != KEY_HOLD && anim_type != 1){
						bn = 0.85;
						anim_count = 0;
						anim_type = 1;
					}
				}
				if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH || GetVirtualKeyState(VK_RIGHT) == KEY_HOLD){
					if(anim_type != 2){
						bn = 0.85;
						anim_count = 0;
						anim_type = 2;
					}
				}
				anim_count+=(1+bn)/TimeSpeed;
				if(floor(anim_count) != anim_count && TimeSpeed == 1 && bn == 0){
					anim_count = floor(anim_count);
				}
			}
		}else{
			if(IsTimeStopped==false){
				Blink;
				anim_count+=1/TimeSpeed;
				if(anim_type != 0){
					anim_count = 0;
					anim_type = 0;
				}
			}
		}
		//0 - Idle; 1 - Left; 2 - Right;
		if(IsTimeStopped == false){
			if(anim_type==0){
				if(round(anim_count) >= 0){ObjSprite2D_SetSourceRect(ObjectRender, 0, 0+offset, x, y+offset);}
				if(round(anim_count) >= ri){ObjSprite2D_SetSourceRect(ObjectRender, x, 0+offset, x*2, y+offset);}
				if(round(anim_count) >= ri*2){ObjSprite2D_SetSourceRect(ObjectRender, x*2, 0+offset, x*3, y+offset);}
				if(round(anim_count) >= ri*3){ObjSprite2D_SetSourceRect(ObjectRender, x*3, 0+offset, x*4, y+offset);}
				if(round(anim_count) >= ri*4){ObjSprite2D_SetSourceRect(ObjectRender, x*4, 0+offset, x*5, y+offset);}
				if(round(anim_count) >= ri*5){ObjSprite2D_SetSourceRect(ObjectRender, x*5, 0+offset, x*6, y+offset);}
				if(round(anim_count) >= ri*6){ObjSprite2D_SetSourceRect(ObjectRender, x*6, 0+offset, x*7, y+offset);}
				if(round(anim_count) >= ri*7){ObjSprite2D_SetSourceRect(ObjectRender, x*7, 0+offset, x*8, y+offset);}
				if(round(anim_count) >= ri*8-1){anim_count = ri-1;}
			}
			if(anim_type==1){
				if(round(anim_count) >= 0){ObjSprite2D_SetSourceRect(ObjectRender, 0, y+offset, x, y*2+offset);}
				if(round(anim_count) >= rm){ObjSprite2D_SetSourceRect(ObjectRender, x, y+offset, x*2, y*2+offset);}
				if(round(anim_count) >= rm*2){ObjSprite2D_SetSourceRect(ObjectRender, x*2, y+offset, x*3, y*2+offset);}
				if(round(anim_count) >= rm*3){ObjSprite2D_SetSourceRect(ObjectRender, x*3, y+offset, x*4, y*2+offset);}
				if(round(anim_count) >= rm*4){ObjSprite2D_SetSourceRect(ObjectRender, x*4, y+offset, x*5, y*2+offset);bn = 0}
				if(round(anim_count) >= rm*5){ObjSprite2D_SetSourceRect(ObjectRender, x*5, y+offset, x*6, y*2+offset);}
				if(round(anim_count) >= rm*6){ObjSprite2D_SetSourceRect(ObjectRender, x*6, y+offset, x*7, y*2+offset);}
				if(round(anim_count) >= rm*7){ObjSprite2D_SetSourceRect(ObjectRender, x*7, y+offset, x*8, y*2+offset);}
				if(round(anim_count) >= rm*8-1){anim_count = rm*4-1;}
			}
			if(anim_type==2){
				if(round(anim_count) >= 0){ObjSprite2D_SetSourceRect(ObjectRender, 0, y*2+offset, x, y*3+offset);}
				if(round(anim_count) >= rm){ObjSprite2D_SetSourceRect(ObjectRender, x, y*2+offset, x*2, y*3+offset);}
				if(round(anim_count) >= rm*2){ObjSprite2D_SetSourceRect(ObjectRender, x*2, y*2+offset, x*3, y*3+offset);}
				if(round(anim_count) >= rm*3){ObjSprite2D_SetSourceRect(ObjectRender, x*3, y*2+offset, x*4, y*3+offset);}
				if(round(anim_count) >= rm*4){ObjSprite2D_SetSourceRect(ObjectRender, x*4, y*2+offset, x*5, y*3+offset);bn = 0}
				if(round(anim_count) >= rm*5){ObjSprite2D_SetSourceRect(ObjectRender, x*5, y*2+offset, x*6, y*3+offset);}
				if(round(anim_count) >= rm*6){ObjSprite2D_SetSourceRect(ObjectRender, x*6, y*2+offset, x*7, y*3+offset);}
				if(round(anim_count) >= rm*7){ObjSprite2D_SetSourceRect(ObjectRender, x*7, y*2+offset, x*8, y*3+offset);}
				if(round(anim_count) >= rm*8-1){anim_count = rm*4-1;}
			}
		}
		ObjSprite2D_SetDestCenter(ObjectRender);
		yield;
	}
	task Blink{
		if(GetPlayerInvincibilityFrame>0){
			if(Uber==0){ObjRender_SetColor(ObjectRender, 255, 255, 255);}
			if(Uber!=0){ObjRender_SetColor(ObjectRender, 32, 32, 255);}
			Uberblink+=1/TimeSpeed;
			if(Uberblink>1){Uberblink=0;Uber++;if(Uber>1){Uber=0}}
		}else{
			ObjRender_SetColor(ObjectRender, 255, 255, 255);
		}
	}
}

task RenderHitboxImage(plobj, offx, hitboxnum){
	yield;yield;yield;
	while(IsPlayerSpawning||playerdead){
		if(GetVirtualKeyState(VK_SLOWMOVE)!=KEY_HOLD){return;}
		yield;
	}
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.39);
	ObjRender_SetAlpha(obj, 235);
	ObjPrim_SetTexture(obj, imgEffect);
	ObjSprite2D_SetSourceRect(obj, 64, 224, 127, 287);
	ObjSprite2D_SetDestCenter(obj);
	
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj2, BLEND_ALPHA);
	Obj_SetRenderPriority(obj2, 0.69);
	ObjRender_SetAlpha(obj2, 235);
	ObjPrim_SetTexture(obj2, imgEffect);
	ObjSprite2D_SetSourceRect(obj2, 64, 224, 127, 287);
	ObjSprite2D_SetDestCenter(obj2);
	
	
	let ObjTime = 0;
	
	let AlphaSet = 0;
	let ObjAlpha = 0;
	let ObjScale = 1;
	
	while(GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD&&ObjScale<1.4&&!playerdead){
		if(!IsTimeStopped){
			ObjTime+=8;
			ObjScale += 0.125;
			PositionSet;
		}
		yield;
	}
	while(GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD&&ObjScale>1&&!playerdead){
		if(!IsTimeStopped){
			ObjTime+=8;
			ObjScale -= 0.1;
			PositionSet;
		}
		yield;
	}
	ObjScale = 1;
	yield;
	while(GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD&&!playerdead){
		if(!IsTimeStopped){
			ObjTime+=3;
			PositionSet;
		}
		yield;
	}
	
	while(ObjScale>0){
		if(!IsTimeStopped){
			ObjTime+=3;
			ObjScale -= 0.1;
			PositionSet;
		}
		yield;
	}

	Obj_Delete(obj);
	Obj_Delete(obj2);
	
	task PositionSet{
		if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH){ObjScale = 0;}
		ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
		ObjRender_SetAngleZ(obj, ObjTime);
		ObjRender_SetPosition(obj2, GetPlayerX, GetPlayerY, 0);
		ObjRender_SetScaleXYZ(obj, ObjScale, ObjScale, ObjScale);
		ObjRender_SetScaleXYZ(obj2, ObjScale, ObjScale, ObjScale);
	}
	
}


task DeathExplosion(offx){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.60);
	ObjPrim_SetTexture(obj, imgEffect);
	ObjSprite2D_SetSourceRect(obj, 198, 232, 262, 296);
	ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);
	let alpha = 175;
	let scale = 0.8;
	let expo = 0.7;
	while(alpha>0){
		scale += expo/TimeSpeed;
		alpha -= 7/TimeSpeed;
		if(expo>0){expo -=0.0085/TimeSpeed;}
		ObjRender_SetAlpha(obj, alpha);
		ObjRender_SetPosition(obj, GetPlayerX+offx, GetPlayerY, 0);
		ObjRender_SetScaleXYZ(obj, scale/3, scale/3, 1);
		yield;
	}
	yield;Obj_Delete(obj);
}

task ClearEnemyBullets(x, y, Tsize, Tspd, Tmaxrad, delay){
	let barray = GetShotIdInCircleA2(x, y, Tsize, TARGET_ENEMY);
	let stopclear = true;
	loop(delay){yield;}
	while(Tsize<Tmaxrad){
		barray = GetShotIdInCircleA2(x, y, Tsize, TARGET_ENEMY);
		ascent(i in 0..length(barray)){
			let o = barray[i];
			if(!ObjShot_IsSpellResist(o)){ObjShot_SetDeleteFrame(o, 0);}
		}
		Tsize += Tspd;
		yield;
	}
}

task ShadowA1(dumobj, incremental, alpha, colorR, colorG, colorB){
	SubtractBG(dumobj);
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let xBend = 1;
	let BendInc = 0.22;
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.30);
	ObjRender_SetAlpha(obj, alpha);
	ObjPrim_SetTexture(obj, imgEffect);
	ObjSprite2D_SetSourceRect(obj, 0, 234, 62, 296);
	ObjSprite2D_SetDestRect(obj, -xBend, -xBend, xBend, xBend);
	ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
	ObjRender_SetColor(obj, colorR, colorG, colorB);
	while(!Obj_IsDeleted(dumobj)){
		ObjSprite2D_SetDestRect(obj, -xBend, -xBend, xBend, xBend);
		if(xBend<1500){
			xBend+=BendInc;
			BendInc+=incremental/TimeSpeed;
		}
		yield;
	}
	while(alpha>0){
		alpha -= 3/TimeSpeed;
		ObjRender_SetAlpha(obj, alpha);
		yield;
	}
	Obj_Delete(obj);
}

task SubtractBG(dumobj){
	//Very Hardcoded
	loop(32){yield}
	let bg = ObjPrim_Create(OBJ_SPRITE_2D);
	let fade = 0;
	ObjRender_SetBlendType(bg, BLEND_SUBTRACT);
	Obj_SetRenderPriority(bg, 0.28);
	ObjPrim_SetTexture(bg, NULL);
	ObjSprite2D_SetSourceRect(bg, 0, 0, 1, 1);
	ObjSprite2D_SetDestRect(bg, -48, -48, GetStgFrameWidth+48, GetStgFrameHeight+48);
	ObjRender_SetColor(bg, fade, fade, fade);
	
	let red = 32;
	let green = 64;
	let blue = 64;
	let shift = 0;
	
	while(!Obj_IsDeleted(dumobj)){
		fade = min(1, fade+0.03);
		if(fade==1){shift = min(32, shift+0.2);}
		ObjRender_SetColor(bg, (red+shift)*fade, (green*fade), (blue-shift)*fade);
		yield;
	}
	while(fade>0){
		fade-=0.05;
		ObjRender_SetColor(bg, (red+shift)*fade, (green*fade), (blue-shift)*fade);
		yield;
	}
	Obj_Delete(bg);
	
}

task ShadowA2(x, y, alpha, alphinc, colorR, colorG, colorB){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let ShadowTime = 0;
	let xBend = 1250;
	let BendInc = 0.22;
	let ShadSet = 0;
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.69);
	ObjRender_SetAlpha(obj, alpha);
	ObjPrim_SetTexture(obj, imgEffect);
	ObjSprite2D_SetSourceRect(obj, 0, 234, 62, 296);
	ObjSprite2D_SetDestRect(obj, -xBend, -xBend, xBend, xBend);
	ObjRender_SetPosition(obj, x, y, 0);
	ObjRender_SetColor(obj, colorR, colorG, colorB);
	while(alpha>0){
		alpha += alphinc;
		ObjRender_SetAlpha(obj, alpha);
		yield;
	}
	Obj_Delete(obj);
}



task ShotType{
	let loopCount = 0;
	let charge = 0;
	loop{
		FireShotData;
		PlayerShoot;
		yield;
	}
	
	task FireShotData{
	
		
		if(GetVirtualKeyState(VK_SHOT)!=KEY_FREE&&GetPlayerState==STATE_NORMAL){
			loopCount = 1;
			if(OptionShift){
				charge++;
				if(charge==5&&!ObjSound_IsPlaying(chargesnd)){
					ObjSound_Play(chargesnd);
					ChargingUp;
				}
				if(charge==75){
					ObjSound_Stop(chargesnd);
					PlaySE(current~"se_chargeidle.wav");
				}
				if(charge>75){
					if(cos(charge*20)==1){PlaySE(current~"se_chargeidle.wav");}
				}
			}else{
				if(charge>=75){FocusedShot;}
				charge = 0;
				ObjSound_Stop(chargesnd);
			}
		}else{
			if(charge>=75&&GetPlayerState==STATE_NORMAL){FocusedShot;}
			charge = 0;
			ObjSound_Stop(chargesnd);
		}
		
		if(loopCount>0){
			if(!IsTimeStopped){
				loopCount++;
				shotCount-=1/TimeSpeed;
			}
			if(loopCount>28||IsPlayerSpawning){
				loopCount = 0;
				shotCount = 1;
			}
		}
	}
	task PlayerShoot{		
		if(OptionShift){shotCount = 4; loopCount = 0;}
		if(shotCount <= 0 && CanShoot){
			PlaySE(current~"se_shot.wav");
			CreatePlayerObjShotA1(GetPlayerX-9, GetPlayerY-16, 15, 270, 3, 1, 1, 1);
			CreatePlayerObjShotA1(GetPlayerX+11, GetPlayerY-16, 15, 270, 3, 1, 1, 1);
			yield;
			shotCount = 4;
		}
	}
	task FocusedShot{
		let ox = GetPlayerX;
		let oy = GetPlayerY;
		CreateSwordSlashA2(ox+8, oy-16, 0.75, 270, 0, 14, 1, -1, false);
		loop(8){yield;}
		CreateSwordSlashA2(ox-8, oy-64, 0.75, 270, 0, 14, 1, 1, false);
		loop(8){yield;}
		CreateSwordSlashA2(ox+8, oy-112, 0.75, 270, 0, 14, 1, -1, false);
		loop(8){yield;}
		CreateSwordSlashA2(ox-8, oy-160, 0.75, 270, 0, 14, 1, 1, false);
		loop(8){yield;}
		CreateSwordSlashA2(ox+8, oy-208, 0.75, 270, 0, 14, 1, -1, false);
		loop(8){yield;}
		CreateSwordSlashA2(ox-8, oy-256, 0.75, 270, 0, 14, 1, 1, false);
	}
	task ChargingUp{
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		let objtime = 0;
		ObjRender_SetBlendType(obj, BLEND_ALPHA);
		Obj_SetRenderPriority(obj, 0.46);
		ObjPrim_SetTexture(obj, imgEffect);
		ObjRender_SetAlpha(obj, 160);
		ObjRender_SetScaleXYZ(obj, 1, 1, 1);
		ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
		let r = 5;
		while(OptionShift&&charge>4){
			objtime++;
			ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY-4, 0);
			if(objtime>=r*0){ObjSprite2D_SetSourceRect(obj, 128, 304, 160, 348);}
			if(objtime>=r*1){ObjSprite2D_SetSourceRect(obj, 160, 304, 192, 348);}
			if(objtime>=r*2){ObjSprite2D_SetSourceRect(obj, 192, 304, 224, 348);}
			if(objtime>=r*3){ObjSprite2D_SetSourceRect(obj, 224, 304, 256, 348);}
			if(objtime>=r*4){ObjSprite2D_SetSourceRect(obj, 128, 350, 160, 394);}
			if(objtime>=r*5){ObjSprite2D_SetSourceRect(obj, 160, 350, 192, 394);}
			if(objtime>=r*6-1){objtime = -1;}
			ObjSprite2D_SetDestCenter(obj);
			if(charge>=75){ObjRender_SetScaleXYZ(obj, 1.75, 1.75, 1);}
			yield;
		}
		Obj_Delete(obj);
	}
}

task CreatePlayerObjShotA1(ShotX, ShotY, Shotspd, Shotangle, Shotdmg, pwr, Shotpenetration, Shotgraphic){
	let ShotObj = CreatePlayerShotA1(ShotX, ShotY, Shotspd, Shotangle, Shotdmg, Shotpenetration, Shotgraphic);
	let X = 0;
	let Y = 0;
	let A = 0;
	while(Obj_IsDeleted(ShotObj)==false){
		X = ObjRender_GetX(ShotObj);
		Y = ObjRender_GetY(ShotObj);
		A = ObjMove_GetAngle(ShotObj);
		ObjMove_SetSpeed(ShotObj, Shotspd/TimeSpeed);
		yield;
	}
	if(X>1 && Y >1){ShotHit(X, Y-8, A, Shotgraphic);loop(2){Particle(X, Y, A+rand(-70,70), 105, rand(0.25, 0.55))}}
}

task CreateOptionS1(robj, X1, Y1, X2, Y2, angle, type, s, dmg){
	if(RefreshOptions){return;}
	yield;
	let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D); 
	ObjPrim_SetTexture(obj, imgEffect);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.5);
	ObjSpriteList2D_SetSourceRect(obj, 0, 9*16, 16+1, (9+1)*16);
	ObjSpriteList2D_SetDestCenter(obj);
	let rx = GetPlayerX;
	let ry = GetPlayerY;
	
	let alp = 0;
	let movea = 0;
	let pulse = 0;
	while(!Obj_IsDeleted(robj) && !RefreshOptions){
		if(!IsTimeStopped){
			if(IsPlayerSpawning || ForceOptionsOff){
				rx = GetPlayerX;
				ry = GetPlayerY;
				alp = 245;
			}else{
				if(playerdead){
					alp = min(alp+20, 245);
				}else{
					alp = 0;
				}
			}
			posit;
			rend;
			
			if(shotCount <= 0 && CanShoot && !OptionShift){
				CreatePlayerObjShotA1(ObjRender_GetX(obj), ObjRender_GetY(obj), 15, 270, dmg, 0.6, 1, 1);
			}
		}
		yield;
	}
	X1 = 0;
	Y1 = 0;
	X2 = 0;
	Y2 = 0;
	Obj_SetRenderPriority(obj, 0.39);
	let alpha = 0;
	while(alpha<255){
		if(!IsTimeStopped){
			alp = alp+15;
			rend;
			posit;
			ObjRender_SetAlpha(obj, alp);
		}
		yield;
	}
	Obj_Delete(obj);
	
	function rend{
		ObjSpriteList2D_ClearVertexCount(obj);
		
		ObjRender_SetAlpha(obj, 255-alp);
		ObjRender_SetScaleXYZ(obj, 1.5+sin(movea)/8, 1.5+sin(movea)/8, 1);
		ObjSpriteList2D_AddVertex(obj);
		ObjRender_SetColor(obj, 0, 0, 0);
	}

	function posit{
		ObjRender_SetPosition(obj, rx, ry, 0);
		if(sin(pulse)==1){GhostlyParticle(obj, rand(265, 275), 255-alp, 1.1);}
		movea+=10/TimeSpeed;
		pulse+=90/TimeSpeed;
		if(OptionShift){
			let dist = GetDistance(rx, ry, (GetPlayerX+X2), (GetPlayerY+Y2));
			let oang = atan2((GetPlayerY+Y2)-ry, (GetPlayerX+X2)-rx);
			if(dist>0.8/TimeSpeed){
				rx = rx+((dist/2+0.75)/TimeSpeed)*cos(oang);
				ry = ry+((dist/2+0.75)/TimeSpeed)*sin(oang);
			}
		}else{
			let tail = length(YoumuTrailX);
			let nx = YoumuTrailX[tail-(1+8*X1)];
			let ny = YoumuTrailY[tail-(1+8*X1)];
			let dist = GetDistance(rx, ry, (nx), (ny));
			let oang = atan2((ny)-ry, (nx)-rx);
			if(dist>0.85/TimeSpeed){
				rx = rx+((dist/3+1.25)/TimeSpeed)*cos(oang);
				ry = ry+((dist/3+1.25)/TimeSpeed)*sin(oang);
			}
		}
	}
}
task ShotHit(EffectX, EffectY, EffectA, type){
	if(AllowShotDecay==false){return;}
	let obj3 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj3_time = 0;
	ObjRender_SetBlendType(obj3, BLEND_ALPHA);
	ObjRender_SetAlpha(obj3, 200);
	Obj_SetRenderPriority(obj3, 0.59);
	ObjPrim_SetTexture(obj3, imgEffect);
	ObjSprite2D_SetSourceRect(obj3, 32+(type)*16, 32, 32+(type+1)*16, 48);
	ObjSprite2D_SetDestCenter(obj3);
	ObjRender_SetAngleZ(obj3, EffectA+90);
	ObjRender_SetX(obj3, EffectX);
	ObjRender_SetY(obj3, EffectY);
	let a = 125;
	if(type==3){a = 195;}
	while(!Obj_IsDeleted(obj3)&&type!=2){
		obj3_time++;
		if(obj3_time==3){
			ObjSprite2D_SetSourceRect(obj3, 32+(type)*16, 16, 32+(type+1)*16, 32);
		}
		if(obj3_time==6){
			ObjSprite2D_SetSourceRect(obj3, 32+(type)*16, 0, 32+(type+1)*16, 16);
		}
		if(obj3_time==9){Obj_Delete(obj3);}
		ObjRender_SetAlpha(obj3, a-obj3_time*8);
		ObjRender_SetScaleXYZ(obj3, 1+obj3_time/10, 1+obj3_time/10, 1);
		ObjRender_SetPosition(obj3, ObjRender_GetX(obj3)+1*cos(EffectA), ObjRender_GetY(obj3)+1*sin(EffectA), 0);
		
		yield;
	}
	if(type!=2){return;}
	ObjSprite2D_SetSourceRect(obj3, 48, 64, 64, 112);
	ObjSprite2D_SetDestCenter(obj3);
	while(!Obj_IsDeleted(obj3)){
		obj3_time++;
		if(obj3_time==9){Obj_Delete(obj3);}
		ObjRender_SetAlpha(obj3, 165-obj3_time*8);
		ObjRender_SetColor(obj3, 255-obj3_time*8, 255-obj3_time*8, 255-obj3_time*8);
		ObjRender_SetScaleXYZ(obj3, 1+obj3_time/10, 1+obj3_time/10, 1);
		ObjRender_SetPosition(obj3, ObjRender_GetX(obj3)+7*cos(EffectA), ObjRender_GetY(obj3)+7*sin(EffectA), 0);
		yield;
	}
}

task YoumuSlash(kdtype){
	yield;
	let objManage = GetSpellManageObject;
	let Master_Time=0;
	
	SetPlayerInvincibilityFrame(300);
	ShadowA1(objManage, 0.75, 60, 0, 0, 0);
	
	PlaySE(current~"se_spark.wav");
	
	let kdf = 30;
	let slash = 30;
	while(Master_Time<240){
		if(!IsTimeStopped){
			if(kdf>=slash){
				let as = 0;
				PlaySE(current~"se_shot2.wav");
				CreateSwordSlashA2(GetStgFrameWidth/2, rand(64, GetStgFrameHeight-64), 0, 270+rand(-20, 20), 0, 20, 2, round(rand(0,1)), true);
				ScreenShake(30, 8);
				kdf=0;
				slash = max(8, slash^0.95);
			}
			kdf+=1/TimeSpeed;
			Master_Time+=1/TimeSpeed;
		}
		yield;
	}
	
	SetPlayerSpeed(unshiftspd,shiftspd);
	Obj_Delete(objManage);

}

task ScreenShake(shaketime, intensity){
	let x = Get2DCameraX;
	let y = Get2DCameraY;
	let fr = 0;
	while(shaketime>0){
		if(fr>=1){
			Set2DCameraFocusX(GetStgFrameWidth/2 + rand(-intensity, intensity));
			Set2DCameraFocusY(GetStgFrameHeight/2 + rand(-intensity, intensity));
			shaketime--;
		}else{
			
		}
		if(IsTimeStopped==false){fr+=1/TimeSpeed;}
		yield;
	}
	Set2DCameraFocusX(x);
	Set2DCameraFocusY(y);
	yield;
}


task Particle(deX, deY, angX, deAlpha, deScale){
	if(TotalParticleCount>=MaximumParticles){return;}
	if(AllowGrazePart != true){return;}
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriority(obj, 0.49);
	ObjPrim_SetTexture(obj, imgEffect);
	ObjSprite2D_SetSourceRect(obj, 0, 234, 62, 296);
	ObjSprite2D_SetDestRect(obj, -rand(1,4), -rand(1,7.5), rand(1, 4), rand(1, 7.5));
	ObjRender_SetAngleXYZ(obj, 0, 0, angX);
	ObjRender_SetPosition(obj, deX, deY, 0);
	ObjRender_SetAlpha(obj, deAlpha);
	ObjRender_SetColor(obj, 155, 155, 155);

	let scale = deScale;
	let randX = rand(75, 350);
	let randY = rand(75, 350);
	
	TotalParticleCount++;
	while(Obj_IsDeleted(obj)==false){
		scale += (-0.05)/TimeSpeed;
		deX = deX+(randX/100/TimeSpeed)*cos(angX);
		deY = deY+(randX/100/TimeSpeed)*sin(angX);
		ObjRender_SetPosition(obj, deX, deY, 0);	
		ObjRender_SetAngleXYZ(obj, 0, 0, angX+deX+deY+scale*45);
		ObjRender_SetScaleXYZ(obj, scale, scale, scale);
		ObjRender_SetAlpha(obj, deAlpha+scale*20);
		if(scale<0.01){Obj_Delete(obj)}
		yield;
	}
	TotalParticleCount--;
	Obj_Delete(obj);
}

task GhostlyParticle(value, angX, deAlpha, scale){
	let position = [ObjRender_GetX(value), ObjRender_GetY(value)];
	let oldposition = position;
	let newa = [position[0]-oldposition[0], position[1]-position[1]];
	let newp = [0,0];
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.51);
	ObjPrim_SetTexture(obj, imgEffect);
	ObjSprite2D_SetSourceRect(obj, 0, 144, 17, 161);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetAngleXYZ(obj, 0, 0, angX);
	ObjRender_SetPosition(obj, position[0], position[1], 0);
	ObjRender_SetAlpha(obj, deAlpha);
	let randX = rand(0.5, 1.50);
	while(!Obj_IsDeleted(obj)){
		position = [ObjRender_GetX(value), ObjRender_GetY(value)];
		newa = [position[0]-oldposition[0], position[1]-position[1]];
		oldposition = position;
		scale += (-0.075)/TimeSpeed;
		newp[0] = newp[0]+(randX/TimeSpeed)*cos(angX);
		newp[1] = newp[1]+(randX/TimeSpeed)*sin(angX);
		ObjRender_SetPosition(obj, position[0]+newp[0]+newa[0]-2, position[1]+newp[1]+newa[1]+1, 0);	
		ObjRender_SetAngleXYZ(obj, 0, 0, angX+position[0]+position[1]+scale*45);
		ObjRender_SetScaleXYZ(obj, scale, scale, scale);
		if(scale<0.01){Obj_Delete(obj)}
		yield;
	}
	Obj_Delete(obj);
}


task MapleLeaf(deX, deY, angX, deAlpha, deScale){
	deScale = deScale*1.25;
		let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D); 
		ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.49);
	ObjPrim_SetTexture(obj, imgEffect);
	ObjSpriteList2D_SetSourceRect(obj, 0, 48, 32, 80);
	ObjSpriteList2D_SetDestCenter(obj);
	ObjRender_SetAngleXYZ(obj, 0, 0, angX);
	ObjRender_SetPosition(obj, deX, deY, 0);
	ObjRender_SetAlpha(obj, deAlpha);

	let scale = deScale;
	let randX = rand(-105, 105);
	let randY = rand(-105, 105);
	let	ang2 = rand(0, 360);
	
	while(scale>0.01){
		scale += ((-0.2)/2)/TimeSpeed;
		deX += (randX/20)/TimeSpeed;
		deY += (randY/20)/TimeSpeed;
		angX += (randX/15)/TimeSpeed;
		ang2 += (randX/15)/TimeSpeed;
		ObjSpriteList2D_ClearVertexCount(obj);
		ObjSpriteList2D_SetSourceRect(obj, 0, 48, 32, 80);
		ObjSpriteList2D_SetDestCenter(obj);
		ObjSpriteList2D_AddVertex(obj);
		
		ObjRender_SetPosition(obj, deX, deY, 0);
		ObjRender_SetAngleXYZ(obj, ang2, angX, (ang2+angX)/2);
		ObjRender_SetScaleXYZ(obj, scale, scale, scale);
		ObjRender_SetAlpha(obj, deAlpha-scale*20);
		yield;
	}
	Obj_Delete(obj);
}

task CreateSwordSlashA2(x, y, spd, angle, offx, damage, scale, sc, erashot){
	yield;
	if(!erashot&&damage != 0){CreateSwordSlashA2(x, y, spd, angle, offx, 0, scale/1.075, sc, erashot)}

	let deAlpha = 0;
	let objtime = 0;
	let mtime = 15;
	
	PlaySE(current~"se_spell.wav");
	
	let collision = CreateStraightLaserA1(x+(128*scale)*cos(angle-90), y+(128*scale)*sin(angle-90), angle+90, 256*scale, 40, mtime, 0, 0);
	ObjShot_SetDamage(collision, damage);
	ObjShot_SetEraseShot(collision, erashot);
	ObjShot_SetSpellFactor(collision, erashot);
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.46);
	ObjPrim_SetTexture(obj, imgBomb);
	ObjSprite2D_SetSourceRect(obj, 0, 0+offx, 128, 256+offx);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetAlpha(obj, 225);
	ObjRender_SetAngleZ(obj, angle);
	ObjRender_SetScaleXYZ(obj, scale, scale, 1);
	if(sc==1){ObjRender_SetScaleXYZ(obj, scale, -scale, 1);}
	ObjRender_SetPosition(obj, x, y, 0);
	let r = mtime/9;
	while(objtime<mtime){
		objtime++;
		ObjRender_SetPosition(obj, ObjRender_GetX(obj)+spd*cos(angle), ObjRender_GetY(obj)+spd*sin(angle), 0);
		if(objtime>=r*2){ObjSprite2D_SetSourceRect(obj, 128, 0+offx, 256, 256+offx);}
		if(objtime>=r*3){ObjSprite2D_SetSourceRect(obj, 256, 0+offx, 384, 256+offx);}
		if(objtime>=r*4){ObjSprite2D_SetSourceRect(obj, 384, 0+offx, 512, 256+offx);}	
		if(objtime>=r*5){ObjSprite2D_SetSourceRect(obj, 0, 256+offx, 128, 512+offx);}
		if(objtime>=r*6){ObjSprite2D_SetSourceRect(obj, 128, 256+offx, 256, 512+offx);}
		if(objtime>=r*7){ObjSprite2D_SetSourceRect(obj, 256, 256+offx, 384, 512+offx);}
		if(objtime>=r*8){ObjSprite2D_SetSourceRect(obj, 384, 256+offx, 512, 512+offx);}	
		yield;
	}
	Obj_Delete(obj);
}


function DigitToArray(digit, count){
	let res = [];
	digit = truncate(digit);

	loop{
		let tnum = truncate(digit % 10);
		digit /= 10;
		res = [tnum] ~ res;
		if(truncate(digit) == 0){break;}
	}

	loop(max(0, count - length(res))){
		res = [0] ~ res;
	}

	return res;
}

function GetEnemyID{
	let earray = GetAllEnemyID;
	let objid = ID_INVALID;
	if(GetEnemyBossSceneObjectID != ID_INVALID){earray = GetEnemyBossObjectID~earray;}
	let size = max(-1, length(earray)-1);
	if(size>=0){objid = earray[0];}
	return objid;
}

function GetClosestEnemyID(x1, y1){
	let earray = GetAllEnemyID;
	if(GetEnemyBossSceneObjectID != ID_INVALID){earray = GetEnemyBossObjectID;}
	let objid = ID_INVALID;
	let dist = 99999;
	let size = max(-1, length(earray));
	if(size>=0){
		ascent(b in 0..size){
			let eID = earray[b];
			let edist = GetDistance(x1,y1,ObjRender_GetX(eID),ObjRender_GetY(eID));
			if(edist<dist){
				dist = edist;
				objid = eID
			}
		}
	}
	return objid;
}

function ArrayMin(array){
    let min = array[0];
    ascent(i in 1..length(array)){
        if(array[i] < min){ min = array[i]; }
	}
    return min;
}

function ArrayMax(array){
    let max = array[0];
    ascent(i in 1..length(array)){
        if(array[i] > max){ max = array[i]; }
    }
    return max;
}

function CheckOutsideScreen(objectID, distance){
	let COSvar = false;
	
	if(ObjRender_GetX(objectID)>GetStgFrameWidth+distance||ObjRender_GetX(objectID)<-distance||
	ObjRender_GetY(objectID)>GetStgFrameHeight+distance||ObjRender_GetY(objectID)<-distance){
		COSvar=true;
	}
	
	return COSvar;
}

function GetDistance(x1,y1,x2,y2){
	return(((x2-x1)^2+(y2-y1)^2)^(1/2))
}

function AnyKey(type){
	let skck = false;
	if(GetVirtualKeyState(VK_LEFT) == type){skck=true;}
	if(GetVirtualKeyState(VK_RIGHT) == type){skck=true;}
	if(GetVirtualKeyState(VK_UP) == type){skck=true;}
	if(GetVirtualKeyState(VK_DOWN) == type){skck=true;}
	return skck;
}
function AllKeysFree{
	let skck = false;
	if(GetVirtualKeyState(VK_LEFT) == KEY_FREE &&
	GetVirtualKeyState(VK_RIGHT) == KEY_FREE &&
	GetVirtualKeyState(VK_UP) == KEY_FREE &&
	GetVirtualKeyState(VK_DOWN) == KEY_FREE){skck=true;}
	return skck;
}
function AnyKeyHeld{
	let skck = false;
	if(GetVirtualKeyState(VK_LEFT) == KEY_HOLD ||
	GetVirtualKeyState(VK_RIGHT) == KEY_HOLD ||
	GetVirtualKeyState(VK_UP) == KEY_HOLD ||
	GetVirtualKeyState(VK_DOWN) == KEY_HOLD){skck=true;}
	return skck;
}
function GetPlayerMoveAngle{
	let angle = 270;
	if(GetVirtualKeyState(VK_DOWN)==KEY_HOLD){
		if(GetVirtualKeyState(VK_RIGHT)==KEY_HOLD){
			angle = 45;
		}else if(GetVirtualKeyState(VK_LEFT)==KEY_HOLD){
			angle = 135;
		}else{
			angle = 90;
		}
	}
	else if(GetVirtualKeyState(VK_UP)==KEY_HOLD){
		if(GetVirtualKeyState(VK_RIGHT)==KEY_HOLD){
			angle = 315;
		}else if(GetVirtualKeyState(VK_LEFT)==KEY_HOLD){
			angle = 225;
		}else{
			angle = 270;
		}
	}else if(GetVirtualKeyState(VK_RIGHT)==KEY_HOLD){
		angle = 0;
	}else if(GetVirtualKeyState(VK_LEFT)==KEY_HOLD){
		angle = 180;
	}
	return angle;
}

