没写完的游戏框架,大家帮我找找bug

C班-杨渔  •  13天前


//The World Before The Earth原创 
#include <iostream>
#include <algorithm>
#include <windows.h>
#include <conio.h>
#include <cstring>
using namespace std;
//
void print(const char s[],int speed=30)
{
	int len=strlen(s);
	for (int i=0;i<len;++i)
	{
		printf("%c",s[i]);
		Sleep(speed);
	}
}
//


void __playTheGame()
{
	
}
//
string name,password;
void __Begin()
{
	name="";password="";
	system("color 0d");
	char s[50]="The World Before The Earth";
	printf("『』\n");
	Sleep(100);
	for (int i=0;i<=25;++i)
	{
		system("cls");
		printf("『");
		for (int j=0;j<=i;++j)
			putchar(s[j]);
		printf("』\n");
		Sleep(50);
	}
	int tmp=15;
	printf("光速加载中......\n");
	while (tmp--)
	{
		system("color 9b");
		printf(">");
		Sleep(50);
		system("color 1a");
		printf(">");
		Sleep(50);
	}
	system("color 0d");
}
void __getAdminster()
{
	system("cls");
	printf("『The World Before The Earth』\n");
	printf("  输入1登录 输入2注册新账号:\n  ");
	int tmp;scanf("%d",&tmp);
	if (tmp==1)
	{
		
	}
	else
	{
		
	}
}
int __ownPage()
{
	system("cls");
	char c,s[10][20]={"",
					"开始游戏",
					"颜色设置",
					"读取存档",
					"存档状态",
					"更改密码",
					"退出游戏"
					};
	int id=1;
	while (true)
	{
		system("cls");
		printf("用户%s\n",name.data());
		for (int i=1;i<=6;++i)
		{
			if (id==i) printf("→|");
			else printf(" |");
			printf("%s\n",s[i]);
		}
		printf("注意:退出游戏必须要在游戏里退出,务必\n");
		printf("     不要在外部关闭窗口,否则有可能造\n");
		printf("     成数据丢失!!!\n");
		c=getch();
		if (c=='w' && id>1) --id;
		if (c=='s' && id<6) ++id;
		if (c<'a'||c>'z') break;
	}
	//
	return id;
}
void __changeColor()
{
	char b[10]="color 0d";
	char ch[20]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
	int id=1,id1=0,id2=13;
	char s[20][20]={
		"   黑色   ",
		"   蓝色   ",
		"   绿色   ",
		"  浅绿色  ",
		"   红色   ",
		"   紫色   ",
		"   黄色   ",
		"   白色   ",
		"   灰色   ",
		"  淡蓝色  ",
		"  淡绿色  ",
		" 淡浅绿色 ",
		"  淡红色  ",
		"  淡紫色  ",
		"  淡黄色  ",
		"  亮白色  "};
	//
	char c;
	while (true)
	{
		system("cls");
		printf("背景色  前景色\n");
		for (int i=0;i<16;++i)
		{
			if (id1==i) printf("→");
			else printf("  ");
			printf("%s",s[i]);
			if (id2==i) printf("←");
			else printf("  ");
			printf("\n");
		}
		c=getch();
		if (c<'a'||c>'z') return;
		else if (c=='a') id=1;
		else if (c=='d') id=2;
		else if (id==1)
		{
			if (c=='w' && id1>0) --id1;
			if (c=='s' && id1<15) ++id1;
		}
		else if (id==2)
		{
			if (c=='w' && id2>0) --id2;
			if (c=='s' && id2<15) ++id2;
		}
		b[6]=ch[id1];
		b[7]=ch[id2];
		system(b);
	}
	
}
void __chooseFile()
{
	
}
void __uploadFile()
{
	
}
void __changePassword()
{
	
}
void __outTheGame()
{
	
}
int main()
{
	__Begin();
	__getAdminster();
	while (true)
	{
		int id=__ownPage();
		if (id==1) __playTheGame();
		else if (id==2) __changeColor();
		else if (id==3) __chooseFile();
		else if (id==4) __uploadFile();
		else if (id==5) __changePassword();
		else
		{
			__outTheGame();
			exit(0);
		}
	}
	return 0;
}

评论: