这是我肝了几节课做出来的小恐龙c++制作,换因游玩,代码如下:

#include<bits/stdc++.h>
#include<windows.h>
#define VK_W 0x57
using namespace std;
const int max_x=55,max_y=25; 
int d[max_y+1][max_x+1],y_z,t_z=0,x_z=16,l_f[99999],z_1[9999][5],z_s1;
double time_lou;
bool s_z=1;
void c_6()
{
	int i=0,l=0;
	for(int j=1;j<=z_s1;j++)
	{
		if(z_1[j][4]!=0)
		{
			i++;
			z_1[i][1]=z_1[j][1];
			z_1[i][2]=z_1[j][2];
			z_1[i][3]=z_1[j][3];
			z_1[i][4]=z_1[j][4];
		}else
		{
			l++;
		}
	}
	z_s1-=l;
}
void c_5()
{
	for(int i=1;i<=z_s1;i++)
	{
		if(z_1[i][3]==1)
		{
			COORD pos={z_1[i][1],z_1[i][2]};
			HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
			SetConsoleCursorPosition(hOut,pos);
			cout<<" ";
			z_1[i][1]-=1;
			if(z_1[i][1]!=1)
			{
				pos={z_1[i][1],z_1[i][2]};
				SetConsoleCursorPosition(hOut,pos);
				cout<<"▌";
				if(z_1[i][1]==x_z&&z_1[i][2]<=y_z)
				{
					s_z=0;
				}
			}else
			{
				z_1[i][4]=0;
			}
		}/*else
		{
			if(z_1[i][3]==2)
			{
				COORD pos={z_1[i][1],z_1[i][2]};
				HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
				SetConsoleCursorPosition(hOut,pos);
				cout<<" ";
				pos={z_1[i][1],z_1[i][2]-1};
				SetConsoleCursorPosition(hOut,pos);
				cout<<" ";
				z_1[i][1]-=1;
				if(z_1[i][1]!=1)
				{
					pos={z_1[i][1],z_1[i][2]};
					SetConsoleCursorPosition(hOut,pos);
					cout<<"▌";
					pos={z_1[i][1],z_1[i][2]-1};
					SetConsoleCursorPosition(hOut,pos);
					cout<<"▌";
				}else
				{
					z_1[i][4]=0;
				}
			}else
			{
				if(z_1[i][3]==3)
				{
					COORD pos={z_1[i][1],z_1[i][2]};
					HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
					SetConsoleCursorPosition(hOut,pos);
					cout<<" ";
					pos={z_1[i][1],z_1[i][2]-1};
					SetConsoleCursorPosition(hOut,pos);
					cout<<" ";
					pos={z_1[i][1],z_1[i][2]-2};
					SetConsoleCursorPosition(hOut,pos);
					cout<<" ";
					if(z_1[i][1]!=1)
					{
						pos={z_1[i][1],z_1[i][2]};
						SetConsoleCursorPosition(hOut,pos);
						cout<<"▌";
						pos={z_1[i][1],z_1[i][2]-1};
						SetConsoleCursorPosition(hOut,pos);
						cout<<"▌";
						pos={z_1[i][1],z_1[i][2]-2};
						SetConsoleCursorPosition(hOut,pos);
						cout<<"▌";
					}else
					{
						z_1[i][4]=0;
					}
				}
			}
		}*/
	}
	c_6();
}
void c_4(int x,int y)
{
	int n=0,u=time_lou;
	while(u>0)
	{
		n++;
		l_f[n]=u%10;
		u/=10;
	}
	COORD pos={x,y};
	HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut,pos);
	for(int i=1;i<=n+5;i++)
	{
		cout<<" ";
		COORD pos={x-i,y};
		HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleCursorPosition(hOut,pos);
	}
	cout<<"分数:"; 
	for(int i=n;i>=1;i--)
	{
		COORD pos={x-i,y};
		HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleCursorPosition(hOut,pos);
		cout<<l_f[i];
	} 
}
void c_3(int x,int y)
{
	COORD pos={x,y};
	HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut,pos);
}
void c_2()
{
	y_z=2;
	while(y_z+1!=20)
	{
		c_3(x_z,y_z);
		cout<<"●"; 
		c_3(x_z,y_z-1);
		cout<<"  ";
		Sleep(90);
		y_z++;
	}
}
void c_1()
{
	for(int i=1;i<=max_y;i++)
	{
		for(int j=1;j<=max_x;j++)
		{
			if(i>=20)
			{
				d[i][j]=2;
			}
			if(i==1||i==max_y||j==1||j==max_x)
			{
				d[i][j]=1;
			}
		}
	}
}
void x1()
{
	for(int i=1;i<=max_y;i++)
	{
		for(int j=1;j<=max_x;j++)
		{
			if(d[i][j]==1)
			{
				printf("■");
			}else
			{
				if(d[i][j]==2)
				{
					printf("█ ");
				}else
				{
					printf("  ");
				}
			}
		}
		printf("\n");
	}
	return;
}
int main()
{
	c_1();
	x1();
	c_2();
	y_z=19;
	srand(time(0));
	while(s_z==1)
	{
		if(s_z==0)
		{
			break;
		}
		if(GetAsyncKeyState(VK_W)&&y_z==19)
		{
			t_z=1;y_z--;
		}
		if(y_z>10&&t_z==1)
		{
			y_z--;
			c_3(x_z,y_z);
			cout<<"●";
			c_3(x_z,y_z+1);
			cout<<"  ";
		}else
		{
			if(t_z==1)
			{
				t_z=0;
			}
		}
		if(t_z==0&&y_z!=19)
		{
			t_z=-1;
		}
		if(y_z!=19&&t_z==-1)
		{
			c_3(x_z,y_z);
			cout<<"●";
			c_3(x_z,y_z-1);
			cout<<"  ";
			y_z++;
		}else
		{
			if(t_z==-1)
			{
				t_z=0;
				y_z=19;
			}
		}
		int j_xr=rand()%15+1;
		if(j_xr==15)
		{
			int g=rand()%1+1;
			z_s1++;
			z_1[z_s1][1]=105;
			z_1[z_s1][2]=19-g;
			z_1[z_s1][3]=g;
			z_1[z_s1][4]=1;
		}/*else
		{
			j_xr=rand()%30+1;
		}*///以后更新别的障碍 
		c_5();
		for(int i=1;i<=1;i++)
		{	
			time_lou+=0.6;
			c_4(104,3);
			Sleep(50);
		}
	}
	for(int i=0;i<=max_y;i++)
	{
		for(int j=0;j<=max_x*2-1;j++)
		{
			COORD pos={j,i};
			HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
			SetConsoleCursorPosition(hOut,pos);
			cout<<" ";
			Sleep(0.75);
		}
	}
	c_4(62,12);
	printf("\n\n\n\n\n\n\n\n\n\n\n\n");
	return 0;
}
共280多行,制作不宜

本站作者已申明原创,禁止转载!

文章内容属作者个人观点,不代表本站立场,如有侵权立删。

   口袋儿题库-青少儿编程自测题库