跳到正文

剪贴板

剪贴板 08bkvsro

原文
剪贴板信息

剪贴板信息

收录
更新
C++
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h> 
#define cls system("cls")
#define KEY_DOWN(VK_NONAME)((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
using namespace std;
//#define int long long
//#define double long double
//#define map unordered_map
//#pragma GCC optimize(2,3,"Ofast","inline")
const int N=2e5+10,M=1024,P=1e9+7,MOD=998244353;
const double PI=3.1415926,EPS=0.00001;
const string VER="0.006 [Test Ver]";
// --- Color Map : 0-7 Dark, 8-15 Light
// 0 Black        => Good: ( 12, 12, 12)
// 1 Dark Blue    => Good: (  0, 55,218)
// 2 Dark Green   => Good: ( 19,161, 14)
// 3 Sky Blue     => Good: ( 58,150,221)
// 4 Red          => Good: (197, 15, 31)
// 5 Dark Purple  => Good: (136, 23,152)
// 6 Dirty Yellow => Good: (243,156, 17)
// 7 White        => Good: (204,204,204)
// 8 Grey         => Good: (118,118,118)
// 9 Blue         => Good: ( 59,120,255)
// a Grass Green  => Good: ( 22,198, 12)
// b Cyan         => Good: ( 97,214,214)
// c Pink         => Good: (231, 72, 86)
// d Purple       => Good: (180,  0,158)
// e Light Yellow => Good: (249,241,165)
// f Light White  => Good: (242,242,242)
bool flat,ssun,star,body,fly,tim,smsea,workm;
int  seed;
void out(string s,int id=7,int tim=0){
    HANDLE handle=::GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO info;
    GetConsoleScreenBufferInfo(handle,&info);
    WORD colorBak=info.wAttributes;
	if(!workm)SetConsoleTextAttribute(handle,id);
    for(int i=0;i<(int)s.size();i++){cout<<s[i];Sleep(tim);}
    SetConsoleTextAttribute(handle,colorBak);
    return;
}
int get_seed(int x){
	if(x==-1)return time(0);
	return x;
}
void SetOutput(){
	CONSOLE_CURSOR_INFO cursor_info={1,0};
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
void setp(int x,int y){HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);COORD coord={short(y*2),short(x)};SetConsoleCursorPosition(handle,coord);}
pair<int,int>stoz(int x,int y){return make_pair(x+1e5,y+64);} // See To True
pair<int,int>ztos(int x,int y){return make_pair(x-1e5,y-64);} // True To See
pair<int,int>seepos,psp;
int world[N][M],nether[N][M];
int hi[N],h=5,m=0,s=0,ss,px,py,ppx,ppy,Wait=1000/45;
double add_sp,G=0.5;
double rand_k(){
	int rnd=rand()%100;
	if(rnd<=42)return 1.5;
	if(rnd<=42+32)return 1.2;
	if(rnd<=42+32+22)return 1;
	return 0.7;
}
bool isblk(int x,int y){
	return(world[x][y]>-1&&(world[x][y]<4||world[x][y]>10)&&world[x][y]!=21&&world[x][y]!=22&&world[x][y]!=23);
}
void fill(int i,int j,int v){
	if(world[i][j]==3)world[i][j]=v;
}
void makehole(int x,int y,int z){
	for(int i=max(0,x-z);i<=x+z;i++){
		for(int j=max(y-z,0);j<=y+z;j++){
			if(min(abs(i-max(0,x-z)),abs(i-(x+z)))+min(abs(j-max(0,y-z)),abs(j-(y+z)))<3)continue;
			else if(min(abs(i-max(0,x-z)),abs(i-(x+z)))+min(abs(j-max(0,y-z)),abs(j-(y+z)))==3){
				int rnd=((rand()%100000)*rand())%1000000;
				if(rnd<100000){ // up
					if(j<20)continue;
					rnd=rand()%2;
					if(rnd==0){
						fill(i-1,j,14);
						fill(i-2,j,14);
						fill(i,j-1,14);
						fill(i-1,j-1,14);
						fill(i-2,j-1,14);
						fill(i-3,j-1,14);
						fill(i-1,j-2,14);
						fill(i-2,j-2,14);
					}else{
						fill(i-1,j,14);
						fill(i-2,j,14);
						fill(i,j-1,14);
						fill(i-2,j-1,14);
						fill(i-1,j-2,14);
						fill(i-2,j-2,14);	
						fill(i-2,j-3,14);
						fill(i-1,j-3,14);
						fill(i,j-3,14);	
						fill(i+1,j-3,14);			
					}
				}else if(rnd<100000+40000){
					rnd=rand()%2;
					if(rnd==0){
						fill(i-1,j,15);
						fill(i-2,j,15);
						fill(i,j-1,15);
						fill(i-1,j-1,15);
						fill(i-2,j-1,15);
						fill(i-3,j-1,15);
					}else{
						fill(i-1,j,15);
						fill(i-2,j,15);
						fill(i,j-1,15);
						fill(i-2,j-1,15);
						fill(i-1,j-2,15);
						fill(i-2,j-2,15);			
					}					
				}else if(rnd<100000+40000+20000){
					fill(i,j,16);
					fill(i-1,j,16);
					fill(i,j-1,16);
					rnd=rand()%2;
					if(rnd==0){
						fill(i+1,j-1,16);
					}else{
						fill(i-1,j-1,16);
					}				
				}else if(rnd<100000+40000+20000+10000){
					if(j>30)continue; // deep
					fill(i,j,17);
					fill(i-1,j,17);
					fill(i,j-1,17);
					rnd=rand()%2;
					if(rnd==0){
						fill(i+1,j-1,17);
					}else{
						fill(i-1,j-1,17);
					}						
				}else world[i][j]=3;
			}else if(world[i][j]!=11)world[i][j]=-1;
		}
	}
}
int rand_m(){
	int rnd=rand()%100;
	if(rnd<50)return rand()%10; // 50%
	if(rnd<75)return rand()%50; // 25%
	if(rnd<90)return rand()%20; // 15%
	if(rnd<97)return rand()%30; // 7%
	return rand()%40; // 3%
}
string blk_map(int x){
	switch(x){
		case 0:return "Grass";
		case 1:return "Snow";
		case 2:return "Dirt";
		case 3:return "Stone";
		case 4:return "Wood";
		case 5:return "HighLeaf_0";
		case 6:return "HighLeaf_1";
		case 7:return "NormalLeaf_0";
		case 8:return "NormalLeaf_1";
		case 9:return "NormalWater";
		case 10:return "Cloud";
		case 11:return "BasicStone";
		case 12:return "Sand";
		case 13:return "Ice";
		case 14:return "Coal";
		case 15:return "Iron";
		case 16:return "Gold";
		case 17:return "Diamond";
		case 18:return "Ruby";
		case 19:return "Gravel";
		case 20:return "SandStone";
		case 21:return "Cactus";
		case 22:return "LittleSnow";
		case 23:return "Bamboo";
		default:return "";
	}
}
int sky_color(){
	if(tim&&(h<=4||h>=20))return 0x00;
	if(tim&&(h>=5&&h<=6))return 0x60;
	if(tim&&(h>=7&&h<=17))return 0x30;
	if(tim&&(h>=18&&h<=19))return 0x60;
	return 0x30;
}
void printWorld(){
	setp(0,0);
	for(int j=seepos.second+10,y=1;j>=seepos.second-10;j--,y++){
		for(int i=seepos.first-15,x=1;i<=seepos.first+15;i++,x++){
			if(i==px&&j==py&&body)out("  ",0x16);
			else if(i==px&&j==py+1&&body)out("[]",0xe0);
			else if(world[i][j]==0)out("==",0xa2);
			else if(world[i][j]==1)out("  ",0xf0);
			else if(world[i][j]==2)out(":.",0x68);
			else if(world[i][j]==3)out("  ",0x80);
			else if(world[i][j]==4)out("||",0x60);
			else if(world[i][j]==5||world[i][j]==6)out("##",0x2a);
			else if(world[i][j]==7||world[i][j]==8)out("##",0xa2);
			else if(world[i][j]==10)out("  ",0x70);
			else if(world[i][j]==11)out("==",0x08);
			else if(world[i][j]==12)out("##",0xe6);
			else if(world[i][j]==13)out(":.",0x9f);
			else if(world[i][j]==14)out(".:",0x80);
			else if(world[i][j]==15)out("::",0x86);
			else if(world[i][j]==16)out("..",0x8e);
			else if(world[i][j]==17)out(":.",0x8b);
			else if(world[i][j]==18)out("::",0x8a);
			else if(world[i][j]==19)out("##",0x87);
			else if(world[i][j]==20)out("==",0xe6);
			else if(world[i][j]==21)out("||",0x20);
			else if(world[i][j]==22)out("__",15+sky_color()); // snow_fall
			else if(world[i][j]==23)out("||",0xa2);
			else if(!ssun&&world[i][j]==9)out("  ",0xb0); // Water
			else if(tim&&h<=4&&h>=1&&(x>=20&&x<=25)&&(y>=10&&y<=15))out("  ",(world[i][j]==9&&ssun?0x70:0xf0)); // Moon R
			else if(tim&&h>=20&&(x<=10&&x>=5)&&(y>=5&&y<=10))out("  ",(world[i][j]==9&&ssun?0x70:0xf0));        // Moon L
			else if(tim&&h==0&&(x>=13&&x<=18)&&(y>=2&&y<=7))out("  ",(world[i][j]==9&&ssun?0x70:0xf0));         // Moon M
			else if(tim&&h>=13&&h<=19&&(x>=20&&x<=25)&&(y>=10&&y<=15))out("  ",(world[i][j]==9&&ssun?0x60:0xe0)); // Sun R
			else if(tim&&h>=5&&h<=11&&(x<=10&&x>=5)&&(y>=5&&y<=10))out("  ",(world[i][j]==9&&ssun?0x60:0xe0));        // Sun L
			else if(tim&&h==12&&(x>=13&&x<=18)&&(y>=2&&y<=7))out("  ",(world[i][j]==9&&ssun?0x60:0xe0));         // Sun M
			else if(world[i][j]==9)out("  ",0xb0); // Water
			else out("  ",sky_color());
		}
		out("||\n",0xe0);
	}
	for(int i=seepos.first-15;i<=seepos.first+16;i++)out("==",0xe0);
	out("\n",0xe0);
}
void UpdateWorld(){ // Update The World
	srand(seed);
	hi[0]=64;
	for(int i=1;i<=2e5;i++){
		hi[i]=hi[i-1];
		for(int j=64;j>=0;j--){
			if(j==64)world[i][j]=0; // Grass
			else if(j>60)world[i][j]=2; // Dirt
			else if(j==0)world[i][j]=11; // BasicStone
			else world[i][j]=3; // Stone
		}
		if(i%10000==0){
			out("==============================\n",0xe);
			out(("C++ Craft v"+VER+"\n\n").c_str());
			out("Update World     :      \n");
			out("Update Ground    : ");
			printf("%03d %%",i/10000*5);
			out("\n\n\n\n\n\n\n\n\n\n\n\n==============================\n",0xe);
			Sleep(50);
			setp(0,0);
		}
	}
	if(!flat){
		for(int i=1;i<=50000;i++){ // 50000 moutains
			int r=(rand()%(200000)*rand())%200000;
			int z=rand_m();
			double mk=rand_k();
			for(int j=max(0,r-z);j<=min(200000,r+z);j++){
				for(int h=(z-abs(r-j))/mk+64;h>=1;h--){
					world[j][h]=3; // Stone
					hi[j]=max(hi[j],h);
				}
			}
			if(i%500==0){
				out("==============================\n",0xe);
				out(("C++ Craft v"+VER+"\n\n").c_str());
				out("Update World     :\n");
				out("Update Ground    : 100 %\n");
				out("Update Mountains : ");
				printf("%03d %%",i/500);
				out("\n\n\n\n\n\n\n\n\n\n\n==============================\n",0xe);
				setp(0,0);
			}
		}
		for(int i=1;i<=2e5;i+=150){
			int ll=i,rr=i+rand()%100+10,mx=0;
			for(int k=ll;k<=rr;k++)mx=max(mx,hi[k]);
			while(ll>0&&hi[ll-1]>mx)--ll;
			while(rr<2e5&&hi[rr+1]>mx)++rr;
			for(int k=max(ll,1);k<=min(rr,200000);k++)for(int j=min(mx,min(hi[ll-1]+abs(k-ll),hi[rr+1]+abs(k-rr)));j>=hi[k];j--)world[k][j]=3,hi[k]=max(hi[k],j);			
			if(i%10000==0){
				out("==============================\n",0xe);
				out(("C++ Craft v"+VER+"\n\n").c_str());
				out("Update World     :\n");
				out("Update Ground    : 100 %\n");
				out("Update Mountains : 100 %\n");
				out("Update Field     : ");
				printf("%03d %%",i/10000*5);
				out("\n\n\n\n\n\n\n\n\n\n==============================\n",0xe);
				setp(0,0);
			}
		}
		for(int i=1;i<=2e5;i++){
			if(world[i][hi[i]]!=3)continue;
			int lt=rand()%3+5,des=rand()%200,desl=rand()%50+10;
			if(des!=0){
				for(int j=hi[i];j>=1;j--){
					if(j==hi[i])world[i][j]=(j>100?1:0); // Grass
					else if(abs(j-hi[i])<lt)world[i][j]=2; // Dirt
					else world[i][j]=3; // Stone
				}
			}else{
				for(int k=i;k<=min(i+desl,200000);k++){
					for(int j=hi[k];j>=1;j--){
						if(hi[k]==j&&j>100)world[k][j]=22;
						else if(hi[k]-j<5-rand()%2)world[k][j]=(hi[k]-j>3?20:12); // Sand
						else if(abs(j-hi[k])<lt)world[k][j]=19; // Gravel
						else world[k][j]=3; // Stone
					}
				}
			}
			if(i%10000==0){
				out("==============================\n",0xe);
				out(("C++ Craft v"+VER+"\n\n").c_str());
				out("Update World     : \n");
				out("Update Ground    : 100 %\n");
				out("Update Mountains : 100 %\n");
				out("Update Field     : 100 %\n");
				out("Update Dirt      : ");
				printf("%03d %%",i/10000*5);
				out("\n\n\n\n\n\n\n\n\n==============================\n",0xe);
				setp(0,0);
			}
		}
		for(int i=170;i<2e5-100;i+=20){
			int ll=i,rr=i+rand()%10+10,mx=0,mn=1e9;
			bool flsand=0;
			for(int k=ll;k<=rr;k++)mx=max(mx,hi[k]),mn=min(mn,hi[k]);
			while(ll>0&&hi[ll-1]<mx+3)--ll,mn=min(mn,hi[ll]);
			while(rr<2e5&&hi[rr+1]<mx+3)++rr,mn=min(mn,hi[rr]);
			if(mx-mn>20&&smsea)continue;
			if(rr-ll>40&&mx+3<100&&smsea)continue;
			for(int k=ll;k<=rr;k++){
				if(world[k][hi[k]]==12){flsand=1;break;}
				for(int j=hi[k];j>=1;j--){
					if(world[k][j]==0||world[k][j]==2)world[k][j]=(hi[k]-j>5?19:hi[k]-j>2?20:12); // Sand
				}				
			}
			if(flsand)continue;
			int ch=rand()%3+5,x=ll-1;
			for(int j=1;j<=ch;j++)world[x][hi[x]+j]=23; // Bamboo	
			ch=rand()%3+5,x=rr+1;
			for(int j=1;j<=ch;j++)world[x][hi[x]+j]=23; // Bamboo	
			for(int k=max(ll,1);k<=min(rr,200000);k++)for(int j=hi[k];j<=hi[k]+20;j++)if(world[k][j]>=4&&world[k][j]<=8)world[k][j]=-1; // clear
			for(int k=ll;k<=rr;k++){
				for(int j=mx+3;j>=hi[k];j--)world[k][j]=9; // Water
				if(mx+3>100)world[k][mx+3]=13; // Ice
			}
			if(i%10000==0){
				out("==============================\n",0xe);
				out(("C++ Craft v"+VER+"\n\n").c_str());
				out("Update World     :\n");
				out("Update Ground    : 100 %\n");
				out("Update Mountains : 100 %\n");
				out("Update Field     : 100 %\n");
				out("Update Dirt      : 100 %\n");
				out("Update Water     : ");
				printf("%03d %%",i/10000*5);
				out("\n\n\n\n\n\n\n\n==============================\n",0xe);
				setp(0,0);
			}
			i=rr+1;
		}
		int tree_jp=rand()%15+5,tcnt=0;
		for(int i=10;i<=2e5;i+=tree_jp){
			if(tcnt%100<50)tree_jp=2+rand()%2;
			else tree_jp=rand()%15+5;
			++tcnt;
			if(world[i][hi[i]]==12&&world[i][hi[i]+1]!=9){ // cactus
				int ch=rand()%3+5;
				for(int j=1;j<=ch;j++){
					if(ch-j<1);
					else if(j>2&&rand()%2&&j%2)world[i-1][hi[i]+j]=21;
					else if(j>2&&rand()%2&&j%2)world[i+1][hi[i]+j]=21;
					world[i][hi[i]+j]=21;
				} // Cactus				
			}else if(hi[i]>100){ // high
				int trh=11+rand()%3,wd=rand()%2+1;
				for(int j=1;j<=trh;j++){
					if(world[i][hi[i]+j]>2||world[i][hi[i]]==22)break;
					world[i][hi[i]+j]=4; // Wood	
					if(j>wd&&j%2)for(int k=max(-(trh+1-j)/2,-6);k<=min((trh+1-j)/2,6);k++)if(world[i+k][hi[i]+j]==-1||k==0)world[i+k][hi[i]+j]=5; // HighLeaf_0
					if(j>wd)world[i][hi[i]+j]=6; // HighLeaf_1
				}
			}else{ // ground
				int trh=6+rand()%3,wd=rand()%2+1;
				for(int j=1;j<=trh;j++){
					if(world[i][hi[i]+j]==9)break;
					world[i][hi[i]+j]=4; // Wood
					if(j>wd&&j<trh)for(int k=-2;k<=2;k++)if(world[i+k][hi[i]+j]==-1||k==0)world[i+k][hi[i]+j]=7; // NormalLeaf_0
					if(j>wd)for(int k=-1;k<=1;k++)if(world[i+k][hi[i]+j]==-1||k==0)world[i+k][hi[i]+j]=7; // NormalLeaf_0
					if(j>wd)world[i][hi[i]+j]=8;	
				}
			}
			if(i%10000<100){
				out("==============================\n",0xe);
				out(("C++ Craft v"+VER+"\n\n").c_str());
				out("Update World     :\n");
				out("Update Ground    : 100 %\n");
				out("Update Mountains : 100 %\n");
				out("Update Field     : 100 %\n");
				out("Update Dirt      : 100 %\n");
				out("Update Water     : 100 %\n");
				out("Update Tree      : ");
				printf("%03d %%",i/10000*5);
				out("\n\n\n\n\n\n\n==============================\n",0xe);
				setp(0,0);
			}
		}
		for(int i=10;i<2e5-100;i+=rand()%20+15){
			int j=rand()%20+110;
			if(rand()%2){ // cloud1
				for(int k=i;k<=i+rand()%10+10;k++){
					if(world[k][j]==-1)world[k][j]=10;
					if(world[k+2][j-1]==-1)world[k+2][j-1]=10;
				}
			}else{ // cloud2
				for(int k=i;k<=i+rand()%10+10;k++){
					if(world[k-2][j+1]==-1)world[k-2][j+1]=10;
					if(world[k][j]==-1)world[k][j]=10;
				}			
			}
			if(i%10000<100){
				out("==============================\n",0xe);
				out(("C++ Craft v"+VER+"\n\n").c_str());
				out("Update World     :\n");
				out("Update Ground    : 100 %\n");
				out("Update Mountains : 100 %\n");
				out("Update Field     : 100 %\n");
				out("Update Dirt      : 100 %\n");
				out("Update Water     : 100 %\n");
				out("Update Tree      : 100 %\n");
				out("Update Cloud     : ");
				printf("%03d %%",i/10000*5);
				out("\n\n\n\n\n\n==============================\n",0xe);
				setp(0,0);
			}
		}
		for(int i=1;i<=2e5;i++){
			for(int j=hi[i];world[i][j]==9||world[i][j]==12&&j<=256;j++){
				hi[i]=j;
			}
		}
	}
	for(int i=1;i<=2e5;i++){
		for(int j=hi[i];j>=1;j--){
			if(world[i][j]==3){
				int rnd=((rand()%100000)*rand())%1000000;
				if(rnd<5000){ // up
					if(j<20)continue;
					rnd=rand()%2;
					if(rnd==0){
						fill(i-1,j,14);
						fill(i-2,j,14);
						fill(i,j-1,14);
						fill(i-1,j-1,14);
						fill(i-2,j-1,14);
						fill(i-3,j-1,14);
						fill(i-1,j-2,14);
						fill(i-2,j-2,14);
					}else{
						fill(i-1,j,14);
						fill(i-2,j,14);
						fill(i,j-1,14);
						fill(i-2,j-1,14);
						fill(i-1,j-2,14);
						fill(i-2,j-2,14);	
						fill(i-2,j-3,14);
						fill(i-1,j-3,14);
						fill(i,j-3,14);	
						fill(i+1,j-3,14);			
					}
				}else if(rnd<5000+2000){
					rnd=rand()%2;
					if(rnd==0){
						fill(i-1,j,15);
						fill(i-2,j,15);
						fill(i,j-1,15);
						fill(i-1,j-1,15);
						fill(i-2,j-1,15);
						fill(i-3,j-1,15);
					}else{
						fill(i-1,j,15);
						fill(i-2,j,15);
						fill(i,j-1,15);
						fill(i-2,j-1,15);
						fill(i-1,j-2,15);
						fill(i-2,j-2,15);			
					}					
				}else if(rnd<5000+2000+1000){
					fill(i,j,16);
					fill(i-1,j,16);
					fill(i,j-1,16);
					rnd=rand()%2;
					if(rnd==0){
						fill(i+1,j-1,16);
					}else{
						fill(i-1,j-1,16);
					}				
				}else if(rnd<5000+2000+1000+500){
					if(j>30)continue; // deep
					fill(i,j,17);
					fill(i-1,j,17);
					fill(i,j-1,17);
					rnd=rand()%2;
					if(rnd==0){
						fill(i+1,j-1,17);
					}else{
						fill(i-1,j-1,17);
					}						
				}else if(rnd<5000+2000+1000+500+700){
					if(j<64)continue; // mountains
					fill(i,j,18);
					if(rand()%2)fill(i,j-1,18);
				}
			}
		}
	}
	for(int i=1;i<=2e5;i+=100){
		int j=rand()%30+5;
		if(world[i][j]==3)makehole(i,j,rand()%8+5);
		if(i%10000==0){
			out("==============================\n",0xe);
			out(("C++ Craft v"+VER+"\n\n").c_str());
			out("Update World     :\n");
			out("Update Ground    : 100 %\n");
			out("Update Mountains : 100 %\n");
			out("Update Field     : 100 %\n");
			out("Update Dirt      : 100 %\n");
			out("Update Water     : 100 %\n");
			out("Update Tree      : 100 %\n");
			out("Update Cloud     : 100 %\n");
			out("Update Mineral   : 100 %\n");
			out("Update Minehole  : ");
			printf("%03d %%",i/10000*5);
			out("\n\n\n\n==============================\n",0xe);
			setp(0,0);
		}
	}
	seepos=stoz(0,hi[100000]-64+5);
	px=seepos.first,py=seepos.second;
	setp(0,0);
	out("==============================\n",0xe);
	out(("C++ Craft v"+VER+"\n\n").c_str());
	out("Update World     :\n");
	out("Update Ground    : 100 %\n");
	out("Update Mountains : 100 %\n");
	out("Update Field     : 100 %\n");
	out("Update Dirt      : 100 %\n");
	out("Update Water     : 100 %\n");
	out("Update Tree      : 100 %\n");
	out("Update Cloud     : 100 %\n");
	out("Update Mineral   : 100 %\n");
	out("Update Minehole  : 100 %\n");
	Sleep(200);
	out("\nUpdate           : ");
	out("Finished.\n",10);
	out("Here We Go!\n");
	out("==============================\n",0xe);
	Sleep(2000);
}
void player_fall(){
	py+=add_sp;
	while(isblk(px,py)){++py;}
	if(isblk(px,py-1)){add_sp=0;return;}
	add_sp-=G; // fall
}
void player_jump(){
	if(world[px][py]==9)add_sp=1;
	else if(isblk(px,py-1))add_sp=1.5;
	player_fall();
}
void UpdateNewGame(){
	memset(world,-1,sizeof(world)); // Air
	 flat=0; // flat
	 ssun=0; // strange sun
	 star=0;
	 body=0; // body
	  fly=0; // fly
	  tim=0; // time
	smsea=0; // small sea
	workm=0; // work mode
	seed=get_seed(-1); // seed
	UpdateWorld();
}
void StartPage(){
	out("==============================\n",0xe);
	out(("C++ Craft v"+VER+"\n\n").c_str());
	out("Press Any Key To ");out("Start.\n\n\n\n\n\n\n\n\n\n\n\n\n",10);
	out("==============================\n",0xe);
	while(!star)for(int i=0;i<=256;i++)if(KEY_DOWN(i))star=1;
	setp(0,0);	
}
signed main(){
	system(("title C++ Craft v"+VER).c_str());
	SetOutput();
	StartPage();
	UpdateNewGame();
	while(1){
		printWorld();
		printf("   x: %06d \n   y: %06d \n",seepos.first-100000,seepos.second);
		if(tim)printf("time: %02dh%02dm\n",h,m);
		printf("seed: %d\n",seed);
		ppx=px,ppy=py;psp=seepos;
		if(KEY_DOWN(32))fly=!fly;
		if(fly&&body){
			if(KEY_DOWN(38))seepos.second++,py++;
			if(KEY_DOWN(40))seepos.second--,py--;
			if(KEY_DOWN(39))seepos.first++,px++;
			if(KEY_DOWN(37))seepos.first--,px--;
		}else if(!body){
			if(KEY_DOWN(38))seepos.second++;
			if(KEY_DOWN(40))seepos.second--;
			if(KEY_DOWN(39))seepos.first++;
			if(KEY_DOWN(37))seepos.first--;			
		}else{
			if(KEY_DOWN(38))player_jump();
			if(KEY_DOWN(39)&&!isblk(px+1,py+1))px++;
			if(KEY_DOWN(37)&&!isblk(px-1,py+1))px--;
			player_fall();
			seepos.first=px,seepos.second=py;	
		}
		if(world[px][py]>-1&&isblk(px,py)&&body)px=ppx,py=ppy,seepos=psp;
		(seepos.second+=M)%=M;
		if(body&&world[px][py-1]==13)Sleep(0.5*Wait); // Move On Ice
		else if(body&&world[px][py]!=9)Sleep(Wait); // Move
		else if(body)Sleep(2*Wait); // Move In Water
		(py+=M)%=M;
		if(tim){
			s+=5;
			if(s>=60)m++,s=0;
			if(m>=60)h++,m=0;
			if(h>=24)h=0;
		}
	}
	return 0;
}