栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

贪财虫(奇怪的游戏增加了)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

贪财虫(奇怪的游戏增加了)

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;
}

你说什么?康不懂?不阔能的

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/868927.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号