感觉编程无聊么,感觉玩别人的游戏索然无味,快来这里看看,走过路过别错过。
在这里你可以成为一个异世界的勇者,可以是都市里的一个拯救世界的主人公,你还可以是一个开始打了败仗的主人公然后转生(这个就可以自己在前面加一个剧情并把战斗的函数调用一遍)。
只能输1进入游戏,和其他数字退出游戏(因为还没学有关网络的知识)
输入名字阶段其实没什么用因为没有联机功能
因为没想到什么功能就把去xx加是分别加攻击力,防御力,生命值
0是可以离开勇者村
awsd是移动,根据移动的步数随机遇到怪物
下面就是战斗的场景(有亿点简陋)
走到括号就可以退出了(因为没有限制地图大小会出现亿些小Bug)
游戏大概就是这样了。
代码在下面(这是我第一次做的东西有的地方有缺陷,因为临近期末就没有去改了,谢谢大家理解):
#include
#include
#include
#include
using namespace std;
struct m_head
{
double h_atk;
double h_fyl;
double h_smz;
};
struct m_xbbh
{
double x_atk;
double x_fyl;
double x_smz;
};
struct m_tbbh
{
double t_atk;
double t_fyl;
double t_smz;
};
struct m_xz
{
double z_atk;
double z_fyl;
double z_smz;
};
struct m_Person
{
string m_name;
double atk;
double fyl;
double smz;
struct m_head a ;
struct m_xbbh b;
struct m_tbbh c;
struct m_xz d;
};
void showmean()
{
cout << "**********************" << endl;
cout << "***** 1,进入游戏 *****" << endl;
cout << "***** 2,看什么看 *****" << endl;
cout << "***** 3,别看了呀 *****" << endl;
cout << "***** 4,快点击11 *****" << endl;
cout << "***** 5,快快快快 *****" << endl;
cout << "***** 6,邀请好友 *****" << endl;
cout << "***** 0,退出游戏 *****" << endl;
cout << "**********************" << endl;
}
void showmean1()
{
cout << "************************" << endl;
cout << "***** 1,进入铁匠铺 *****" << endl;
cout << "***** 2,进入村长家 *****" << endl;
cout << "***** 3,进入小翠家 *****" << endl;
cout << "***** 4,进入小埋家 *****" << endl;
cout << "***** 5,进入蕾姆家 *****" << endl;
cout << "***** 6,回去自己家 *****" << endl;
cout << "***** 0,离开勇者村 *****" << endl;
cout << "************************" << endl;
}
void showmean2()
{
cout << "************************" << endl;
cout << "***** 1,进入下水道 *****" << endl;
cout << "***** 2,进入小树林 *****" << endl;
cout << "***** 3,进入爱琴海 *****" << endl;
cout << "***** 4,进入天空岛 *****" << endl;
cout << "***** 5,进入火焰山 *****" << endl;
cout << "***** 6,进入寒冷地 *****" << endl;
cout << "***** 0,回去勇者村 *****" << endl;
cout << "************************" << endl;
}
int atkmean(m_Person * xph, double *xl)
{
cout << "******************" << endl;
cout << "***** 1,斩击 *****" << endl;
cout << "***** 2,光波 *****" << endl;
cout << "***** 3,防御 *****" << endl;
cout << "***** 4,闪避 *****" << endl;
cout << "***** 0,逃跑 *****" << endl;
cout << "******************" << endl;
int select;
double atk;
cin >> select;
atk = xph->atk;
while (select)
{
system("cls");
cout << "******************" << endl;
cout << "***** 1,斩击 *****" << endl;
cout << "***** 2,光波 *****" << endl;
cout << "***** 3,防御 *****" << endl;
cout << "***** 4,闪避 *****" << endl;
cout << "***** 0,逃跑 *****" << endl;
cout << "******************" << endl;
switch (select)
{
case 1:
*xl = *xl - (atk*0.5 + 10);
cout << "你攻击了敌人并造成" << atk * 0.5 + 10 << endl;
cout << "敌人血量还剩下" << *xl << endl;
if (*xl > 0)
{
cout << "你受到敌人的攻击" << endl;
xph->smz = xph->smz - 20;
cout << "你还剩下" << xph->smz << endl;
}
else
return 1;
break;
case 2:
*xl = *xl - (atk*0.6 + 10);
cout << "你攻击了敌人并造成" << atk * 0.6 + 10 << endl;
cout << "敌人血量还剩下" << *xl << endl;
if (*xl > 0)
{
cout << "你受到敌人的攻击" << endl;
xph->smz = xph->smz - 20;
cout << "你还剩下" << xph->smz << endl;
}
else
return 1;
break;
case 3:
xph->smz = xph->smz - 20 * xph->fyl*0.5;
cout << "你受到敌人的攻击" << endl;
cout << "你还剩下" << xph->smz << endl;
break;
case 4:
cout << "你闪开了对方的攻击" << endl;
break;
case 0:
cout << "你离开了战场" << endl;
return 1;
break;
default:
break;
}
if (xl <= 0)
return 1;
if (xph->smz <= 0)
return -1;
}
}
int guaiwu (m_Person * xph)
{
double xl = 100;
system("cls");
cout << "你遇到一个敌人耶,这都被你碰上了" << endl;
system("pause");
cout << "下水道太脏了你行动受到限制后手攻击" << endl;
cout << "敌人嘲讽了你" << endl;
cout << "到你攻击了" << endl;
if (xl > 0 && xph->smz)
atkmean(xph, &xl);
else if (xl <= 0)
return -1;
else if (xph->smz <= 0)
return 1;
}
void showdt(m_Person *xph)
{
int m_y = 30;
int m_x = 20;
void yzc(m_Person *xph);
char per;
int x=1, y=1,i=0;
int a = rand() % 20;
while (1)
{
void ddt(m_Person *xph);
system("cls");
cout << "出口" << endl;
cout << "( )" << endl;
for (int x = 0; x <= m_x; x++)
{
cout << endl;
for (int y = 0; y <= m_y; y++)
{
cout << " ";
}
}
cout << "*";
if (i == a)
{
if (guaiwu(xph) == -1)
{
cout << "你已经挂了正在返回勇者村" << endl;
xph->smz = 1000;
yzc(xph);
}
a = rand() % 20;
}
if (m_x == 0 && m_y == 0)
{
system("cls");
cout << "恭喜你回到大地图" << endl;
showmean2();
ddt(xph);
}
per = _getch();
if (per == 'w')
{
m_x = m_x - 1;
i++;
}
else if (per == 's')
{
m_x = m_x + 1;
i++;
}
else if (per == 'a')
{
m_y = m_y - 1;
i++;
}
else if (per == 'd')
{
m_y = m_y + 1;
i++;
}
}
}
void csh(m_Person *xph)
{
xph->a.h_atk = 20;
xph->a.h_fyl = 20;
xph->a.h_smz = 20;
xph->b.x_atk = 20;
xph->b.x_fyl = 20;
xph->b.x_smz = 20;
xph->c.t_atk = 20;
xph->c.t_fyl = 20;
xph->c.t_smz = 20;
xph->d.z_atk = 20;
xph->d.z_fyl = 20;
xph->d.z_smz = 20;
}
void Percsh(m_Person *xph)
{
xph->atk = xph->a.h_atk + xph->b.x_atk + xph->c.t_atk + xph->d.z_atk;
xph->fyl = xph->a.h_fyl + xph->b.x_fyl + xph->c.t_fyl + xph->d.z_fyl;
xph->smz = xph->a.h_smz + xph->b.x_smz + xph->c.t_smz + xph->d.z_smz;
}
void showperson(m_Person *xph)
{
cout << "你的攻击力为" << xph->atk << endl;
cout << "你的防御力为" << xph->fyl << endl;
cout << "你的生命值为" << xph->smz << endl;
}
void changename(m_Person *xph)
{
string name;
cout << "已经为你创造了一位五星角色" << endl;
cout << "请输入你的名字" << endl;
cin >> name;
xph->m_name = name;
cout << "你的名字为" << xph->m_name << endl;
}
void jqjj()
{
cout << "剧情简介" << endl;
cout << "恭喜你诞生在勇者村,在你出生后你的家人离你而去然后你就不知道怎么就长大了" << endl;
cout << "现在你什么都没有但是这个世界上并不太平有许多的怪物要等着你去拯救" << endl;
}
void ddt(m_Person *xph)
{
void yzc(m_Person *xph);
system("cls");
showmean2();
int select;
cin >> select;
switch (select)
{
case 1:
system("cls");
showdt(xph);
break;
case 2:
system("cls");
showdt(xph);
break;
case 3:
system("cls");
showdt(xph);
break;
case 4:
system("cls");
showdt(xph);
break;
case 5:
system("cls");
showdt(xph);
break;
case 6:
system("cls");
showdt(xph);
break;
case 0:
system("cls");
yzc(xph);
break;
}
}
void yzc(m_Person *xph)
{
int selcet;
cout << "你现在在勇者村" << endl;
showmean1();
cin >> selcet;
while (selcet)
{
cin >> selcet;
switch (selcet)
{
case 1:
xph->atk = xph->atk + 20;
cout << "攻击力加20" << endl;
cout << "角色攻击力为" << xph->atk << endl;
break;
case 2:
xph->fyl = xph->fyl + 20;
cout << "防御力加20" << endl;
cout << "角色防御力为" << xph->fyl << endl;
break;
case 3:
xph->smz = xph->smz + 20;
cout << "生命值加20" << endl;
cout << "角色生命值为" << xph->smz << endl;
break;
case 4:
xph->atk = xph->atk + 40;
cout << "攻击力加40" << endl;
cout << "角色攻击力为" << xph->atk << endl;
break;
case 5:
xph->fyl = xph->fyl + 40;
cout << "防御力加40" << endl;
cout << "角色防御力为" << xph->fyl << endl;
break;
case 6:
xph->smz = xph->smz + 40;
cout << "生命值加40" << endl;
cout << "角色生命值为" << xph->smz<< endl;
break;
default:
break;
}
}
cout << "已经离开勇者村" << endl;
ddt(xph);
}
void m_xsd (m_Person *xph)
{
cout << "你已经来到下水道,这里有点脏,你的反应变快了,但是畏手畏脚防御力下降了" << endl;
xph->fyl = xph->fyl - 20;
showdt(xph);
cout << "你已经离开下水道,你已经恢复了" << endl;
xph->fyl = xph->fyl + 20;
}
int main()
{
showmean();
int a;
cin >> a;
if (a == 1)
{
system("cls");
cout << "欢迎进入游戏" << endl;
m_Person xph;
csh(&xph);
Percsh(&xph);
changename(&xph);
showperson(&xph);
system("pause");
system("cls");
jqjj();
system("pause");
system("cls");
yzc(&xph);
}
else
{
cout << "欢迎下次游玩" << endl;
return 0;
}
}