📄 head.cpp
字号:
#include"head.h"
#include<iostream>//输入输出流
#include"CRole.h"
#include"Color.h"
using namespace std;
color c;
CRole k;
extern mygame call;//调用已经声明的对象
mygame::mygame()
{
wupin1="强化乌龙剑 ";//物品
wupin2=" ";
wupin3=" ";
wupin4=" ";
wupin5=" ";
zhuangtai=0;
}
mygame::~mygame()
{
}
void mygame::image(char a[],int b)//提示玩家输入信息(单个输出)
{
for(int i=0;i<b;i++)
{
cout<<a[i];
Sleep(10);
}
}
void mygame::user()//用户名及密码输入
{
c.anlvse();
cout<<"欢迎来到游戏世界!"<<endl;
cout<<"你的用户名为:lilinjie"<<endl;
cout<<"你的密码为:123456\n"<<endl;
comein=1;
while(comein){
c.baise();
call.image("请输入用户名:",14);
c.qingse();
cin>>inName;//接收用户输入的用户名
char name[]="lilinjie";
int OK1 = strcmp(inName,name);//判断输入的用户名和服务器上的是否一样
if(OK1==0)//如果用户名正确
{
c.anhuangse();
cout<<"用户名输入正确\n"<<endl;
c.baise();
A: call.image("请输入密码:",12);
char code[] = "123456";
c.qingse();
cin>>inCode;//接收密码
int OK2 = strcmp(inCode,code);//判断输入的密码和服务器上的是否一样
if(OK2==0)//如果密码正确
{
c.anhuangse();
cout<<"密码输入正确\n"<<endl;
comein=0;
}else
{
c.Hongse();
cout<<"密码输入错误,请重新输入!\n"<<endl;
goto A;
}
}else
{
c.Hongse();
cout<<"用户名输入错误,请重新输入!\n"<<endl;;
}
}
}
void mygame::jiaose()//角色
{
c.lvse();
cout<<"进入游戏前需要创建你的人物昵称,天性选择,性别选择。"<<endl;
cout<<"\n"<<endl;
c.anbaise();
call.image("请输入你想创建的昵称(中英文均可):",36);
c.qingse();//昵称颜色
cin>>inNickName;
cout<<"\n"<<endl;
c.huangse();
cout<<"人物昵称";
c.qingse();
cout<<" 【"<<inNickName<<"】 ";
c.huangse();
cout<<"创建成功\n"<<endl;
strcpy(k.player,inNickName);
comein=1;
while(comein){
c.Hongse();
cout<<"请选择你的天性:\n"<<endl;
c.anbaise();
cout<<"1:阴险奸诈"<<" 2:光明磊落"<<" 3:狡猾多变"<<" 4:心狠手辣"<<" 5:无恶不做\n"<<endl;
cin>>M;
switch(M[0])
{
c.baise();
case '1':
cout<<" 阴险奸诈的 ";
c.huangse();
cout<<"【"<<inNickName<<"】~!.\n"<<endl;
comein=0;
break;
case '2':
cout<<" 光明磊落的 ";
c.qingse();
cout<<"【"<<inNickName<<"】~~.\n"<<endl;
comein=0;
break;
case '3':
cout<<" 狡猾多变的 ";
c.huangse();
cout<<"【"<<inNickName<<"】~~.\n"<<endl;
comein=0;
break;
case '4':
cout<<" 心狠手辣的 ";
c.huangse();
cout<<"【"<<inNickName<<"】!!.\n"<<endl;
comein=0;
break;
case '5':
cout<<" 无恶不做的 ";
c.huangse();
cout<<"【"<<inNickName<<"】!!.\n"<<endl;
comein=0;
break;
c.Hongse();
default:cout<<"错误!\n"<<endl;
}
}
comein=1;
while(comein){
c.Hongse();
cout<<"选择你要扮演的角色性别:男";
c.huangse();
cout<<"(g)";
c.Hongse();
cout<<"女";
c.huangse();
cout<<"(m)."<<endl;
cin>>M;
c.baise();
if(M[1]==NULL){
switch(M[0])
{
case 'g':
cout<<"性别:男\n"<<endl;
comein=0;
break;
case 'm' :
cout<<"性别:女\n"<<endl;
comein=0;
break;
default:cout<<"现在没有太监的分类~~!\n"<<endl;
}
}else
{
cout<<"现在还没有太监的分类~~!\n"<<endl;
}
}
c.baise();
c.huangse();
call.image(" 昵称:",6);
cout<<inNickName;
if(nature[0]=='1')
call.image(" 天性:阴险奸诈",17);
if(nature[0]=='2')
call.image(" 天性:光明磊落",17);
if(nature[0]=='3')
call.image(" 天性:狡猾多变",17);
if(nature[0]=='4')
call.image(" 天性:心狠手辣",17);
if(nature[0]=='5')
call.image(" 天性:无恶不做",17);
if(M[0]=='g')
call.image(" 性别: 男",15);
if(M[0]=='m')
call.image(" 性别: 女",13);
cout<<"\n"<<endl;
c.baise();
cout<<"==============================================="<<endl;
call.zhuangtai=1000;
k.shuxing();
}
void mygame::wenben( )//游戏介绍
{
FILE *p;//文本指针
char w;//接 入字符串
p=fopen(".\\world.ini","r");//r是读字符串
if(p==NULL)
{
cout << "阅读文件出错"<<endl;
}
while(true)
{
w=fgetc(p);//得到文本里面的字符串给w;
if(w!=EOF)//如果得到的字符不结束。。。。。
{
c.qingse();
cout<<w;
Sleep(5);//文字显示速度
}else
{
cout<<"\n"<<endl;
break;
}
}
}
void mygame::shuoming()//菜单
{
c.huangse();
cout<<" ***************";
c.Hongse();
cout<<" 欢迎";
c.qingse();
cout<<" 【"<<inNickName<<"】 ";
c.Hongse();
cout<<"进入游戏世界!";
c.huangse();
cout<<" ***************"<<"\n";
c.qingse();
cout<<"【"<<inNickName<<"】 ";
c.lvse();
cout<<"你好:"<<endl;;
call.image(" 欢迎来到游戏.",16);
cout<<"\n"<<endl;
c.qingse();
call.image(" 你现在的位置是",16);
c.anHongse();
cout<<"新手村";
c.qingse();
call.image("肩负着改变人类命运的使命!",26);
cout<<endl;
call.image(" 提升自己的法力!消灭魔族,挽救世界!!",38);
cout<<""<<endl;
cout<<" --------算是挽救世界吧~~~!真不知道该写什么好~!---------"<<endl;
call.image(" 招数道行可以在蓬莱(乌龙)大理(铁鹰)祝融地(无虑) 学会。",58);
cout<<""<<endl;
call.image(" 法术道行可以在蓬莱(无忧)大理(无欢)祝融地(寇神官) 学会。",64);
cout<<"\n"<<endl;
cout<<" 新手村";
call.image("有七条路分别通往",16);
c.huangse();
call.image(": 蓬莱 大理 帝王陵 死亡金山 占卜圣地 祝融地 勇士之谷",52);
cout<<"\n"<<endl;
c.qingse();
call.image(" 每条路上都有可能出现怪物,并有生命危险!",42);
cout<<"\n"<<endl;
}
void mygame::caidan(){
B: c.Lanse();
cout<<"菜单选择";cout<<"\n"<<endl;
c.anzise();
cout<<" ◆◆◆◆◆◆◆◆◆"<<"\n"<<endl;
c.huangse();
cout<<" s: ";
c.Hongse();
cout<<"开始游戏";cout<<"\n"<<endl;
c.huangse();
cout<<" h: ";
c.Hongse();
cout<<"游戏帮助";cout<<"\n"<<endl;
c.huangse();
cout<<" k: ";
c.Hongse();
cout<<"物品查看";cout<<"\n"<<endl;
c.huangse();
cout<<" m: ";
c.Hongse();
cout<<"查看地图";cout<<"\n"<<endl;
c.huangse();
cout<<" b: ";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -