用户:
萌新大佬查看:0 回复:0 评论:0 创建时间:2020-10-03T15:04:02
我的最新抓人游戏可以玩啦!
#include<iostream>
#include <conio.h>
#include <windows.h>
using namespace std;
int r[11][15]={
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
{2,1,0,0,0,0,0,0,0,0,0,0,0,0,2},
{2,0,0,0,0,0,0,0,0,0,0,0,0,0,2},
{2,0,0,0,0,0,0,0,0,0,0,0,0,0,2},
{2,0,0,0,0,0,0,0,0,0,0,0,0,0,2},
{2,0,0,0,0,0,0,0,0,0,0,0,0,0,2},
{2,0,0,0,0,0,0,0,0,0,0,0,0,0,2},
{2,0,0,0,0,0,0,0,0,0,0,0,0,0,2},
{2,0,0,0,0,0,0,0,0,0,0,0,0,0,2},
{2,0,0,0,0,0,0,0,0,0,0,0,0,3,2},
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}
};
int main()
{
int i,j,x=1,y=1,x_o=1,y_o=1,n=13,m=9,n_o=9,m_o=13;
char a,b;
while(1)
{
for(i=0;i<11;i++)
{
for(j=0;j<15;j++)
{
if(r[i][j]==0)cout<<" ";
else if(r[i][j]==2)cout<<"■";
else if(r[i][j]==3)cout<<"o ";
else cout<<"x ";
}
cout<<endl;
}
a=_getch();
x_o=x;
y_o=y;
n_o=n;
m_o=m;
if(a=='w')
{
y--;
if(r[y][x]==3)
{
system("cls");
cout<<"抓到了!!";
Sleep(1000);
return 0;
}
else if(r[y][x]!=0)y++;
}
else if(a=='s')
{
y++;
if(r[y][x]==3)
{
system("cls");
cout<<"抓到了!!";
Sleep(1000);
return 0;
}
else if(r[y][x]!=0)y--;
}
else if(a=='a')
{
x--;
if(r[y][x]==3)
{
system("cls");
cout<<"抓到了!!";
Sleep(1000);
return 0;
}
else if(r[y][x]!=0)x++;
}
else if(a=='d')
{
x++;
if(r[y][x]==3)
{
system("cls");
cout<<"抓到了!!";
Sleep(1000);
return 0;
}
else if(r[y][x]!=0)x--;
}
if(a==72)
{
m--;
if(r[m][n]!=0)m++;
}
else if(a==80)
{
m++;
if(r[m][n]!=0)m--;
}
else if(a==75)
{
n--;
if(r[m][n]!=0)n++;
}
else if(a==77)
{
n++;
if(r[m][n]!=0)n--;
}
r[y_o][x_o]=0;
r[y][x]=1;
r[m_o][n_o]=0;
r[m][n]=3;
system("cls");
}
}
自己看代码