C++里的Getch()想必大家都不陌生,
char c=getch()
运用二位数组也可以创建地图
int Map[19][19];
再加上玩家的坐标和诸多变量
using namespace std;
struct crood
{
int x,y;
}player;
int money=0;
char c;
int temp,dir,mon=1,turn=0;
随机数&头文件
#include#include #include #include //... int po; //... srand(time(NULL)); po=rand%21+1;
就组成了“贪财虫” [doge]
下方主程序↓
int main()
{
temp=rand()%21;
dir=rand()%21;
srand(time(NULL));
player.x=0;player.y=0;
while(1){
system("cls");
time_t now = time(0);
tm *ltm = localtime(&now);
cout << "金币:" << money << " 时间:" << ltm->tm_hour << ":"<tm_min << ":"<tm_sec << endl;
cout << "# # # # # # # # # # # # # # # # # # # # # ##"<0)
{
if(c=='w')player.x--;
}
if(player.y>0)
{
if(c=='a')player.y--;
}
if(player.x<20)
{
if(c=='s')player.x++;
}
if(player.y<20)
{
if(c=='d')player.y++;
}
if(c=='p')
{
cout << "暂停";
getch();
}
turn++;
}
return 0;
}
你说什么?康不懂?不阔能的



