感覺編程無聊么,感覺玩別人的游戲索然無味,快來這里看看,走過路過別錯過,
在這里你可以成為一個異世界的勇者,可以是都市里的一個拯救世界的主人公,你還可以是一個開始打了敗仗的主人公然后轉生(這個就可以自己在前面加一個劇情并把戰斗的函式呼叫一遍),

只能輸1進入游戲,和其他數字退出游戲(因為還沒學有關網路的知識)

輸入名字階段其實沒什么用因為沒有聯機功能

因為沒想到什么功能就把去xx加是分別加攻擊力,防御力,生命值
0是可以離開勇者村

123456的地方都是一樣的但是可以在源代碼處修改的
awsd是移動,根據移動的步數隨機遇到怪物
下面就是戰斗的場景(有億點簡陋)


勝利了就回到地圖界面
走到括號就可以退出了(因為沒有限制地圖大小會出現億些小Bug)
游戲大概就是這樣了,

代碼在下面(這是我第一次做的東西有的地方有缺陷,因為臨近期末就沒有去改了,謝謝大家理解):
#include <iostream>
#include<string>
#include <conio.h>
#include<cstdlib>
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;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/394092.html
標籤:其他
上一篇:舍友僅僅打了一把游戲,我就學會了如何找鏈表的中間結點
下一篇:語音排隊叫號系統原始碼
