c++双人战争小游戏

c++双人战争小游戏,第1张

       一个小游戏。

效果:

 

代码:

#include
#include
#define random(x) (rand()%x)
using namespace std;
int main() 
{
	srand((int)time(0));
	char b[20][20]={'-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-',
	               '-','.','.','.','|','.','.','.','.','.','.','.','.','|','.','.','.','.','.','-',
				   '-','.','|','.','|','.','.','.','.','.','.','.','|','.','.','.','.','.','.','-',
				   '-','.','|','.','|','.','.','.','.','|','.','|','.','.','.','.','.','.','.','-',
				   '-','.','|','.','|','.','.','.','.','.','|','.','.','.','.','.','.','.','.','-',
				   '-','|','|','.','|','.','.','.','.','.','.','|','.','|','|','|','|','.','.','-',
				   '-','.','.','.','|','.','.','.','.','.','.','.','.','|','.','.','|','.','.','-',
				   '-','.','.','.','|','.','.','.','|','.','.','.','.','|','.','.','|','|','.','-',
				   '-','.','.','|','.','|','.','.','|','.','.','.','.','|','.','.','|','.','.','-',
				   '-','.','.','.','.','|','.','.','|','|','|','|','.','|','.','.','|','.','.','-',
				   '-','.','.','.','.','|','.','.','|','.','.','.','.','|','.','.','|','.','.','-',
				   '-','|','|','.','.','|','.','.','|','.','.','.','.','.','.','.','.','.','.','-',
				   '-','.','|','.','.','|','.','.','|','.','.','.','.','.','.','.','.','|','|','-',
				   '-','.','|','.','.','.','.','.','.','.','.','.','.','.','.','.','.','|','.','-',
				   '-','.','|','|','.','.','|','.','.','.','.','.','|','.','.','|','.','|','.','-',
				   '-','.','.','.','.','|','.','.','.','.','.','.','|','.','.','|','.','|','.','-',
				   '-','.','.','.','|','|','|','|','|','|','.','.','|','|','|','|','.','|','.','-',
				   '-','.','.','|','.','.','.','|','.','.','.','|','.','.','.','.','.','|','.','-',
				   '-','.','|','.','.','.','.','.','.','.','|','.','.','.','.','.','.','.','.','-',
				   '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'};
    for(int i=0;i<20;i++)
    {
    	    for(int j=0;j<20;j++)
             cout<>a;
    system("cls");
    if(a==1)
    {
    	cout<<"1.随机传送至是.的方格"<f;  
           	if(op==1)
           	{
      		if(f=='g')
           		{
           			if(b[qw-1][er]=='B' ||b[qw+1][er]=='B'||b[qw][er+1]=='B' || b[qw][er-1]=='B'|| b[qw-1][er-1]=='B'|| b[qw+1][er-1]=='B'|| b[qw-1][er+1]=='B'|| b[qw+1][er+1]=='B' )
           			{
           				system("cls");
           				cout<<"击中!"<>k;
          
           	if(op==1)
           	{
          		if(k=='g')
           		{
           			if(b[ty-1][ui]=='A' ||b[ty+1][ui]=='A'||b[ty][ui+1]=='A' || b[ty][ui-1]=='A'|| b[ty-1][ui-1]=='A'|| b[ty+1][ui-1]=='A'|| b[ty-1][ui+1]=='A'|| b[ty+1][ui+1]=='A' )
           			{
           				system("cls");
           				cout<<"击中!"<

 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/674953.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-19
下一篇 2022-04-19

发表评论

登录后才能评论

评论列表(0条)