c++小游戏[2.0.1测试版本]和[2.2版本]

这个小游戏就是原来的坑人小游戏,原来是1.0版本,2.0.1测试版本增加了

1.“漂亮”的首页面

2.猜数字游戏

2.0.2版本预告:增加剪刀石头布、高精度算法

1.0版本就是今天刚出的,我更新快吧?

呵呵......

对了,代码忘出了

(新版本更新了,快去看看吧!!!)

/*
	Name: 
	Copyright: 
	Author: 
	Date: 01/01/22 18:16 
	Description: 
*/
#include
#include
#include
#include
#include
#include
#include 
#include 
#include 
#pragma comment(lib, "winmm.lib")
#include
#include
#include
#include
#include
#include
#define high 25
#define width 80
#define bullet_num 5
#define up 1
#define down 2
#define left 3
#define right 4
using namespace std;
#define GameW 10
#define GameH 20


int color(int a)//颜色函数
{
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleTextAttribute(hConsole, a);    //更改文字颜色
	return 0;
}

void printinit()//首页字体
{
    printf("\n");
     printf("\n");
      printf("\n");
	color(5);
printf("     ◆         ◆    			\n");
printf("       ◆    ◆     				\n");
printf("          ◆      		\n");
printf("           ◆     				\n");
printf("           ◆      			\n");
printf("           ◆					\n");
printf("           ◆					\n");
printf("           ◆					\n");
printf("                        \n");
printf("     ◆        ◆                   \n");
printf("       ◆     ◆                    \n");
printf("         ◆  ◆                      \n");
printf("            ◆                      \n");
printf("          ◆  ◆                   \n");
printf("        ◆      ◆                  \n\n");
color(5);
printf("          Y     X:按任意键解冻");
}

//病毒1(光标乱跑)
//病毒1解除方法:Alt+F4 或 Ctrl+c 
void move()
{
	int x = GetSystemMetrics(SM_CXSCREEN);
	int y = GetSystemMetrics(SM_CYSCREEN);
	srand(time(0));
	while (1)
	{
		SetCursorPos(rand()%x,rand()%y);
	}
} 

//屏幕乱闪 
void pc()
{
	for(int sws = 0;sws<10;sws++)
	{
		system("color A0");
		Sleep(100);
		system("color B0");
		Sleep(100);
		system("color C1");
		Sleep(100);
		system("color D0");
		Sleep(100);
		system("color E0");
		Sleep(100);
		system("color F0");
		Sleep(100);
	}
}
 
void sl()
{
	int x1,y1;
	while(!_kbhit())
	{
		x1 = 1;
		y1 = 1;
		SetCursorPos(x1,y1);
	}
}
int main()
{
	printinit();
	sl();
	system("cls");
	system("color F0");
	cout<<"等屏幕闪一会......";
	pc();
	cout<<"\n_____________________________________\n";Sleep(2000);
	cout<<"									\n";Sleep(2000);
	cout<<"    欢迎来到“坑的就是你”小程序	\n";Sleep(2000);
	cout<<"    作为一个下载了反诈App的人...	\n";Sleep(2000);
	cout<<"    请慎重进入。					\n";Sleep(2000);
	cout<<"______________________________________\n"; 
	cout<<"\n1.现在进入\n2.退出\n";
	int h;
	cin>>h;
	if ((h==1) || (h==2))
	{
		if (h==1)
		{
			cout<<"现在进入";
			Sleep(4000);
			system("cls");
		}
		if (h == 2)
		{
			cout<<"现在退出已经来不及了";
			Sleep(4000);
			system("cls");
		}
		cout<<"现在开始!!!";
		cout<>a;
		cout<<"你终于关完了,继续。"<>op;
			if (op==1)
			{
				cout<<"\n\n\n猜数字\n";
				srand((int)time(NULL));
				int n=rand()%1000;
				int op_1=0;
				int temp_1=0;
				cout<<"from 0 to 1000.";
				while(true)
				{
					cin>>op_1;
					if (op_1>n) 
					{
						cout<<"大了!"; 
						temp_1++; 
						continue;
					}
					if (op_1

——————————————————华丽的分割线———————————————————

不要复制旧版本的代码了,看看新版本!!!

c++小游戏2.2版本更新了!

这次更新增加了

1.高精度计算加法、减法

2.修复了3个bug

3.走迷宫游戏

因为不想在这么简单的程序上逗留太长时间,所以我在更新这个程序的同时,也会发一些c++、html、python的教程(毕竟作者还学过几年python)

......额,好像扯远了。

上代码!!!

Dev c++运行通过。

/*
	Name: 
	Copyright: 
	Author: 
	Date: 02/01/22 09:07
	Description: 
*/
 
#include
#include
#include
#include
#include
#include
#include 
#include 
#include 
#pragma comment(lib, "winmm.lib")
#include
#include
#include
#include
#include
#include
#define high 25
#define width 80
#define bullet_num 5
#define up 1
#define down 2
#define left 3
#define right 4
using namespace std;
#define GameW 10
#define GameH 20
 
 
int color(int a)//颜色函数
{
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleTextAttribute(hConsole, a);    //更改文字颜色
	return 0;
}
 
void printinit()//首页字体
{
    printf("\n");
     printf("\n");
      printf("\n");
	color(5);
printf("     ◆         ◆    			\n");
printf("       ◆    ◆     				\n");
printf("          ◆      		\n");
printf("           ◆     				\n");
printf("           ◆      			\n");
printf("           ◆					\n");
printf("           ◆					\n");
printf("           ◆					\n");
printf("                        \n");
printf("     ◆        ◆                   \n");
printf("       ◆     ◆                    \n");
printf("         ◆  ◆                      \n");
printf("            ◆                      \n");
printf("          ◆  ◆                   \n");
printf("        ◆      ◆                  \n\n");
color(5);
printf("          Y     X:按任意键解冻");
}
 
//病毒1(光标乱跑)
//病毒1解除方法:Alt+F4 或 Ctrl+c 
void move()
{
	int x = GetSystemMetrics(SM_CXSCREEN);
	int y = GetSystemMetrics(SM_CYSCREEN);
	srand(time(0));
	while (1)
	{
		SetCursorPos(rand()%x,rand()%y);
	}
} 
 
//屏幕乱闪 
void pc()
{
	for(int sws = 0;sws<10;sws++)
	{
		system("color A0");
		Sleep(100);
		system("color B0");
		Sleep(100);
		system("color C1");
		Sleep(100);
		system("color D0");
		Sleep(100);
		system("color E0");
		Sleep(100);
		system("color F0");
		Sleep(100);
	}
}
 
void sl()
{
	int x1,y1;
	while(!_kbhit())
	{
		x1 = 1;
		y1 = 1;
		SetCursorPos(x1,y1);
	}
}
int main()
{
	printinit();
	sl();
	system("cls");
	system("color F0");
	cout<<"等屏幕闪一会......";
	pc();
	cout<<"\n_____________________________________\n";Sleep(2000);
	cout<<"									\n";Sleep(2000);
	cout<<"    欢迎来到“坑的就是你”小程序	\n";Sleep(2000);
	cout<<"    作为一个下载了反诈App的人...	\n";Sleep(2000);
	cout<<"    请慎重进入。					\n";Sleep(2000);
	cout<<"______________________________________\n"; 
	cout<<"\n1.现在进入\n2.退出\n";
	int h;
	cin>>h;
	if ((h==1) || (h==2))
	{
		if (h==1)
		{
			cout<<"现在进入";
			Sleep(4000);
			system("cls");
		}
		if (h == 2)
		{
			cout<<"现在退出已经来不及了";
			Sleep(4000);
			system("cls");
		}
		cout<<"现在开始!!!";
		cout<>a;
		cout<<"你终于关完了,继续。"<>op;
			if (op==1)
			{
				cout<<"\n\n\n猜数字\n";
				srand((int)time(NULL));
				int n=rand()%1000;
				int op_1=0;
				int temp_1=0;
				cout<<"from 0 to 1000.";
				while(true)
				{
					cin>>op_1;
					if (op_1>n) 
					{
						cout<<"大了!"; 
						temp_1++; 
						continue;
					}
					if (op_1 blen) ? alen : blen;
				for (i = 0; i <= alen; i++)
				t = a1[i]+b1[i], a1[i] = t%10, a1[i+1] += t/10;
				while (!a1[i] && i) i--;
				for(; i >= 0; i--) printf("%d", a1[i]);
				Sleep(5000);
				system("cls");
				cout<<"_____________________________\n";
				cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
				cout<<"-----------------------------|\n";
			}
			if (op==3)
			{
				cout<<"\n\n\n高精度减法 依次输入被减数和减数(被减数>=减数) 算出结果后可继续选择数字\n";
				char a[202]={0}, b[202]={0};
				scanf("%s%s", a, b);
				int alen = strlen(a), blen = strlen(b), t = 0, i;
				int a1[202]={0}, b1[202]={0};
				for (i = 0; i < alen; i++)	a1[i] = a[alen-1-i]-'0';
				for (i = 0; i < blen; i++)	b1[i] = b[blen-1-i]-'0';
				alen = (alen > blen) ? alen : blen;
				for (i = 0; i <= alen; i++)
				t = a1[i]-b1[i], t<0?(t+=10,a1[i+1]--):t, a1[i] = t;
				while (!a1[i] && i) i--;
				for(; i >= 0; i--) printf("%d", a1[i]);
				Sleep(5000);
				system("cls");
				cout<<"_____________________________\n";
				cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
				cout<<"-----------------------------|\n";
				//减法
			}
			if (op==4)
			{
				cout<<"\n迷宫\n";
				cout<<"简简单单,x开门(|是门),wasd移动\n";
				char a[1000][1000]={
					"######@############$#",
					"#*#  #    #   | ### #",
					"#  # # ###### # ##  #",
					"## # # #      # #  #",
					"##   #  | #####  | ##",
					"#  #  ^############",
					"#######"
				};
				for(int i=0;i<=10;i++)
					puts(a[i]);
				char ch;
				int x=1,y=1;
				while(1)
				{
					ch=_getch();
					if(ch=='a'){
						if(a[x][y-1]!='#' && a[x][y-1]!='|'){
							a[x][y]=' ';
							y--;
							a[x][y]='*';
						}
					}
					if(ch=='s'){
						if(a[x+1][y]!='#' && a[x+1][y]!='|'){
							a[x][y]=' ';
							x++;
							a[x][y]='*';
						}
					}
					if(ch=='d'){
						if(a[x][y+1]!='#' && a[x][y+1]!='|'){
							a[x][y]=' ';
							y++;
							a[x][y]='*';
						}
					}
					if(ch=='x'){
						if(a[x][y+1]=='|'){
							a[x][y]=' ';
							y++;
							a[x][y]='*';
						}
					}
					if(ch=='w'){
						if(a[x-1][y]!='#' && a[x-1][y]!='@'  && a[x-1][y]!='|'){
							a[x][y]=' ';
							x--;
							a[x][y]='*';
						}
						if(a[x-1][y] == '$')
						{
							cout<<"you win!!!";
							Sleep(5000);
							system("cls");
							cout<<"_____________________________\n";
							cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
							cout<<"-----------------------------|\n";							
							break;
						}
					}
					system("cls");
					for(int i=0;i<=10;i++)
						puts(a[i]);
				}
			}
		} 
		return 0;
	}
	

欢迎点赞关注!!!

你可能感兴趣的:(c++,开发语言,后端)