为您推荐:
精华内容
最热下载
问答
  • 5星
    40KB weixin_51194902 2021-01-08 12:19:19
  • 5星
    56KB qq_40905804 2021-01-27 19:09:08
  • 5星
    1.46MB weixin_44573410 2021-03-15 21:57:51
  • 5星
    1.25MB weixin_44573410 2021-03-13 20:36:25
  • 5星
    137KB weixin_44573410 2021-03-02 23:27:18
  • 5星
    4.4MB I520ZYS 2021-02-19 09:53:22
  • 5星
    435KB weixin_44573410 2021-03-13 20:29:44
  • 5星
    712KB weixin_44573410 2021-03-01 13:55:37
  • 5星
    108KB qq_20232875 2021-01-11 19:16:19
  • 5星
    265KB m0_52957036 2020-06-20 21:22:04
  • C语言小游戏0、前言1、普普通通的五子棋2、好难操作的贪吃蛇3、简单到炸的自制迷宫4、不忍直视的双人飞机对战 0、前言 1、我使用的是编译软件是vc6.0 2、如果代码无法运行,你可以尝试吧文件xxx.c改为xxx.cpp 3、四...

    0、前言

    1、我使用的是编译软件是vc6.0
    2、如果代码无法运行,你可以尝试吧文件xxx.c改为xxx.cpp
    3、四个小游戏我都运行过,确保是可以运行的。虽然可玩性、操作性。。。

    1、普普通通的五子棋

    这是四个游戏中,个人感觉最好的一个了。

    #include <stdio.h>
    #include <windows.h>
    #include <time.h>
    #include <conio.h>
    #include <stdlib.h>
    #define N 65
    
    int status[N][N]={{0},{0}};//记录棋盘情况,0无,1红棋/玩家,2为白棋/电脑 
    int flag=0;//判断输赢 
    int direct[2];//方向
    int Value1[N][N]={{0},{0}};//计算权值 
    int Value2[N][N]={{0},{0}};//计算权值
    int regrex,regrey,regrex1,regrey1; 
    int count=0;//计算棋子数量 
    
    void chess_board();//打印棋盘 
    void red_movexy();//红子棋移动光标
    void white_movexy();//白棋移动光标 
    void red_chess(int x,int y);//红棋
    void white_chess(int x,int y);//白棋
    void man_man();
    void man_machine();//人机对战
    int judge_chess(int x,int y);//判断这个位置是否下过 
    int judge_winner(int x,int y,int temp);//判断输赢 
    void machine_attack();//电脑进攻权值 
    void machine_defend();//电脑防守权值 
    void find_position();//寻找最佳权值
    void Regret();//悔棋函数 
    
    void BackGround(unsigned int ForeColor, unsigned int BackGroundColor)  //颜色 
    {
    	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);  //获取控制台的句柄
    	SetConsoleTextAttribute(handle, ForeColor + BackGroundColor * 0x10);//改变当前光标的背景和字体颜色
    }
    
    void gotoxy(int x, int y)    //光标函数 
    {
    	HANDLE handle;
    	COORD coord;   //获取坐标轴结构体
    	coord.X = x;
    	coord.Y = y;
    	handle = GetStdHandle(STD_OUTPUT_HANDLE);  //获取控制台句柄,值为-11
    	SetConsoleCursorPosition(handle, coord);   //移动光标到x,y处
    }
    
    void chess_board()//打印棋盘 
    {
    	int i,j;
    	for(i=0;i<=30;i++)
    	    for(j=0;j<=60;j+=4)
    	    {
    	    	gotoxy(j,i);
    	    	printf("|");
    		}
    	for(i=0;i<=30;i+=2)
    	    for(j=1;j<=57;j+=4)
    	    {
    	    	gotoxy(j,i);
    	    	printf("---");
    		}
    }
    
    void chess_menu()//打印棋盘旁的菜单 
    {
    	int i,j;
    	for(i=1;i<=29;i++)
    	{
    		gotoxy(67,i);
    		printf("||");
    	}
    	for(i=1;i<=29;i++)
    	{
    		gotoxy(89,i);
    		printf("||");
    	}
    	gotoxy(69,1);
    	printf("--------------------");
    	gotoxy(69,29);
    	printf("--------------------");
    	gotoxy(75,3);
    	printf("模   式");
    	gotoxy(75,20);
    	printf("提   示");
    }
    
    void red_movexy()//红棋移动光标 
    {
    	loop2:gotoxy(direct[0],direct[1]);
    	char key='y';
    	int temp;
    	while(key!=' ')
    	{
    	    key=getch();
    		switch(key)
    		{
    			case 'W':
        		case 'w':
    	    		direct[1]-=2;
    	    		if(direct[1]<=1)
    	    		    direct[1]=1;
        			break;
        		case 's':
        		case 'S':
        			direct[1]+=2;
    	    		if(direct[1]>=29)
    	    		    direct[1]=29;
        			break;
        		case 'a':
        		case 'A':
    	    		direct[0]-=4;
    	    		if(direct[0]<=2)
    	    		    direct[0]=2;
    	    		break;
        		case 'd':
        		case 'D':
    	    		direct[0]+=4;
    	    		if(direct[0]>=58)
    	    		    direct[0]=58;
        			break;
        		case 'q':
        		case 'Q':
        		{ 
    				int message=MessageBox(NULL,"是否确定悔棋?","友情提示",MB_OKCANCEL);
    		        if(IDCANCEL==message)
    					break;
    			    if(IDOK==message)
    			    {
    			    	Regret();
        				break;
        			}
        		}
        	}
        	gotoxy(direct[0],direct[1]);
        }
            temp=judge_chess(direct[1],direct[0]);
    	    if(temp==1)
    	    {
    	    	gotoxy(70,22);
    	    		BackGround(4, 0);
    				printf("这里已经被人下过了");
    			goto loop2;
    		}
    }
    
    void white_movexy()//白棋移动光标 
    {
    	loop1:gotoxy(direct[0],direct[1]);
    	char key='y';
    	int temp;
    	while(key!='0')
    	{
    	    key=getch();
    		switch(key)
    		{
        		case 72:
    	    		direct[1]-=2;
    	    		if(direct[1]<=1)
    	    		    direct[1]=1;
        			break;
        		case 80:
        			direct[1]+=2;
    	    		if(direct[1]>=29)
    	    		    direct[1]=29;
        			break;
        		case 75:
    	    		direct[0]-=4;
    	    		if(direct[0]<=2)
    	    		    direct[0]=2;
    	    		break;
        		case 77:
    	    		direct[0]+=4;
    	    		if(direct[0]>=58)
    	    		    direct[0]=58;
        			break;
        		case 'B':
        		case 'b':
        		{ 
    				int message=MessageBox(NULL,"是否确定悔棋?","友情提示",MB_OKCANCEL);
    		        if(IDCANCEL==message)
    					break;
    			    if(IDOK==message)
    			    {
    			    	Regret();
        				break;
        			}
        		}
        	}
        	gotoxy(direct[0],direct[1]);
        }
            temp=judge_chess(direct[1],direct[0]);
    	    if(temp==1)
    	    {
    	    	gotoxy(70,22);
    	    		BackGround(4, 0);
    				printf("这里已经被人下过了");
    			goto loop1;
    		}
    }
    
    void red_chess(int x,int y)//打印红棋 
    {
    	BackGround(4,0);
    	regrex=x;//记录上一落子的位置 ,方便悔棋 
    	regrey=y;
    	count++;
    	printf("●");
    	status[x][y]=1;
    }
    
    void white_chess(int x,int y)//打印白棋
    {
    	BackGround(7,0);
    	regrex1=x;
    	regrey1=y;
    	printf("●");
    	count++;
    	status[x][y]=2;
    }
    
    void machine_chess(int x,int y)//电脑落子
    {
    	BackGround(7,0);
    	status[x][y]=2;
    	regrex1=x;
    	regrey1=y;
    	count++;
    	gotoxy(y,x);
    	printf("●");
    }
    
    int judge_chess(int x,int y)//判断这个地方是否有棋子
    {
    	if(status[x][y]==0)
    		return 0;
    	else
    		return 1;
    } 
    
    int judge_winner(int x,int y,int temp)//判断输赢 
    { 
    	int i,j,n1,n2;
    	n1=n2=0;
    	for(i=x,j=y+4;j<=58;j+=4)//右
    	{
    		if(status[i][j]==temp)
    		    n1++;
    		else
    		    break;
    	}
    	for(i=x,j=y;j>=2;j-=4)//左
    	{
    		if(status[i][j]==temp)
    		    n2++;
    		else
    		    break;
    	}
    	if(n1+n2>=5)
    	    return temp;
    	n1=n2=0;
    	for(i=x,j=y;i>=1;i-=2)//上 
    	{
    		if(status[i][j]==temp)
    		    n1++;
    		else
    		    break;
    	}
    	for(i=x+2,j=y;i<=30;i+=2)//下 
    	{
    		if(status[i][j]==temp)
    		    n2++;
    		else
    		    break;
    	}
    	if(n1+n2>=5)
    	    return temp;
    	n1=n2=0;
    	for(i=x-2,j=y+4;i>=1&&j<=58;i-=2,j+=4)//右上 
    	{
    		if(status[i][j]==temp)
    		    n1++; 
    		else
    		    break;
    	}
    	for(i=x,j=y;i<=30&&j>=2;i+=2,j-=4)//左下
    	{
    		if(status[i][j]==temp)
    		    n2++; 
    		else
    		    break;
    	}
    	if(n1+n2>=5)
    	    return temp;
    	n1=n2=0;
    	for(i=x,j=y;i>=0&&j>=0;i-=2,j-=4)//左上 
    	{
    		if(status[i][j]==temp)
    		    n1++; 
    		else
    		    break;
    	}
    	for(i=x+2,j=y+4;i<=30&&j<=58;i+=2,j+=4)//右下
    	{
    		if(status[i][j]==temp)
    		    n2++; 
    		else
    		    break;
    	}
    	if(n1+n2>=5)
    	    return temp;
    	return 0;
    }
    
    void machine_attack()//电脑进攻权值 
    {
    	int i1,j1;
    	int k1,k2,k;
    	for(int i=1;i<=30;i+=2)
    	{
    		for(int j=2;j<=58;j+=4)
    		{
    			if(status[i][j])
    				Value1[i][j]=0;
    			if(status[i][j]==0)
    			{
    				k1=k2=0;
    				for(i1=i,j1=j-4;j1>=2;j1-=4)//往左数寻找电脑棋子数
    				{
    					if(status[i1][j1]==2)
    						k1++;
    					else
    						break;
    				}
    				for(i1=i,j1=j+4;j1<=58;j1+=4)//往右数寻找电脑棋子数
    				{
    					if(status[i1][j1]==2)
    						k2++;
    					else
    						break;
    				}
    				k=k1>k2? k1:k2;
    				k1=k2=0;
    				for(i1=i-2,j1=j;i1>=1;i1-=2)//往上数寻找电脑棋子数
    				{
    					if(status[i1][j1]==2)
    						k1++;
    					else
    						break;
    				}
    				for(i1=i+2,j1=j;i1<=30;i1+=2)//往下数寻找电脑棋子数
    				{
    					if(status[i1][j1]==2)
    						k2++;
    					else
    						break;
    				}
    				k1=k1>k2? k1:k2;
    				k=k>k1? k:k1;
    				k1=k2=0;
    				for(i1=i-2,j1=j-4;i1>=0&&j1>=0;i1-=2,j1-=4)//往左上数寻找电脑棋子数
    				{
    					if(status[i1][j1]==2)
    						k1++;
    					else
    						break;
    				}
    				for(i1=i+2,j1=j+4;i1<=30&&j1<=58;i1+=2,j1+=4)//往右下数寻找电脑棋子数
    				{
    					if(status[i1][j1]==2 )
    						k2++;
    					else
    						break;
    				}
    				k1=k1>k2? k1:k2;
    				k=k>k1?k:k1;
    				k1=k2=0;
    				for(i1=i+2,j1=j-4;i1<=30&&j1>=2;i1+=2,j1-=4)//往左下数寻找电脑棋子数
    				{
    					if(status[i1][j1]==2)
    						k1++;
    					else
    						break;
    				}
    				for(i1=i-2,j1=j+4;i1>=1&&j1<=58;i1-=2,j1+=4)//往右上数寻找电脑棋子数
    				{
    					if(status[i1][j1]==2)
    						k2++;
    					else
    						break;
    				}
    				k1=k1>k2? k1:k2;
    				k=k>k1?k:k1;
    				switch(k) 
    				{ 
    					case 3:
    						Value1[i][j]=15;break;                       
    					case 4:
    						Value1[i][j]=25;break; 
    					default:
    						Value1[i][j]=3+2*k;break;
    				}
    			}
    		}
    	}
    }
    
    void machine_defend()//防守权值
    {
    	int i1, j1;
    	int k1,k2,k;
    	for(int i=1;i<=30;i+=2)
    	{
    		for(int j=2;j<=58;j+=4)
    		{
    			if(status[i][j])
    				Value2[i][j]=0;
    			if(status[i][j]==0)
    			{
    				k1=k2=0;
    				for(i1=i,j1=j-4;j1>=2;j1-=4)//往左数寻找玩家棋子数
    				{
    					if(status[i1][j1]==1)
    						k1++;
    					else
    						break;
    				}
    				for(i1=i,j1=j+4;j1<=58;j1+=4)//往右数寻找玩家棋子数
    				{
    					if(status[i1][j1]==1)
    						k2++; 
    					else
    						break;
    				}
    				k=k1>k2? k1:k2;
    				k1=k2=0;
    				for(i1=i-2,j1=j;i1>=1;i1-=2)//往上数寻找玩家棋子数
    				{
    					if(status[i1][j1]==1)
    						k1++;
    					else
    						break;
    				}
    				for(i1=i+2,j1=j;i1<=30;i1+=2)//往下数寻找玩家棋子数
    				{
    					if(status[i1][j1]==1)
    						k2++;
    					else
    						break;
    				}
    				k1=k1>k2? k1:k2;
    				k=k>k1?k:k1;
    				k1=k2=0;
    				for(i1=i-2,j1=j-4;i1>=1&&j1>=2;i1-=2,j1-=4)//往左上数寻找玩家棋子数
    				{
    					if(status[i1][j1]==1)
    						k1++;
    					else
    						break;
    				}
    				for(i1=i+2,j1=j+4;i1<=30&&j1<=58;i1+=2,j1+=4)//往右下数寻找玩家棋子数
    				{
    					if(status[i1][j1]==1)
    						k2++;
    					else
    						break;
    				}
    				k1=k1>k2? k1:k2;
    				k=k>k1?k:k1;
    				k1=k2=0;
    				for(i1=i+2,j1=j-4;i1<=30&&j1>=2;i1+=2,j1-=4)//往左下数寻找玩家棋子数
    				{
    					if(status[i1][j1]==1)
    						k1++;
    					else
    						break;
    				}
    				for(i1=i-2,j1=j+4;i1>=1&&j1<=58;i1-=2,j1+=4)//往右上数寻找玩家棋子数
    				{
    					if(status[i1][j1]==1)
    						k2++;
    					else
    						break;
    				}
    				k1=k1>k2? k1:k2;
    				k=k>k1?k:k1;
    			    switch(k)
    				{
    					case 3:
    						Value2[i][j]=10;break;                 
    					case 4:                                       
    						Value2[i][j]=20;break;
    					default:
    						Value2[i][j]=2+k*2;
    				}
    			}
    		}
    	}
    }
    
    void find_position()//找到最有价值的位置
    {
    	int k1=0, k2=0;
    	int i, j, max=0;
    	for( i=1;i<=30;i+=2)
    		for( j=2;j<=58;j+=4)
    		{
    			if(max<=Value1[i][j])
    			{
    				max=Value1[i][j];
    				k1=i;
    				k2=j;
    			}
    		}
    	for( i=1;i<=30;i+=2)
    		for( j=2;j<=58;j+=4)
    		{
    			if(max<=Value2[i][j])
    			{
    				max=Value2[i][j];
    				k1=i;
    				k2=j;
    			}
    		}
    	direct[1]=k1;  //将找到的位置传给光标
    	direct[0]=k2;
    }
    
    void man_man()//人人对战模式
    {
    	loop5:system("cls");
    	char key;
    	int control;
    	gotoxy(2, 3);
    	printf("1.红 子 先 手");
    	
    	gotoxy(2, 5);
    	printf("2.白 子 先 手");
    	
    	gotoxy(2, 7);
    	printf("(输入相应序号选择)");
    	key=getch();
    	system("cls");
    	if(key=='1')
    		control=1;
    	else if(key=='2')
    		control=-1;
    	else
    		goto loop5;
    	gotoxy(70,5);
    	printf("   人 人 对 战    "); 
    	direct[1]=15;
    	direct[0]=30;
    	chess_board();
    	chess_menu();
    	while(flag==0)
    	{
    		if(control==1)
    		{
    			gotoxy(70,22);
    			BackGround(6,0);
    			printf("   红 子 执 手    "); 
    			red_movexy();
    			red_chess(direct[1],direct[0]);
    			flag=judge_winner(direct[1],direct[0],1);
    		}
    		else
    		{
    			gotoxy(70,22);
    			BackGround(6,0);
    			printf("   白 子 执 手    "); 
    			white_movexy();
    			white_chess(direct[1],direct[0]);
    			flag=judge_winner(direct[1],direct[0],2);
    		}
    		control=-control;
    	}
    	if(flag==1)
    	{
    		BackGround(7,0);
    		MessageBox(NULL,"游戏结束,红子胜利","五子棋游戏",MB_OK);
    	}
    	if(flag==2)
    	{
    		MessageBox(NULL,"游戏结束,白子胜利","五子棋游戏",MB_OK);
    	}
    	if(count>=225)
    	{
    		MessageBox(NULL,"游戏结束,平局","五子棋游戏",MB_OK);
    	}
    }
    
    void man_machine()//人机对战模式 
    {
    	loop6:system("cls");
    	char key;
    	int control;
    	gotoxy(2, 3);
    	printf("1.玩 家 先 手(玩家为红子)");
    	
    	gotoxy(2, 5);
    	printf("2.电 脑 先 手(电脑为白子)");
    	
    	gotoxy(2, 7);
    	printf("(输入相应序号选择)");
    	key=getch();
    	system("cls");
    	if(key=='1')
    		control=1;
    	else if(key=='2')
    	{
    		control=1;
    		machine_chess(13,26);
    	}
    	else 
    		goto loop6;
    	gotoxy(70,5);
    	printf("   人 机 对 战    ");
    	direct[1]=15;
    	direct[0]=30;
    	chess_board();
    	chess_menu();
    	while(flag==0)
    	{
    		if(control==1)
    		{
    			gotoxy(70,22);
    			BackGround(6,0);
    			printf("   玩 家 执 手    "); 
    			red_movexy();
    			red_chess(direct[1],direct[0]);
    			flag=judge_winner(direct[1],direct[0],1);
    		}
    		else
    		{
    			gotoxy(70,22);
    			BackGround(6,0);
    			printf("   电 脑 执 手    "); 
    			machine_defend();
    			machine_attack();
    			find_position();
    			machine_chess(direct[1],direct[0]);
    			flag=judge_winner(direct[1],direct[0],2);
    		}
    		control=-control;
    	}
    	gotoxy(8,18);
    	if(flag==1)
    	{
    		BackGround(7,0);
    		MessageBox(NULL,"太厉害了,您竟然战胜了电脑!","五子棋游戏",MB_OK);
    	}
    	if(flag==2)
    	{
    		MessageBox(NULL,"游戏结束,您输给了电脑","五子棋游戏",MB_OK);
    	}
    	if(count>=225)
    	{
    		MessageBox(NULL,"平局","五子棋游戏",MB_OK);
    	}
    }
    
    void Regret()//悔棋函数 
    {
    	gotoxy(regrey,regrex);
    	BackGround(0,0);
     	printf(" ");
    	status[regrex][regrey]=0;
    	gotoxy(regrey1,regrex1);
    	BackGround(0,0);
     	printf(" ");
    	status[regrex1][regrey1]=0;
    	count-=2;
    } 
    
    void welcome()//游戏菜单 
    {
    	int k;
    	char choose;
    	system("cls");
    	for(k=2;k<=16;k+=2)//游戏菜单 
    	{
    		gotoxy(5,k);	
        	printf("|-----------------|");
    	}
    	gotoxy(5, 3);
    	printf("|  五 子 棋 游 戏 |");
    	
    	gotoxy(5, 5);
    	printf("|     菜    单    |");
    
    	gotoxy(5, 7);
    	printf("|  1.人 人 对 战  |");
    	
    	gotoxy(5, 9);
    	printf("|  2.人 机 对 战  |");
    	
    	gotoxy(5, 11);	
    	printf("|  3.游 戏 帮 助  |");
    	
    	gotoxy(5, 13);	
    	printf("|  4.更 新 日 志  |");
    	
    	gotoxy(5, 15);
    	printf("|  5.退 出 游 戏  |");
    	
    	gotoxy(5, 18);
    	printf("温馨提示:输入菜单对应序号进行操作");
    	
    	gotoxy(5, 20);
    	printf("祝您游戏愉快!");
    	
    	gotoxy(13, 20);
    }
    
    char Gametips()//游戏帮助 
    {
    	char choose;
    	int key;
    	
    	system("cls");
    	
    	gotoxy(2, 3);
    	printf("游戏操作:"); 
    		
    	gotoxy(4, 5);
    	printf("① 红色棋子WASD移动光标选择下棋位置,按空格键确认,按Q悔棋"); 
    		
    	gotoxy(4, 7);
    	printf("② 白色棋子↑↓←→移动光标选择下棋位置,按0确认,按B悔棋");
    		
    	gotoxy(2, 19);
    	printf("(按任意键返回)");
    	
    	return getch();
    }
    
    char Updatediary()//更新日志 
    {
    	system("cls");
    	
    	gotoxy(2, 3);
    	printf("(暂时没有)"); 
    	
    	gotoxy(2, 5);
    	printf("(按任意键返回)");
    	
    	return getch();
    }
    
    int main()
    {
    	system("title 五子棋");
    	system("mode con cols=92 lines=33");
    	char choose,temp;
    thetop:	loop:welcome();
    	choose=getch();
    	switch(choose)
    	{
    		case '1':
    			man_man();
    			goto thetop;
    			break;
    		case '2':
    			man_machine();
    			goto thetop;
    			break;
    		case '3':
    			temp=Gametips();
    				goto thetop;
    			break;
    		case '4':
    			temp=Updatediary();
    				goto thetop;
    			break;
    		case '5':
    			int message=MessageBox(NULL,"是否退出?","友情提示",MB_OKCANCEL);
    			if(IDCANCEL==message)
    				goto thetop;
    			if(IDOK==message)
    			{
    				break;
    			}
    	}
    }
    
    

    2、好难操作的贪吃蛇

    贪吃蛇的基本框架还是有的。

    文件一:stdafx.h

    #if !defined(AFX_STDAFX_H__20B660F3_64B9_4993_8071_269F806FAF71__INCLUDED_)
    #define AFX_STDAFX_H__20B660F3_64B9_4993_8071_269F806FAF71__INCLUDED_
    
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    
    

    代码二:主程序

    #include "stdafx.h"
    /*******头  文  件*******/
    #include<stdio.h>			//标准输入输出函数库
    #include<time.h>			//用于获得随机数
    #include<windows.h>			//控制dos界面
    #include<stdlib.h>			//即standard library标志库头文件,里面定义了一些宏和通用工具函数
    #include<conio.h>			//接收键盘输入输出
    
    /*******宏  定  义*******/
    #define U 1
    #define D 2
    #define L 3 
    #define R 4    //蛇的状态,U:上 ;D:下;L:左 R:右
    
    /*******定  义  全  局  变  量 *******/
    typedef struct snake 		//蛇身的一个节点
    {
        int x;					//节点x坐标
        int y;					//节点y坐标
        struct snake *next;		//蛇身体下一节点
    }snake;
    int score=0;                //总得分
    int add=10;			        //每次吃食物得分
    int HighScore = 0;			//最高分
    int status;					//蛇前进状态
    int sleeptime=200;			//每次运行的时间间隔
    snake *head;				//蛇头指针
    snake *food;				//食物指针
    snake *q;					//遍历蛇的时候用到的指针
    int endgamestatus=0;		//游戏结束的情况,1:撞到墙;2:咬到自己;3:主动退出游戏
    HANDLE hOut;				//控制台句柄
    
    /*******函  数  声  明 *******/
    void gotoxy(int x,int y);   //设置光标位置
    int color(int c);           //更改文字颜色
    void printsnake();          //字符画
    void welcometogame();       //开始界面
    void createMap();           //绘制地图
    void scoreandtips();		//游戏界面右侧的得分和小提示
    void initsnake();           //初始化蛇身,画蛇身
    void createfood();          //创建并随机出现食物
    int biteself();             //判断是否咬到了自己
    void cantcrosswall();       //设置蛇撞墙的情况
    void speedup();				//加速
    void speeddown();			//减速
    void snakemove();           //控制蛇前进方向
    void keyboardControl();     //控制键盘按键
    void Lostdraw();            //游戏结束界面
    void endgame();             //游戏结束
    void choose();				//游戏失败之后的选择
    void File_out();            //在文件中读取最高分
    void File_in();            	//储存最高分进文件
    void explation();           //游戏说明
    
    /*
    	设置光标位置
    */
    void gotoxy(int x,int y)
    {
        COORD c;
        c.X=x;
        c.Y=y;
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
    }
    
    /*
    	文字颜色函数
    */
    int color(int c)
    {
    	//SetConsoleTextAttribute是API设置控制台窗口字体颜色和背景色的函数
    	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);        //更改文字颜色
    	return 0;
    }
    
    /*
    	字符拼成英文图案
    */
    void printsnake()
    {
    	color(2);
    	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");
    	 
    
    
    
    	
    }
    
    /*
    	开始界面
    */
    void welcometogame()
    {
    	int n;
    	int i,j = 1;
    	gotoxy(43,18);
    	color(11);
    	printf("贪 吃 蛇 游 戏");
    	color(14);          			//黄色边框
    	for (i = 20; i <= 26; i++)   	//输出上下边框┅
    	{
    		for (j = 27; j <= 74; j++)  //输出左右边框┇
    		{
    			gotoxy(j, i);
    			if (i == 20 || i == 26)
    			{
    				printf("-");
                }
    			else if (j == 27 || j == 74)
                {
    				printf("|");
                }
    		}
    	}
    	color(10);
    	gotoxy(35, 22);
    	printf("1.开始游戏");
    	gotoxy(55, 22);
    	printf("2.游戏说明");
    	gotoxy(35, 24);
    	printf("3.退出游戏");
    	gotoxy(29,27);
    	color(3);
    	printf("请选择[1 2 3]:[ ]\b\b");        //\b为退格,使得光标处于[]中间
    	color(14);
        scanf("%d", &n);    		//输入选项
        switch (n)
        {
        	case 1:					//选择开始游戏
        		system("cls");
    			createMap();        //创建地图
    			initsnake();        //初始化蛇身
    			createfood();		//初始化食物
    			keyboardControl();	//控制键盘按钮
            	break;
        	case 2:					//选择游戏说明
            	explation();
            	break;
        	case 3:					//选择退出游戏
            	exit(0);     		//退出游戏
            	break;
    		default:				//输入非1~3之间的选项
    			color(12);
    			gotoxy(40,28);
    			printf("请输入1~3之间的数!");
    			getch();			//输入任意键
    			system("cls");		//清屏
    			printsnake();
    			welcometogame();
        }
    }
    
    /*
    	创建地图
    */
    void createMap()
    {
        int i,j;
        for(i=0;i<58;i+=2)		//打印上下边框
        {
            gotoxy(i,0);
    		color(6);			//深绿色的边框
            printf("□");
            gotoxy(i,26);
            printf("□");
        }
        for(i=1;i<26;i++)		//打印左右边框
        {
            gotoxy(0,i);
            printf("□");                        
            gotoxy(56,i);
            printf("□");        
        }
    	for(i = 2;i<56;i+=2)	//打印中间网格
    	{
    		for(j = 1;j<26;j++)
    		{
    			gotoxy(i,j);
    			color(3);
    			printf("■\n\n");
    		}
    	}
    }
    
    /*
    	游戏界面右侧的得分和小提示
    */
    void scoreandtips()
    {
    	File_out();				//调用File_out(),读取文件save.txt中的内容
    	gotoxy(64,4);			//确定打印输出的位置
    	color(11);				//设置颜色
    	printf("☆最高记录☆:%d",HighScore);	//打印最高分
    	gotoxy(64,8);
    	color(14);
    	printf("当前得分:%d  ",score);
    	color(15);
    	gotoxy(73,11);
    	printf("小 提 示");
    	gotoxy(60,13);
    	color(6);
    	printf("╬ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ ╬");
    	gotoxy(60,25);
    	printf("╬ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ ╬");
    	color(3);
    	gotoxy(64,14);
    	printf("每个食物得分:%d分",add);
    	gotoxy(64,16);
    	printf("不能撞墙,不能咬到自己");
    	gotoxy(64,18);
    	printf("用↑ ↓ ← →分别控制蛇的移动");
    	gotoxy(64,20);
    	printf("F1键加速,F2键减速");
    	gotoxy(64,22);
    	printf("空格键暂停游戏");
    	gotoxy(64,24);
        printf("Esc键退出游戏");
    }
    
    /*
    	初始化蛇身,画蛇身
    */
    void initsnake()
    {
        snake *tail;
        int i;
        tail=(snake*)malloc(sizeof(snake));	//从蛇尾开始,头插法,以x,y设定开始的位置
        tail->x=24;				//蛇的初始位置(24,5)
        tail->y=5;
        tail->next=NULL;
        for(i=1;i<=4;i++)       //设置蛇身,长度为5
        {
            head=(snake*)malloc(sizeof(snake)); //初始化蛇头
            head->next=tail;    //蛇头的下一位为蛇尾
            head->x=24+2*i;     //设置蛇头位置
            head->y=5;
            tail=head;          //蛇头变成蛇尾,然后重复循环
        }
        while(tail!=NULL)		//从头到尾,输出蛇身
        {
            gotoxy(tail->x,tail->y);
    		color(14);
            printf("◆");       //输出蛇身,蛇身使用◆组成
            tail=tail->next;    //蛇头输出完毕,输出蛇头的下一位,一直输出到蛇尾
        }
    }
    
    /*
    	随机出现食物
    */
    void createfood()
    {
        snake *food_1;
        srand((unsigned)time(NULL));        	//初始化随机数
        food_1=(snake*)malloc(sizeof(snake));   //初始化food_1
        while((food_1->x%2)!=0)    				//保证其为偶数,使得食物能与蛇头对齐,然后食物会出现在网格线上
        {
            food_1->x=rand()%52+2;              //食物随机出现,食物的x坐标在2~53
        }
        food_1->y=rand()%24+1;					//食物的y坐标在1~24
        q=head;
        while(q->next==NULL)
        {
            if(q->x==food_1->x && q->y==food_1->y) //判断蛇身是否与食物重合
            {
                free(food_1);               //如果蛇身和食物重合,那么释放食物指针
                createfood();               //重新创建食物
            }
            q=q->next;
        }
        gotoxy(food_1->x,food_1->y);
        food=food_1;
    	color(12);
        printf("●");           //输出食物
    }
    
    /*
    	判断是否咬到了自己
    */
    int biteself()
    {
        snake *self;            //定义self为蛇身上的一个节点
        self=head->next;        //self是蛇头之外的蛇身上的节点
        while(self!=NULL)
        {
            if(self->x==head->x && self->y==head->y)    //如果self和蛇身上的节点重合
            {
                return 1;       //返回1
            }
            self=self->next;
        }
        return 0;
    }
    
    /*
    	设置蛇撞墙的情况
    */
    void cantcrosswall()
    {  
        if(head->x==0 || head->x==56 ||head->y==0 || head->y==26) //如果蛇头碰到了墙壁
        {
            endgamestatus=1;        //返回第一种情况
            endgame();              //出现游戏结束界面
        }
    }
    
    /*
    	加速,蛇吃到食物会自动提速,并且按F1会加速
    */
    void speedup()
    {
    	if(sleeptime>=50)
    	{
    		sleeptime=sleeptime-10;
    		add=add+2;
    
        }
    }
    
    /*
    	减速,按F2会减速
    */
    void speeddown()
    {
    	if(sleeptime<350)               //如果时间间隔小于350
        {
            sleeptime=sleeptime+30;     //时间间隔加上30
            add=add-2;                  //每吃一次食物的得分减2
    
        }
    }
    
    /*
    	控制方向
    */
    void snakemove()	//蛇前进,上U,下D,左L,右R
    {
    	snake * nexthead;
        cantcrosswall();
        nexthead=(snake*)malloc(sizeof(snake));		//为下一步开辟空间
        if(status==U)
        {
            nexthead->x=head->x;        //向上前进时,x坐标不动,y坐标-1
            nexthead->y=head->y-1;
            nexthead->next=head;
            head=nexthead;
            q=head;						//指针q指向蛇头
            if(nexthead->x==food->x && nexthead->y==food->y)	//如果下一个有食物 下一个位置的坐标和食物的坐标相同
            {
                
                while(q!=NULL)
                {
                    gotoxy(q->x,q->y);
    				color(14);
                    printf("◆");       //原来食物的位置,从●换成◆
                    q=q->next;          //指针q指向的蛇身的下一位也执行循环里的操作
    				
                }
                score=score+add;        //吃了一个食物,在总分上加上食物的分
    			speedup();
                createfood();           //创建食物
            }
            else                        
            {
                while(q->next->next!=NULL)	//如果没遇到食物
                {
                    gotoxy(q->x,q->y);
                    color(14);
                    printf("◆");           //蛇正常往前走,输出当前位置的蛇身
                    q=q->next;              //继续输出整个蛇身
                }
                gotoxy(q->next->x,q->next->y);  //经过上面的循环,q指向蛇尾,蛇尾的下一位,就是蛇走过去的位置
    			color(3);
                printf("■");
                free(q->next);			//进行输出■之后,释放指向下一位的指针
                q->next=NULL;			//指针下一位指向空
            }
        }
        if(status==D)
        {
            nexthead->x=head->x;        //向下前进时,x坐标不动,y坐标+1
            nexthead->y=head->y+1;
            nexthead->next=head;
            head=nexthead;
            q=head;
            if(nexthead->x==food->x && nexthead->y==food->y)  //有食物
            {
                
                while(q!=NULL)
                {
                    gotoxy(q->x,q->y);
                    color(14);
                    printf("◆");
                    q=q->next;
                }
                score=score+add;
    			speedup();
                createfood();
            }
            else                               //没有食物
            {
                while(q->next->next!=NULL)
                {
                    gotoxy(q->x,q->y);
                    color(14);
                    printf("◆");
                    q=q->next;
                }
                gotoxy(q->next->x,q->next->y);
    			color(3);
                printf("■");
                free(q->next);
                q->next=NULL;
            }
        }
        if(status==L)
        {
            nexthead->x=head->x-2;        //向左前进时,x坐标向左移动-2,y坐标不动
            nexthead->y=head->y;
            nexthead->next=head;
            head=nexthead;
            q=head;
            if(nexthead->x==food->x && nexthead->y==food->y)//有食物
            {
                while(q!=NULL)
                {
                    gotoxy(q->x,q->y);
                    color(14);
                    printf("◆");
                    q=q->next;
                }
                score=score+add;
    			speedup();
                createfood();
            }
            else                                //没有食物
            {
                while(q->next->next!=NULL)
                {
                    gotoxy(q->x,q->y);
                    color(14);
                    printf("◆");
                    q=q->next;        
                }
                gotoxy(q->next->x,q->next->y);
    			color(3);
                printf("■");
                free(q->next);
                q->next=NULL;
            }
        }
        if(status==R)
        {
            nexthead->x=head->x+2;        //向右前进时,x坐标向右移动+2,y坐标不动
            nexthead->y=head->y;
            nexthead->next=head;
            head=nexthead;
            q=head;
            if(nexthead->x==food->x && nexthead->y==food->y)//有食物
            {
                while(q!=NULL)
                {
                    gotoxy(q->x,q->y);
                    color(14);
                    printf("◆");
                    q=q->next;
                }
                score=score+add;
    			speedup();
                createfood();
            }
            else                                         //没有食物
            {
                while(q->next->next!=NULL)
                {
                    gotoxy(q->x,q->y);
                    color(14);
                    printf("◆");
                    q=q->next;        
                }
                gotoxy(q->next->x,q->next->y);
    			color(3);
                printf("■");
                free(q->next);
                q->next=NULL;
            }
        }
        if(biteself()==1)       //判断是否会咬到自己
        {
            endgamestatus=2;
            endgame();
        }
    }
    
    /*
    	控制键盘按键
    */
    void keyboardControl()
    {
    	status=R;       //初始蛇向右移动
        while(1)
        {
    		scoreandtips();
            if(GetAsyncKeyState(VK_UP) && status!=D)            //GetAsyncKeyState函数用来判断函数调用时指定虚拟键的状态
            {
                status=U;           //如果蛇不是向下前进的时候,按上键,执行向上前进操作
            }
            else if(GetAsyncKeyState(VK_DOWN) && status!=U)     //如果蛇不是向上前进的时候,按下键,执行向下前进操作
            {
                status=D;
            }
            else if(GetAsyncKeyState(VK_LEFT)&& status!=R)      //如果蛇不是向右前进的时候,按左键,执行向左前进
            {
                status=L;
            }
            else if(GetAsyncKeyState(VK_RIGHT)&& status!=L)     //如果蛇不是向左前进的时候,按右键,执行向右前进
            {
                status=R;
            }
            if(GetAsyncKeyState(VK_SPACE))		//按暂停键,执行pause暂停函数
            {
                while(1)
    			{
    				Sleep(300); //sleep()函数,头文件#include <unistd.h>  令进程暂停,直到达到里面设定的参数的时间
    				if(GetAsyncKeyState(VK_SPACE))      //按空格键暂停
    				{
    					break;
    				}
    				
    			}       
            }
            else if(GetAsyncKeyState(VK_ESCAPE))
            {
                endgamestatus=3;    //按esc键,直接到结束界面
                break;
            }
            else if(GetAsyncKeyState(VK_F1))    //按F1键,加速
            {
                speedup();
            }
            else if(GetAsyncKeyState(VK_F2))    //按F2键,减速
            {
            	speeddown();
                
            }
            Sleep(sleeptime);
            snakemove();
        }
    }
    
    /*
    	储存最高分进文件
    */
    void File_in()
    {
    	FILE *fp;
    	fp = fopen("save.txt", "w+");       //以读写的方式建立一个名为save.txt的文件
    	fprintf(fp, "%d", score);           //把分数写进文件中
    	fclose(fp);                         //关闭文件
    }
    
    /*
    	在文件中读取最高分
    */
    void File_out()
    {
    	FILE *fp;
    	fp = fopen("save.txt", "a+");       //打开文件save.txt
    	fscanf(fp, "%d", &HighScore);       //把文件中的最高分读出来
    	fclose(fp);                         //关闭文件
    }
    
    /*
    	游戏说明
    */
    void explation()
    {
    	int i,j = 1;
        system("cls");
        color(15);
        gotoxy(44,3);
        printf("游戏说明");
        color(2);
        for (i = 6; i <= 22; i++)   //输出上下边框===
    	{
    		for (j = 20; j <= 76; j++)  //输出左右边框||
    		{
    			gotoxy(j, i);
    			if (i == 6 || i == 22) printf("=");
    			else if (j == 20 || j == 75) printf("||");
    		}
    	}
        color(3);
        gotoxy(30,8);
        printf("tip1: 不能撞墙,不能咬到自己");
        color(10);
        gotoxy(30,11);
        printf("tip2: 用↑.↓.←.→分别控制蛇的移动");
        color(14);
        gotoxy(30,14);
        printf("tip3: F1 为加速,F2 为减速");
        color(11);
        gotoxy(30,17);
        printf("tip4: 按空格键暂停游戏,再按空格键继续");
        color(4);
        gotoxy(30,20);
        printf("tip5: Esc :退出游戏");
        getch();                //按任意键返回主界面
        system("cls");
        printsnake();
        welcometogame();
    }
    
    /*
    	结束游戏
    */
    void endgame()
    {
        system("cls");
        if(endgamestatus==1)
        {
            
    		Lostdraw();
    		gotoxy(35,9);
        	color(7);
    		printf("对不起,您撞到墙了。游戏结束!");
        }
        else if(endgamestatus==2)
        {
            
            Lostdraw();
            gotoxy(35,9);
        	color(7);
            printf("对不起,您咬到自己了。游戏结束!");
        }
        else if(endgamestatus==3)
        {
    		Lostdraw();
    		gotoxy(40,9);
        	color(7);
            printf("您已经结束了游戏。");
        }
        gotoxy(43,12);
        color(14);
        printf("您的得分是 %d",score);
    
    	if(score >= HighScore)
    	{
    		color(10);
    		gotoxy(33,16);
    		printf("创纪录啦!最高分被你刷新啦,真棒!!!");
    		File_in();              //把最高分写进文件
    	}
    	else
    	{
    		color(10);
    		gotoxy(33,16);
    		printf("继续努力吧~ 你离最高分还差:%d",HighScore-score);
    	}
    	choose();
    }
    
    /*
    	边框下面的分支选项
    */
    void choose()
    {
    	int n;
    	gotoxy(30,23);
    	color(12);
    	printf("重玩一局 [1]");
    	gotoxy(55,23);
    	printf("溜了溜了 [2]");
    	gotoxy(45,25);
    	color(11);
    	printf("选择:");
    	scanf("%d", &n);
        switch (n)
        {
    	case 1:
    		system("cls");          //清屏
    		score=0;                //分数归零
    		sleeptime=200;			//设定初始速度
    		add = 10;				//使add设定为初值,吃一个食物得分10,然后累加
    		printsnake();           //返回欢迎界面
    		welcometogame();
    		break;
    	case 2:
    		exit(0);                //退出游戏
    		break;
    	default:
    		gotoxy(35,27);
    		color(12);
    		printf("※※您的输入有误,请重新输入※※");
    		system("pause >nul");
    		endgame();
    		choose();
    		break;
    	}
    
    }
    
    /*
    	失败界面
    */
    void Lostdraw()
    {
    	system("cls");
    	int i;
    	gotoxy(45,1);
    	color(6);
    	printf(" |-----|   ");		//匹诺曹的帽子
    	gotoxy(45,2);
    	color(6);
    	printf(" |     |   ");
    	gotoxy(43,3);
    	color(6);
    	printf("-------------");
    
    	gotoxy(44,4);
    	color(14);
    	printf("(");
    
    	gotoxy(47,4);
    	color(15);
    	printf(" > <");				//眼睛
    
    	gotoxy(54,4);
    	color(14);
    	printf(")");
    
    	gotoxy(17,5);
    	color(11);
    	printf("+------------------------");	//上边框
    
    	gotoxy(35,5);
    	color(14);
    	printf("oOOo");
    
    	gotoxy(39,5);
    	color(11);
    	printf("----------");					//上边框
    
    	gotoxy(48,5);
    	color(14);
    	printf("| |");				//鼻子
    	gotoxy(48,6);
    	color(14);
    	printf("|_|");
    
    	gotoxy(51,5);
    	color(11);
    	printf("----------");					//上边框
    
    	gotoxy(61,5);
    	color(14);
    	printf("oOOo");
    
    	gotoxy(65,5);
    	color(11);
    	printf("-----------------+");			//上边框
    	
    	for(i = 6;i<=19;i++)					//竖边框
    	{
    		gotoxy(17,i);
    		printf("|");
    		gotoxy(82,i);
    		printf("|");
    	}
    
    	gotoxy(17,20);
    	printf("+------------------------------------------");	//下边框
    
    	gotoxy(60,20);
    	color(11);
    	printf("----------------------+");						//下边框
    
    }
    
    /*
    	主函数
    */
    int main(int argc, char* argv[])
    {
    	system("mode con cols=110 lines=30");	//设置控制台宽高
    	printsnake();							//绘制字符蛇
    	welcometogame();						//欢迎界面
    	//File_out();								//读取文件信息
    	//keyboardControl();						//控制键盘按钮
    	endgame();								//游戏结束
    	return 0;
    }
    
    

    3、简单到炸的自制迷宫

    本程序中的迷宫及其简单,你可以尝试修改地图,增加难度。

    #include<stdio.h>
    #include<stdlib.h>
    #include<windows.h>
    #include<conio.h>
    int main()
    {
    	
    	char a[1000][1000] = {"##########",
    						"#o #  #   ",
    						"# ## ## ##",
    						"#  #    ##",
    						"##   ## ##",
    						"##########" };
    	int i, x = 1, y = 1;
    	int count=0;
    	printf("\n\n\t请不要使用中文输入法!\n\t操作方式:上下左右=WSAD\n\t o 代表你操作的人物, # 代表墙体。\n\t开始你的游戏吧!\n\n\n");
    	for (i = 0; i < 11; i++)
    		puts(a[i]);
    	char ch;
    	while (x != 1|| y != 9)
    	{
    		
    		ch = _getch();
    		count++;
    		if (ch == 's')
    		{
    			if (a[x + 1][y] != '#')
    			{
    				a[x][y] = ' ';
    				x++;
    				a[x][y] = 'o';
    			}
    		}
    		if (ch == 'w')
    		{
    			if (a[x - 1][y] != '#')
    			{
    				a[x][y] = ' ';
    				x--;
    				a[x][y] = 'o';
    			}
    		}
    		if (ch == 'a')
    		{
    			if (a[x][y - 1] != '#')
    			{
    				a[x][y] = ' ';
    				y--;
    				a[x][y] = 'o';
    			}
    		}
    		if (ch == 'd')
    		{
    			if (a[x][y + 1] != '#')
    			{
    				a[x][y] = ' ';
    				y++;
    				a[x][y] = 'o';
    			}
    		}
     
    		system("cls");
    		if (x == 1 && y == 9)
    			printf("成功过关\n");
    		for (i = 0; i < 6; i++)
    			puts(a[i]);
    	}
    	printf("你一共走了%d步\n", count);
    	Sleep(5000);
    	return 0;
    }
    
    

    4、不忍直视的双人飞机对战

    芜湖,我愿称之为无与伦比。

    /*--------------------------------------
    project: 双人小游戏
    anthor:   LLz 
    操作    移动    逆、顺时针旋转   发射子弹 
    玩家1   4568    7 9 			      0 
    玩家2   adws 	  q e 			      空格        
    --------------------------------*/ 
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <windows.h>
    // 游戏画面尺寸
    #define High 20  
    #define Width 100        
    // 全局变量
    int position_x,position_y,p_x,p_y,turn_a,turn_b,num_a,num_b,num_max,life_a = 10,life_b = 10; // 飞机位置
    int canvas[High][Width] = {0}; // 二维数组存储游戏画布中对应的元素
                            // 0为空格,1为飞机*,2为子弹|,3为敌机@
    int next[8][2] = {{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1}}; //从右  右下  下  左下 
    int bullet_a[21][4];
    int bullet_b[21][4];   //a b玩家子弹20发;            
    void gotoxy(int x,int y)  //光标移动到(x,y)位置
    {
        HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
        COORD pos;
        pos.X = x;
        pos.Y = y;
        SetConsoleCursorPosition(handle,pos);
    } 
    void startup() // 数据初始化
    {
    	num_a = 0;
    	num_b = 0;
    	turn_a = 0;
    	turn_b = 0;
    	p_x = High/2;//左边飞机
    	p_y = Width* 4 / 5;
    	canvas[p_x][p_y] = 5;//?
    	position_x = High/2;//右边飞机
    	position_y = Width/5;
    	canvas[position_x][position_y] = 1;	
    }
    void show()  // 显示画面
    {
    	gotoxy(0,0);  // 光标移动到原点位置,以下重画清屏
    	int i,j;
    	for (i=0;i<High;i++)
    	{
    		for (j=0;j<Width;j++)
    		{
    			if( i == 0 || i == High -1 || j == 0 || j == Width -1){
    				canvas[i][j] = 4;
    				printf("0");
    				continue;
    			}
    			if (canvas[i][j]==0)
    				printf(" ");   //   输出空格
    			else if (canvas[i][j]==1)
    				printf("A");   //   输出飞机a
    			else if (canvas[i][j]==2)
    				printf("B");   //   输出飞机B
    			else if (canvas[i][j]==3)
    				printf("o");   //  输出子弹o 
    			else if (canvas[i][j]==4)
    				printf("+");   //	输出飞机a指向 
    			else if (canvas[i][j]==5)
    				printf("+");   //	输出飞机b指向  
    		}
    		printf("\n");
    	}
    	//初始血量显示
    	printf("A:");
    	for( i = 1; i <= 10; i++ )
    		if( i <= life_a)
    			printf("■");
    		else printf(" ");
    	printf("\nB: ");
    	for( i = 1; i <= 10; i++ )
    		if( i <= life_b)
    			printf("■");
    		else printf(" ");
    }	
    void updateWithoutInput()  // 与用户输入无关的更新
    {	
    	int i,j,k;
    	num_max = num_a > num_b? num_a : num_b;
    	for( i = 1; i <= num_max; i++){
    			if( bullet_a[i][2] == 0 || bullet_a[i][2] == High - 1){
    				bullet_a[i][0] = -bullet_a[i][0];
    			}
    			else if( bullet_a[i][3] == 0 || bullet_a[i][3] == Width - 1){
    				bullet_a[i][1] = -bullet_a[i][1];
    			}
    			if( bullet_b[i][2] == 0 || bullet_b[i][2] == High - 1){
    				bullet_b[i][0] = -bullet_b[i][0];
    			}
    			else if( bullet_b[i][3] == 0 || bullet_b[i][3] == Width - 1){
    				bullet_b[i][1] = -bullet_b[i][1];
    			}
    			canvas[ bullet_a[i][2] ][ bullet_a[i][3] ] = 0;
    			canvas[ bullet_b[i][2] ][ bullet_b[i][3] ] = 0;
    			bullet_a[i][2] += bullet_a[i][0];
    			bullet_a[i][3] += bullet_a[i][1];
    			bullet_b[i][2] += bullet_b[i][0];
    			bullet_b[i][3] += bullet_b[i][1];
    			canvas[ bullet_a[i][2] ][ bullet_a[i][3] ] = 3;
    			canvas[ bullet_b[i][2] ][ bullet_b[i][3] ] = 3;
    	}
    	for (k=1;k<=num_max;k++)
    	{
    		if (((position_x==bullet_a[k][2]) && (position_y==bullet_a[k][3]))||((position_x==bullet_b[k][2]) && (position_y==bullet_b[k][3])))  // 敌机撞到我机
    		{
    			life_a--;
    			if( life_a <= 0){
    				printf("A 玩家失败!\n");
    				Sleep(3000);
    				system("pause");
    				exit(0);
    			}
    		}
    		if (((p_x==bullet_a[k][2]) && (p_y==bullet_a[k][3]))||((p_x==bullet_b[k][2]) && (p_y==bullet_b[k][3])))  // 敌机撞到我机
    		{
    			life_b--;
    			if( life_b <= 0){
    				printf("B 玩家失败!\n");
    				Sleep(3000);
    				system("pause");
    				exit(0);
    			}
    		}
    	}
    }
    void updateWithInput()  // 与用户输入有关的更新
    {
    	char input;
    	if(kbhit())  // 判断是否有输入
    	{
    		input = getch();  // 根据用户的不同输入来移动,不必输入回车
    		if (input == 'a' && position_y>1) 
    		{
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 0;
    			canvas[position_x][position_y] = 0;
    			position_y--;  // 位置左移
    			canvas[position_x][position_y] = 1;
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 4;
    		}
    		else if (input == 'd' && position_y<Width-2)
    		{
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 0;
    			canvas[position_x][position_y] = 0;
    			position_y++;  // 位置右移
    			canvas[position_x][position_y] = 1;
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 4;
    		}
    		else if (input == 'w' && position_x > 1)
    		{
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 0;
    			canvas[position_x][position_y] = 0;
    			position_x--;  // 位置上移
    			canvas[position_x][position_y] = 1;
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 4;
    		}
    		else if (input == 's'&& position_x < High - 2)
    		{
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 0;
    			canvas[position_x][position_y] = 0;
    			position_x++;  // 位置下移
    			canvas[position_x][position_y] = 1;
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 4;
    		}		
    		else if (input == ' ' && num_a <= 20)  // 发射子弹
    		{
    			num_a++;
    			bullet_a[num_a][0] = next[turn_a][0];
    			bullet_a[num_a][1] = next[turn_a][1];
    			bullet_a[num_a][2] = position_x + bullet_a[num_a][0];
    			bullet_a[num_a][3] = position_y + bullet_a[num_a][1];
    			canvas[ bullet_a[num_a][2] ][ bullet_a[num_a][3] ] = 3;
    		}
    		else if (input == 'q')  // 炮弹换方向 
    		{
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 0;
    			turn_a--;
    			if(turn_a < 0)
    				turn_a = 7;
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 4;
    		}
    		else if (input == 'e')  //  炮弹换方向 
    		{
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 0;
    			turn_a++;
    			if(turn_a > 7)
    				turn_a = 0;
    			canvas[position_x + next[turn_a][0]][position_y + next[turn_a][1]] = 4;
    		}
    		else if (input == '4' && position_y>1) 
    		{
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 0;
    			canvas[p_x][p_y] = 0;
    			p_y--;  // 位置左移
    			canvas[p_x][p_y] = 2;
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 5;
    		}
    		else if (input == '6' && p_y<Width-2)
    		{
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 0;
    			canvas[p_x][p_y] = 0;
    			p_y++;  // 位置右移
    			canvas[p_x][p_y] = 2;
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 5;
    		}
    		else if (input == '8' && p_x > 1)
    		{
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 0;
    			canvas[p_x][p_y] = 0;
    			p_x--;  // 位置上移
    			canvas[p_x][p_y] = 2;
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 5;
    		}
    		else if (input == '5' && p_x < High - 2)
    		{
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 0;
    			canvas[p_x][p_y] = 0;
    			p_x++;  // 位置下移
    			canvas[p_x][p_y] = 2;
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 5;
    		}		
    		else if (input == '0' && num_b <= 20)  // 发射子弹
    		{
    			num_b++;
    			bullet_b[num_b][0] = next[turn_b][0];
    			bullet_b[num_b][1] = next[turn_b][1];
    			bullet_b[num_b][2] = p_x + bullet_b[num_b][0];
    			bullet_b[num_b][3] = p_y + bullet_b[num_b][1];
    			canvas[ bullet_b[num_b][2] ][ bullet_b[num_b][3] ] = 3;
    		}	
    		else if (input == '7')  // 炮弹换方向 
    		{
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 0;
    			turn_b--;
    			if(turn_b < 0)
    				turn_b = 7;
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 5;
    		}
    		else if (input == '9')  //  炮弹换方向 
    		{
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 0;
    			turn_b++;
    			if(turn_b > 7)
    				turn_b = 0;
    			canvas[p_x + next[turn_b][0]][p_y + next[turn_b][1]] = 5;
    		}
    	}
    }
    int main()
    {
    	startup();  // 数据初始化
    	system("color 30");
    	while (1)  // 游戏循环执行
    	{
    		show();  // 显示画面
    		updateWithoutInput();  // 与用户输入无关的更新
    		updateWithInput();  // 与用户输入有关的更新
    	}
    	return 0;
    }
    
    
    展开全文
    weixin_47192105 2021-11-22 19:37:41
  • //C语言多线程-主角和怪物#include#include#define bool int //定义int变量为bool变量,bool不是真就是假int a=0,b=20;//主角的坐标int x=1,y=0;//怪物的坐标int i=1;//i值为真HANDLE hMutex;//1.坐标void ...

    //C语言多线程-主角和怪物

    #include

    #include

    #define bool int //定义int变量为bool变量,bool不是真就是假

    int a=0,b=20;//主角的坐标

    int x=1,y=0;//怪物的坐标

    int i=1;//i值为真

    HANDLE hMutex;

    //1.坐标

    void GamePosition(HANDLE g_hout,int x,int y)

    {

    COORD pos;//点的结构体

    pos.X=x;//横坐标

    pos.Y=y;//纵坐标

    SetConsoleCursorPosition(g_hout,pos);

    //设置控制平台光标位置

    }

    DWORD WINAPI Func(LPVOID lpParamter)//多线程的功能函数6.线程是画怪物

    {

    HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);//7.拿到这张纸

    WaitForSingleObject(hMutex, INFINITE);//13.自己进来,自己用洗手间

    GamePosition(hout,x,y),printf('●');//8.在纸上画怪物

    ReleaseMutex(hMutex);//14.放弃使用权

    while(1)//9.怪物在横坐标为从0-10依次循环移动

    {

    if(x>=0&&i==1)

    {

    printf('  ');

    GamePosition(hout,++x,y);

    printf('●');

    Sleep(1000);

    if(x==10)

    i=0;//i为假

    }

    else if(x<>

    {

    printf('  ');

    GamePosition(hout,--x,y);

    printf('●');

    Sleep(1000);

    if(x==0)

    i=1;

    }

    }

    return 0;

    }

    int main()

    {

    HANDLE hThread = CreateThread(NULL, 0, Func, NULL, 0, NULL);//5.创建线程

    hMutex = CreateMutexA(NULL, FALSE, '123');//创建互斥锁(量)//10.关上洗手间

    HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);//2.拿到这张纸

    WaitForSingleObject(hMutex, INFINITE);//11.等待你的同事出来 15步接着

    GamePosition(hout,a,b),printf('☆');//3.在纸上画主角

    ReleaseMutex(hMutex);//12.同事出来了,放弃了洗手间的使用权

    while(1)

    {

    if(kbhit())

    switch(getch())//控制左右 4.主角上下左右移动

    {

    case 'w':

    case 'W':

    if(b>3)GamePosition(hout,a,b),printf('  '),GamePosition(hout,a,--b),printf('☆');

    break;

    case 's':

    case 'S':

    if(b<20)gameposition(hout,a,b),printf('>

    break;

    case 'a':

    case 'A':

    if(a>0)printf('  '),GamePosition(hout,--a,b),printf('☆');

    break;

    case 'd':

    case 'D':

    if(a<20)printf('>

    break;

    }

    }

    CloseHandle(hThread);

    system('pause');

    return 0;

    }

    70951668_2

    扫雷游戏代码源码

    70951668_3

    70951668_4

    70951668_5

    #include

    #include

    #include

    int main (){

    int delta[8][2] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

    int row =0,col = 0,num = 0;

    char map[10][10] = {0};

    char show[10][10] = {0};

    srand(time(0));

    for(row = 0;row <=>

    for(col = 0;col <=>

    map[row][col] = '0';

    }

    }

    do{

    row = rand() % 10;

    col = rand() % 10;

    if(map[row][col] == '0'){

    map[row][col] = 'x';

    num++;

    }

    }while(num <>

    for (row = 0;row <=>

    for (col = 0;col <=>

    if(map[row][col] != 'x'){

    int cnt = 0;

    for (num = 0;num <=>

    if(row + delta[num][0] <>

    continue;

    }

    if(row + delta[num][0] > 9){

    continue;

    }

    if(col + delta[num][1] <>

    continue;

    }

    if(col + delta[num][1] > 9){

    continue;

    }

    if(map[row + delta[num][0]][col + delta[num][1]]== 'x'){

    cnt++;

    }

    }

    map[row][col] = '0' + cnt;

    }

    }

    }

    for (row = 0;row <>

    for(col = 0;col < 10;col="">

    printf('* ');

    }

    printf('\n');

    }

    num = 0;

    int x,y;

    do{

    printf('please enter the coordinate of array:');

    scanf('%d%d',&x,&y);

    show[x-1][y-1] = 1;

    if(map[x-1][y-1] == '0'){

    for (num = 0;num <=>

    if(x-1 + delta[num][0] <>

    continue;

    }

    if(x-1 + delta[num][0] > 9){

    continue;

    }

    if(y -1+ delta[num][1] <>

    continue;

    }

    if(y-1 + delta[num][1] > 9){

    continue;

    }

    show[x-1+delta[num][0]][y-1+delta[num][1]] = 1;

    }

    }

    if (map[x-1][y-1]!= 'x'&&map[x-1][y-1] != '0'){

    for (num = 0;num <=>

    int cnt = 0;

    if(x-1 + delta[num][0] <>

    continue;

    }

    if(x-1 + delta[num][0] > 9){

    continue;

    }

    if(y-1 + delta[num][1] <>

    continue;

    }

    if(y-1 + delta[num][1] > 9){

    continue;

    }

    if( map[x -1 + delta[num][0]][y -1+ delta[num][1]] != 'x'){

    show[x-1  + delta[num][0]][y -1+ delta[num][1]] = 1 ;

    }

    }

    }

    if(map[x-1][y-1] == 'x') {

    printf('game over!\n');

    for (row = 0;row <>

    for(col = 0;col < 10;col="">

    printf('%c ',map[row][col]);

    }

    printf('\n');

    }

    return 0;

    }

    system('cls');

    printf('mine sweeping:\n');

    for (row = 0;row <>

    for(col = 0;col < 10;col="">

    if (show[row][col] == 1)

    {

    printf('%c ', map[row][col]);

    }

    else

    {

    printf('* ');

    }

    }

    printf('\n');

    }

    num = 0;

    for (row = 0;row <>

    for(col = 0;col < 10;col="">

    if (show[row][col] == 1 )

    {

    num++;

    }

    }

    }

    printf('num:%d\n',num);

    }while(num <>

    printf('you win!');

    return 0;

    }70951668_2

    展开全文
    weixin_42299310 2021-05-20 01:10:20
  • 在此提供C语言小游戏源码,包括扫雷游戏,贪吃蛇游戏,时钟等。运行时只要把红色部分改为自己电脑上TC目录的BGI分目录即可。//扫雷游戏#include #include #include #define LEFTPRESS 0xff01#define LEFTCLICK 0xff...

    在此提供C语言小游戏源码,包括扫雷游戏,贪吃蛇游戏,时钟等。

    运行时只要把红色部分改为自己电脑上TC目录的BGI分目录即可。

    //扫雷游戏

    #include

    #include

    #include

    #define LEFTPRESS 0xff01

    #define LEFTCLICK 0xff10

    #define LEFTDRAG 0xff19

    #define MOUSEMOVE 0xff08

    struct

    {

    int num;

    int roundnum;

    int flag;

    }Mine[10][10];

    int gameAGAIN=0;

    int gamePLAY=0;

    int mineNUM;

    char randmineNUM[3];

    int Keystate;

    int MouseExist;

    int MouseButton;

    int MouseX;

    int MouseY;

    void Init(void);

    void MouseOn(void);

    void MouseOff(void);

    void MouseSetXY(int,int);

    int LeftPress(void);

    int RightPress(void);

    void MouseGetXY(void);

    void Control(void);

    void GameBegain(void);

    void DrawSmile(void);

    void DrawRedflag(int,int);

    void DrawEmpty(int,int,int,int);

    void GameOver(void);

    void GameWin(void);

    int MineStatistics(int,int);

    int ShowWhite(int,int);

    void GamePlay(void);

    void Close(void);

    void main(void)

    {

    Init();

    Control();

    Close();

    }

    void Init(void)

    {

    int gd=DETECT,gm;

    initgraph(&gd,&gm,"D:\\tc20\\BGI");

    }

    void Close(void)

    {

    closegraph();

    }

    void MouseOn(void)

    {

    _AX=0x01;

    geninterrupt(0x33);

    }

    void MouseOff(void)

    {

    _AX=0x02;

    geninterrupt(0x33);

    }

    void MouseSetXY(int x,int y)

    {

    _CX=x;

    _DX=y;

    _AX=0x04;

    geninterrupt(0x33);

    }

    int LeftPress(void)

    {

    _AX=0x03;

    geninterrupt(0x33);

    return(_BX&1);

    }

    int RightPress(void)

    {

    _AX=0x03;

    geninterrupt(0x33);

    return(_BX&2);

    }

    void MouseGetXY(void)

    {

    _AX=0x03;

    geninterrupt(0x33);

    MouseX=_CX;

    MouseY=_DX;

    }

    void Control(void)

    {

    int gameFLAG=1;

    while(1)

    {

    if(gameFLAG)

    {

    GameBegain();

    GamePlay();

    if(gameAGAIN==1)

    {

    gameAGAIN=0;

    continue;

    }

    }

    MouseOn();

    gameFLAG=0;

    if(LeftPress())

    {

    MouseGetXY();

    if(MouseX>280&&MouseX<300&&MouseY>65&&MouseY<85)

    {

    gameFLAG=1;

    continue;

    }

    }

    if(kbhit())

    break;

    }

    MouseOff();

    }

    void DrawSmile(void)

    {

    setfillstyle(SOLID_FILL,YELLOW);

    fillellipse(290,75,10,10);

    setcolor(YELLOW);

    setfillstyle(SOLID_FILL,BLACK);

    fillellipse(285,75,2,2);

    fillellipse(295,75,2,2);

    setcolor(BLACK);

    bar(287,80,293,81);

    }

    void DrawRedflag(int i,int j)

    {

    setcolor(7);

    setfillstyle(SOLID_FILL,RED);

    bar(198+j*20,95+i*20,198+j*20+5,95+i*20+5);

    setcolor(BLACK);

    line(198+j*20,95+i*20,198+j*20,95+i*20+10);

    }

    void DrawEmpty(int i,int j,int mode,int color)

    {

    setcolor(color);

    setfillstyle(SOLID_FILL,color);

    if(mode==0)

    bar(200+j*20-8,100+i*20-8,200+j*20+8,100+i*20+8);

    else

    if(mode==1)

    bar(200+j*20-7,100+i*20-7,200+j*20+7,100+i*20+7);

    }

    void GameBegain(void)

    {

    int i,j;

    cleardevice();

    if(gamePLAY!=1)

    {

    MouseSetXY(290,70);

    MouseX=290;

    MouseY=70;

    }

    gamePLAY=1;

    mineNUM=0;

    setfillstyle(SOLID_FILL,7);

    bar(190,60,390,290);

    for(i=0;i<10;i++)

    for(j=0;j<10;j++)

    DrawEmpty(i,j,0,8);

    setcolor(7);

    DrawSmile();

    randomize();//__page_break__

    for(i=0;i<10;i++)

    for(j=0;j<10;j++)

    {

    Mine[i][j].num=random(8);

    if(Mine[i][j].num==1)

    mineNUM++;

    else

    Mine[i][j].num=2;

    Mine[i][j].flag=0;

    }

    sprintf(randmineNUM,"%d",mineNUM);

    setcolor(1);

    settextstyle(0,0,2);

    outtextxy(210,70,randmineNUM);

    mineNUM=100-mineNUM;

    MouseOn();

    }

    void GameOver(void)

    {

    int i,j;

    setcolor(0);

    for(i=0;i<10;i++)

    for(j=0;j<10;j++)

    if(Mine[i][j].num==1)

    {

    DrawEmpty(i,j,0,RED);

    setfillstyle(SOLID_FILL,BLACK);

    fillellipse(200+j*20,100+i*20,7,7);

    }

    }

    void GameWin(void)

    {

    setcolor(11);

    settextstyle(0,0,2);

    outtextxy(230,30,"YOU WIN!");

    }

    int MineStatistics(int i,int j)

    {

    int nNUM=0;

    if(i==0&&j==0)

    {

    if(Mine[0][1].num==1)

    nNUM++;

    if(Mine[1][0].num==1)

    nNUM++;

    if(Mine[1][1].num==1)

    nNUM++;

    }

    else

    if(i==0&&j==9)

    {

    if(Mine[0][8].num==1)

    nNUM++;

    if(Mine[1][9].num==1)

    nNUM++;

    if(Mine[1][8].num==1)

    nNUM++;

    }

    else

    if(i==9&&j==0)

    {

    if(Mine[8][0].num==1)

    nNUM++;

    if(Mine[9][1].num==1)

    nNUM++;

    if(Mine[8][1].num==1)

    nNUM++;

    }

    else

    if(i==9&&j==9)

    {

    if(Mine[9][8].num==1)

    nNUM++;

    if(Mine[8][9].num==1)

    nNUM++;

    if(Mine[8][8].num==1)

    nNUM++;

    }

    else if(j==0)

    {

    if(Mine[i][j+1].num==1)

    nNUM++;

    if(Mine[i+1][j].num==1)

    nNUM++;

    if(Mine[i-1][j].num==1)

    nNUM++;

    if(Mine[i-1][j+1].num==1)

    nNUM++;

    if(Mine[i+1][j+1].num==1)

    nNUM++;

    }

    else if(j==9)

    {

    if(Mine[i][j-1].num==1)

    nNUM++;

    if(Mine[i+1][j].num==1)

    nNUM++;

    if(Mine[i-1][j].num==1)

    nNUM++;

    if(Mine[i-1][j-1].num==1)

    nNUM++;

    if(Mine[i+1][j-1].num==1)

    nNUM++;

    }

    else if(i==0)

    {

    if(Mine[i+1][j].num==1)

    nNUM++;

    if(Mine[i][j-1].num==1)

    nNUM++;

    if(Mine[i][j+1].num==1)

    nNUM++;

    if(Mine[i+1][j-1].num==1)

    nNUM++;

    if(Mine[i+1][j+1].num==1)

    nNUM++;

    }

    else if(i==9)

    {

    if(Mine[i-1][j].num==1)

    nNUM++;

    if(Mine[i][j-1].num==1)

    nNUM++;

    if(Mine[i][j+1].num==1)

    nNUM++;

    if(Mine[i-1][j-1].num==1)

    nNUM++;

    if(Mine[i-1][j+1].num==1)

    nNUM++;

    }

    else

    {

    if(Mine[i-1][j].num==1)

    nNUM++;

    if(Mine[i-1][j+1].num==1)

    nNUM++;

    if(Mine[i][j+1].num==1)

    nNUM++;

    if(Mine[i+1][j+1].num==1)

    nNUM++;

    if(Mine[i+1][j].num==1)

    nNUM++;

    if(Mine[i+1][j-1].num==1)

    nNUM++;

    if(Mine[i][j-1].num==1)

    nNUM++;

    if(Mine[i-1][j-1].num==1)

    nNUM++;

    }//__page_break__

    return (nNUM);

    }

    int ShowWhite(int i,int j)

    {

    if(Mine[i][j].flag==1||Mine[i][j].num==0)

    return;

    mineNUM--;

    if(Mine[i][j].roundnum==0&&Mine[i][j].num!=1)

    {

    DrawEmpty(i,j,1,7);

    Mine[i][j].num=0;

    }

    else

    if(Mine[i][j].roundnum!=0)

    {

    DrawEmpty(i,j,0,8);

    sprintf(randmineNUM,"%d",Mine[i][j].roundnum);

    setcolor(RED);

    outtextxy(195+j*20,95+i*20,randmineNUM);

    Mine[i][j].num=0;

    return ;

    }

    if(i!=0&&Mine[i-1][j].num!=1)

    ShowWhite(i-1,j);

    if(i!=0&&j!=9&&Mine[i-1][j+1].num!=1)

    ShowWhite(i-1,j+1);

    if(j!=9&&Mine[i][j+1].num!=1)

    ShowWhite(i,j+1);

    if(j!=9&&i!=9&&Mine[i+1][j+1].num!=1)

    ShowWhite(i+1,j+1);

    if(i!=9&&Mine[i+1][j].num!=1)

    ShowWhite(i+1,j);

    if(i!=9&&j!=0&&Mine[i+1][j-1].num!=1)

    ShowWhite(i+1,j-1);

    if(j!=0&&Mine[i][j-1].num!=1)

    ShowWhite(i,j-1);

    if(i!=0&&j!=0&&Mine[i-1][j-1].num!=1)

    ShowWhite(i-1,j-1);

    }

    void GamePlay(void)

    {

    int i,j,Num;

    for(i=0;i<10;i++)

    for(j=0;j<10;j++)

    Mine[i][j].roundnum=MineStatistics(i,j);

    while(!kbhit())

    {

    if(LeftPress())

    {

    MouseGetXY();

    if(MouseX>280&&MouseX<300&&MouseY>65&&MouseY<85)

    {

    MouseOff();

    gameAGAIN=1;

    break;

    }

    if(MouseX>190&&MouseX<390&&MouseY>90&&MouseY<290)

    {

    j=(MouseX-190)/20;

    i=(MouseY-90)/20;

    if(Mine[i][j].flag==1)

    continue;

    if(Mine[i][j].num!=0)

    {

    if(Mine[i][j].num==1)

    {

    MouseOff();

    GameOver();

    break;

    }

    else

    {

    MouseOff();

    Num=MineStatistics(i,j);

    if(Num==0)

    ShowWhite(i,j);

    else

    {

    sprintf(randmineNUM,"%d",Num);

    setcolor(RED);

    outtextxy(195+j*20,95+i*20,randmineNUM);

    mineNUM--;

    }

    MouseOn();

    Mine[i][j].num=0;

    if(mineNUM<1)

    {

    GameWin();

    break;

    }

    }

    }

    }

    }

    if(RightPress())

    {

    MouseGetXY();

    if(MouseX>190&&MouseX<390&&MouseY>90&&MouseY<290)

    {

    j=(MouseX-190)/20;

    i=(MouseY-90)/20;

    MouseOff();

    if(Mine[i][j].flag==0&&Mine[i][j].num!=0)

    {

    DrawRedflag(i,j);

    Mine[i][j].flag=1;

    }

    else

    if(Mine[i][j].flag==1)

    {

    DrawEmpty(i,j,0,8);

    Mine[i][j].flag=0;

    }

    }

    MouseOn();

    sleep(1);

    }

    }

    }

    //时钟

    #include

    #include

    #include

    #define pi 3.1415926

    #define X(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300;

    #define Y(a,b,c) y=a*sin(b*c*pi/180-pi/2)+240;

    #define d(a,b,c) X(a,b,c);Y(a,b,c);line(300,240,x,y)

    void init()

    {int i,l,x1,x2,y1,y2;

    setbkcolor(0);

    circle(300,240,200);

    circle(300,240,205);

    circle(300,240,5);

    for(i=0;i<60;i++)

    {if(i%5==0) l=15;

    else l=5;

    x1=200*cos(i*6*pi/180)+300;

    y1=200*sin(i*6*pi/180)+240;

    x2=(200-l)*cos(i*6*pi/180)+300;

    y2=(200-l)*sin(i*6*pi/180)+240;

    line(x1,y1,x2,y2);

    }

    }

    main()

    {

    int x,y;

    int gd=VGA,gm=2;

    unsigned char h,m,s;

    struct time t[1];

    initgraph(&gd,&gm,"d:\\tc20\\BGI");

    init();

    setwritemode(1);

    gettime(t);

    h=t[0].ti_hour;

    m=t[0].ti_min;

    s=t[0].ti_sec;

    setcolor(7);

    d(150,h,30);

    setcolor(14);

    d(170,m,6);

    setcolor(4);

    d(190,s,6);

    while(!kbhit())

    {while(t[0].ti_sec==s)

    gettime(t);

    sound(400);

    delay(70);

    sound(200);

    delay(30);

    nosound();

    setcolor(4);

    d(190,s,6);

    s=t[0].ti_sec;

    d(190,s,6);

    if (t[0].ti_min!=m)

    {

    setcolor(14);

    d(170,m,6);

    m=t[0].ti_min;

    d(170,m,6);

    }

    if (t[0].ti_hour!=h)

    { setcolor(7);

    d(150,h,30);

    h=t[0].ti_hour;

    d(150,h,30);

    sound(1000);

    delay(240);

    nosound();

    delay(140);

    sound(2000);

    delay(240);

    nosound();

    }

    }

    getch();

    closegraph();

    }

    //贪吃蛇

    #define N 200

    #include

    #include

    #include

    #define LEFT 0x4b00

    #define RIGHT 0x4d00

    #define DOWN 0x5000

    #define UP 0x4800

    #define ESC 0x011b

    int i,key;

    int score=0;

    int gamespeed=50000;

    struct Food

    {

    int x;

    int y;

    int yes;

    }food;

    struct Snake

    {

    int x[N];

    int y[N];

    int node;

    int direction;

    int life;

    }snake;

    void Init(void);

    void Close(void);

    void DrawK(void);

    void GameOver(void);

    void GamePlay(void);

    void PrScore(void);

    void main(void)

    {

    Init();

    DrawK();

    GamePlay();

    Close();

    }

    void Init(void)

    {

    int gd=DETECT,gm;

    initgraph(&gd,&gm,"D:\\tc20\\BGI");

    cleardevice();

    }

    void DrawK(void)

    {

    setcolor(11);

    setlinestyle(SOLID_LINE,0,THICK_WIDTH);

    for(i=50;i<=600;i+=10)

    {

    rectangle(i,40,i+10,49);

    rectangle(i,451,i+10,460);

    }

    for(i=40;i<=450;i+=10)

    {

    rectangle(50,i,59,i+10);

    rectangle(601,i,610,i+10);

    }

    }

    void GamePlay(void)

    {

    randomize();

    food.yes=1;

    snake.life=0;

    snake.direction=1;

    snake.x[0]=100;snake.y[0]=100;

    snake.x[1]=110;snake.y[1]=100;

    snake.node=2;

    PrScore();

    while(1)

    {

    while(!kbhit())

    {

    if(food.yes==1)

    {

    food.x=rand()%400+60;

    food.y=rand()%350+60;

    while(food.x%10!=0)

    food.x++;

    while(food.y%10!=0)

    food.y++;

    food.yes=0;

    }

    if(food.yes==0)

    {

    setcolor(GREEN);

    rectangle(food.x,food.y,food.x+10,food.y-10);

    }

    for(i=snake.node-1;i>0;i--)

    {

    snake.x[i]=snake.x[i-1];

    snake.y[i]=snake.y[i-1];

    }

    switch(snake.direction)

    {

    case 1:snake.x[0]+=10;break;

    case 2: snake.x[0]-=10;break;

    case 3: snake.y[0]-=10;break;

    case 4: snake.y[0]+=10;break;

    }

    for(i=3;i

    {

    if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])

    {

    GameOver();

    snake.life=1;

    break;

    }

    }

    if(snake.x[0]<55||snake.x[0]>595||snake.y[0]<55||

    snake.y[0]>455)

    {

    GameOver();

    snake.life=1;

    }

    if(snake.life==1)

    break;

    if(snake.x[0]==food.x&&snake.y[0]==food.y)

    {

    setcolor(0);

    rectangle(food.x,food.y,food.x+10,food.y-10);

    snake.x[snake.node]=-20;snake.y[snake.node]=-20;

    snake.node++;

    food.yes=1;

    score+=10;

    PrScore();

    }

    setcolor(4);

    for(i=0;i

    rectangle(snake.x[i],snake.y[i],snake.x[i]+10,

    snake.y[i]-10);

    delay(gamespeed);

    setcolor(0);

    rectangle(snake.x[snake.node-1],snake.y[snake.node-1],

    snake.x[snake.node-1]+10,snake.y[snake.node-1]-10);

    }

    if(snake.life==1)

    break;

    key=bioskey(0);

    if(key==ESC)

    break;

    else

    if(key==UP&&snake.direction!=4)

    snake.direction=3;

    else

    if(key==RIGHT&&snake.direction!=2)

    snake.direction=1;

    else

    if(key==LEFT&&snake.direction!=1)

    snake.direction=2;

    else

    if(key==DOWN&&snake.direction!=3)

    snake.direction=4;

    }

    }

    void GameOver(void)

    {

    cleardevice();

    PrScore();

    setcolor(RED);

    settextstyle(0,0,4);

    outtextxy(200,200,"GAME OVER");

    getch();

    }

    void PrScore(void)

    {

    char str[10];

    setfillstyle(SOLID_FILL,YELLOW);

    bar(50,15,220,35);

    setcolor(6);

    settextstyle(0,0,2);

    sprintf(str,"score:%d",score);

    outtextxy(55,20,str);

    }

    void Close(void)

    {

    getch();

    closegraph();

    }

    //鼠标控制

    #include

    #include

    #include

    #include

    #include

    #include "graphics.h"

    #define R 15

    void initgr(void)

    {

    int gd = DETECT, gm = 0;

    initgraph(&gd, &gm, "D:\\TC20\\BGI");

    }

    void getmouse(int *x,int *y,int *key)

    {

    union REGS inregs,outregs;

    inregs.x.ax=3;

    int86(0x33,&inregs,&outregs);

    *x=outregs.x.cx;

    *y=outregs.x.dx;

    *key=outregs.x.bx;

    }

    void visbilemouse()

    {

    union REGS inregs,outregs;

    inregs.x.ax=0x01;

    int86(0x33,&inregs,&outregs);

    }

    void mouse(int *x,int *y,int *z)

    {

    int a=0,b=0,c=0,a_old=0,b_old=0;

    int *ball;

    ball=malloc(imagesize(a,b,a+R,b+R));

    getimage(a,b,a+R,b+R,ball);

    while(c==0)

    {

    getmouse(&a,&b,&c);

    if(a<0) a=0;

    if(b<0) b=0;

    if(a>getmaxx()-R) a=getmaxx()-R;

    if(b>getmaxy()-R) b=getmaxy()-R;

    if(a!=a_old || b!=b_old)

    {

    putimage(a_old,b_old,ball,0);

    getimage(a,b,a+R,b+R,ball);

    setcolor(GREEN);

    setlinestyle(0,0,1);

    line(a,b,a+R,b+R/2);

    line(a,b,a+R/2,b+R);

    line(a+R,b+R/2,a+R/2,b+R);

    line(a+R*3/4,b+R*3/4,a+R,b+R);

    }

    a_old=a;b_old=b;

    }

    *x=a;*y=b;*z=c;

    putimage(a,b,ball,0);

    free(ball);

    }

    void main()

    {

    int x,y,z;

    initgr();

    visbilemouse();

    do

    {

    setcolor(WHITE);

    rectangle(175,8,220,25);

    outtextxy(180,10,"exit");

    mouse(&x,&y,&z);

    if(z==1)

    {

    setlinestyle(0,0,1);

    setcolor(12);

    circle(x,y,1);

    }

    if(z==2)

    {setfillstyle(1,BLACK);

    bar(0,0,getmaxx(),getmaxy());

    }

    }while(x<175 || x>220 ||

    y<8 || y>25);

    closegraph();

    }

    本源码整理于互联网

    展开全文
    weixin_35196909 2021-05-19 12:45:48
  • 一、贪吃蛇小游戏简介:用上下左右控制蛇的方向,寻找吃的东西,每吃一口就能得到一定的积分,而且蛇的身子会越吃越长,身子越长玩的难度就越大,不能碰墙,也不能咬到自己的身体,等到了一定的分数,就能过关。...

    一、贪吃蛇小游戏简介:

    用上下左右控制蛇的方向,寻找吃的东西,每吃一口就能得到一定的积分,而且蛇的身子会越吃越长,身子越长玩的难度就越大,不能碰墙,也不能咬到自己的身体,等到了一定的分数,就能过关。

    二、函数框架

    87268eeeb7940971538d86ea80a0373f.png

    三、数据结构

    typedef struct Snake

    {

    size_t x; //行

    size_t y; //列

    struct Snake* next;

    }Snake, *pSnake;

    定义蛇的结构体,利用单链表来表示蛇,每个结点为蛇身体的一部分。

    四、代码实现(vs2010  c语言)

    1.Snake.h

    #ifndef __SNAKE_H__

    #define __SNAKE_H__

    #include

    #include

    #include

    #include

    #include

    #include

    //标识地图大小

    #define ROW_MAP 10 //地图的行

    #define COL_MAP 20 //地图的列

    #define SUCCESS_SCORE 10//通关分数

    enum Direction //蛇行走的方向

    {

    R, //右

    L, //左

    U, //上

    D //下

    }Direction;

    enum State

    {

    ERROR_SELF, //咬到自己

    ERROR_WALL, //撞到墙

    NORMAL, //正常状态

    SUCCESS //通关

    }State;

    typedef struct Snake

    {

    size_t x; //行

    size_t y; //列

    struct Snake* next;

    }Snake, *pSnake;

    void StartGame();

    void RunGame();

    void EndGame();

    #endif

    2.Snake.c

    #include "Snake.h"

    pSnake head = NULL; //定义蛇头指针

    pSnake Food = NULL; //定义食物指针

    int sleeptime = 500;//间隔时间,用来控制速度

    int Score = 0; //总分

    int everyScore = 1; //每步得分

    //定义游戏中用到的符号

    const char food = '#';

    const char snake = '*';

    void Pos(int x, int y) //控制输出光标

    {

    COORD pos; //pos为结构体

    pos.X = x; //控制列

    pos.Y = y; //控制行

    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);//读取标准输出句柄来控制光标为pos

    }

    void Face()

    {

    system("color 0C");

    printf("*******************************************************\n");

    printf("* Welcome to Snake Game! *\n");

    printf("* *\n");

    printf("* ->开始游戏请按 enter键 *\n");

    printf("* ->退出游戏请按 esc键 *\n");

    printf("* ->暂停游戏请按 space键 *\n");

    printf("* ->通过上下左右键来控制蛇的移动 *\n");

    printf("* ->通过F1键减速 F2键加速 *\n");

    printf("*******************************************************\n");

    }

    void Map() //初始化地图

    {

    int i = 0;

    for(i = 0; i

    {

    Pos(i, 0);

    printf("■");

    Pos(i, ROW_MAP-1);

    printf("■");

    }

    for(i = 0; i

    {

    Pos(0, i);

    printf("■");

    Pos(COL_MAP-2, i);

    printf("■");

    }

    }

    void PrintSnake() //打印蛇

    {

    pSnake cur = head;

    while(cur)

    {

    Pos(cur->y, cur->x);

    printf("%c", snake);

    cur = cur->next;

    }

    }

    void InitSnake() //初始化蛇身

    {

    int initNum = 3;

    int i = 0;

    pSnake cur;

    head = (pSnake)malloc(sizeof(Snake));

    head->x = 5;

    head->y = 10;

    head->next = NULL;

    cur = head;

    for(i = 1; i < initNum; i++)

    {

    pSnake newNode = (pSnake)malloc(sizeof(Snake));

    newNode->x = 5+i;

    newNode->y = 10;

    newNode->next = NULL;

    cur->next = newNode;

    cur = cur->next;

    }

    PrintSnake();

    }

    void CreateFood() //在地图上随机产生一个食物

    {

    pSnake cur = head;

    Food = (pSnake)malloc(sizeof(Snake));

    //产生x~y的随机数 k=rand()%(Y-X+1)+X;

    srand((unsigned)time(NULL));

    Food->x = rand()%(ROW_MAP-2 - 1 + 1)+1;

    Food->y = rand()%(COL_MAP-3 - 2 + 1)+2;

    Food->next = NULL;

    while(cur) //检查食物是否与蛇身重合

    {

    if(cur->x == Food->x && cur->y == Food->y)

    {

    free(Food);

    Food = NULL;

    CreateFood();

    return;

    }

    cur = cur->next;

    }

    Pos(Food->y, Food->x);

    printf("%c", food);

    }

    void StartGame() //游戏开始的所有设置

    {

    Face();

    system("pause");

    if(GetAsyncKeyState(VK_RETURN))

    {

    system("cls");

    Pos(COL_MAP+5, 1);

    printf("当前分数/通关分数:");

    Pos(COL_MAP+20, 1);

    printf("%d/%d", Score, SUCCESS_SCORE);

    Pos(COL_MAP+5, 2);

    printf("当前分每步得分:");

    Pos(COL_MAP+20, 2);

    printf("%d", everyScore);

    Pos(COL_MAP+5, 3);

    printf("\n");

    Pos(COL_MAP+5, 4);

    printf("速度越快 得分越高哦!!\n");

    Map();

    InitSnake();

    CreateFood();

    }

    else if(GetAsyncKeyState(VK_ESCAPE))

    {

    exit(0);

    }

    }

    int IsCrossWall() //判断是否碰到墙

    {

    if(head->x <= 0 || head->x >= ROW_MAP-1

    ||head->y <= 1 || head->y >= COL_MAP-2)

    {

    State = ERROR_WALL;

    return 0;

    }

    return 1;

    }

    int IsEatSelf(pSnake newHead) //判断是否咬到自己

    {

    pSnake cur = head;

    assert(newHead);

    while(cur)

    {

    if(cur->x == newHead->x && cur->y == newHead->y)

    {

    State = ERROR_SELF;

    return 0;

    }

    cur = cur->next;

    }

    return 1;

    }

    int IsFood(pSnake pos) //判断该位置是不是食物

    {

    assert(pos);

    if(pos->x == Food->x && pos->y == Food->y)

    {

    return 1;

    }

    return 0;

    }

    void SnakeMove() //蛇移动一次

    {

    pSnake newHead = NULL;

    newHead = (pSnake)malloc(sizeof(Snake));

    if(Direction == R)

    {

    newHead->x = head->x;

    newHead->y = head->y+1;

    newHead->next = head;

    }

    else if(Direction == L)

    {

    newHead->x = head->x;

    newHead->y = head->y-1;

    newHead->next = head;

    }

    else if(Direction == U)

    {

    newHead->x = head->x-1;

    newHead->y = head->y;

    newHead->next = head;

    }

    else if(Direction == D)

    {

    newHead->x = head->x+1;

    newHead->y = head->y;

    newHead->next = head;

    }

    if(IsFood(newHead))

    {

    head = newHead;

    PrintSnake();

    CreateFood();

    Score += everyScore;

    Pos(COL_MAP+20, 1);

    printf("%d/%d", Score, SUCCESS_SCORE);

    if(Score >= SUCCESS_SCORE)

    {

    State = SUCCESS;

    }

    }

    else

    {

    if(IsCrossWall() && IsEatSelf(newHead))

    {

    pSnake cur = NULL;

    head = newHead;

    cur = head;

    //删除蛇尾并打印

    while(cur->next->next != NULL)

    {

    Pos(cur->y, cur->x);

    printf("%c", snake);

    cur = cur->next;

    }

    Pos(cur->y, cur->x);

    printf("%c", snake);

    Pos(cur->next->y, cur->next->x);

    printf(" "); //打印空格来覆盖频幕上的蛇尾

    free(cur->next);

    cur->next = NULL;

    }

    else

    {

    free(newHead);

    newHead = NULL;

    }

    }

    }

    void Pause()

    {

    while(1)

    {

    Sleep(sleeptime);

    if(GetAsyncKeyState(VK_SPACE))

    {

    break;

    }

    }

    }

    void ControlSnake() //用键盘控制游戏

    {

    if(GetAsyncKeyState(VK_UP) && Direction!=D)

    {

    Direction = U;

    }

    else if(GetAsyncKeyState(VK_DOWN) && Direction!=U)

    {

    Direction = D;

    }

    else if(GetAsyncKeyState(VK_LEFT) && Direction!=R)

    {

    Direction = L;

    }

    else if(GetAsyncKeyState(VK_RIGHT) && Direction!=L)

    {

    Direction = R;

    }

    else if(GetAsyncKeyState(VK_F1))

    {

    if(sleeptime != 500)

    {

    sleeptime = 500;

    everyScore = 1;

    Pos(COL_MAP+20, 2);

    printf("%d", everyScore);

    }

    }

    else if(GetAsyncKeyState(VK_F2))

    {

    if(sleeptime != 300)

    {

    sleeptime = 300;

    everyScore = 2;

    Pos(COL_MAP+20, 2);

    printf("%d", everyScore);

    }

    }

    else if(GetAsyncKeyState(VK_SPACE))

    {

    Pause();

    }

    else if(GetAsyncKeyState(VK_ESCAPE))

    {

    exit(0);

    }

    }

    void StateGame() //判断游戏失败或成功

    {

    if(State == ERROR_SELF)

    {

    system("cls");

    printf("很遗憾,蛇咬到自己,游戏失败!\n");

    }

    else if(State == ERROR_WALL)

    {

    system("cls");

    printf("很遗憾,蛇碰到墙壁,游戏失败!\n");

    }

    else if(State == SUCCESS)

    {

    system("cls");

    printf("恭喜您,已通关!!!\n");

    }

    }

    void RunGame()

    {

    Direction = R; //蛇初始行走方向为右

    State = NORMAL;//游戏初始为正常状态

    while(1)

    {

    ControlSnake();

    SnakeMove();

    if(State != NORMAL)

    {

    StateGame();

    break;

    }

    Sleep(sleeptime);

    }

    }

    void EndGame() //释放链表并恢复默认值

    {

    pSnake cur = head;

    while(cur)

    {

    pSnake del = cur;

    cur = cur->next;

    free(del);

    del = NULL;

    }

    head = NULL;

    if(Food != NULL)

    {

    free(Food);

    Food = NULL;

    }

    Score = 0;

    everyScore = 1;

    sleeptime = 500;

    }

    3.Test.c

    #include "Snake.h"

    int main()

    {

    while(1)

    {

    StartGame();

    RunGame();

    EndGame();

    }

    system("pause");

    return 0;

    }

    五、运行界面展示

    1.欢迎界面

    1c66302ba75c46aaa713f7507e21baaf.png

    2.游戏界面

    e21f67a94a949299241eb5155e5e2fb6.png

    小小的c语言项目,用来练手,仅供参考哦!!

    谢谢阅读,如有问题,欢迎提出。

    更多有趣的经典小游戏实现专题,分享给大家:

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

    展开全文
    weixin_36036271 2021-05-19 13:21:30
  • weixin_35707846 2021-05-23 02:14:25
  • weixin_36327582 2021-05-20 08:27:41
  • weixin_43474701 2021-07-26 11:39:52
  • weixin_34683262 2021-06-08 10:21:56
  • qq_59708493 2021-10-02 08:35:24
  • weixin_29927965 2021-05-19 12:00:15
  • weixin_30817835 2021-05-22 10:06:31
  • weixin_29210727 2021-05-19 20:23:16
  • weixin_28881787 2021-05-19 18:48:47
  • weixin_51563198 2021-11-24 17:34:46
  • weixin_39795479 2021-05-19 20:37:01
  • weixin_29346059 2021-05-23 05:04:21
  • weixin_34581040 2021-05-23 10:25:52
  • weixin_29361879 2021-05-25 08:24:59
  • xiaoqianqian88 2021-01-05 19:19:32
  • weixin_39613839 2021-01-17 15:43:42
  • weixin_36436683 2021-05-25 02:33:58
  • weixin_31653645 2020-12-23 13:47:55
  • weixin_29000891 2021-05-19 03:48:55
  • weixin_39968760 2021-05-23 04:37:38
  • weixin_42511712 2021-05-23 06:11:02
  • weixin_42348233 2021-05-20 05:26:55
  • weixin_35339622 2021-05-24 00:58:05

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 69,443
精华内容 27,777
关键字:

c语言小游戏大全

c语言 订阅