大家好我是你们的随机更作者——Paul 孙;
我今天分享一下我编的游戏;
(本来想用viod函数的,发现不太会用只能这样了😁)
#include<bits/stdc++.h>
#include<windows.h>
#include<ctime>
#include<cstdlib>
using namespace std;
//struct定义玩家信息
struct player{
string name;
int heart;
int EX;
}sc;
//struct定义怪兽信息
struct monster{
int heart;
int time;
}po;
//定义随机数函数
int generateRandomNumber(int min, int max) {
srand(time(0));
int random_number = rand() % (max - min + 1) + min;
return random_number;
}
int main(){
MessageBox(0,"本产品属于??工作室旗下!","您好!",64+MB_OK);//弹出弹窗
//弹窗判断
if(MessageBox(0,"是否开始使用?","您好!",32+MB_YESNO)==6){
MessageBox(0,"Plast copart1.0首测!"," ",64+MB_OK);//弹出弹窗
Sleep(100);
//输出介绍(信息)
cout<<"***********************"<<endl;
Sleep(100);
cout<<"欢迎来到Plast copart1.0"<<endl;
Sleep(100);
cout<<"本游戏由????工作室出品!"<<endl;
Sleep(100);
cout<<"***抵制盗版,从我做起***"<<endl;
Sleep(100);
cout<<"***********************"<<endl;
Sleep(100);
cout<<"*****制作人:?*****"<<endl;
Sleep(100);
cout<<"***********************"<<endl;
Sleep(100);
cout<<"请输入姓名:";
getline(cin,sc.name);
Sleep(100);
cout<<"请输入难度:";
int mos;
cin>>mos;
cout<<endl;
int a,b;//定义大小 (a,b)
//for嵌套实现
for(int i=1;i<=mos;i++){
po.time=i-1;
cout<<"恭喜你闯到到了第"<<i<<"关"<<endl;//客套话
if(i==mos){
cout<<"同样也是最后一关!!!"<<endl;
}
Sleep(100);
//输出怪物形态
cout<<" //---------\\"<<endl;
Sleep(100);
cout<<" || ||"<<endl;
Sleep(100);
cout<<" || o o ||"<<endl;
Sleep(100);
cout<<" //||-----||\\"<<endl;
Sleep(100);
cout<<"//----v---v----\\"<<endl;
Sleep(100);
cout<<"vv||---------||vv"<<endl;
Sleep(100);
cout<<" ||---[ ]---||"<<endl;
Sleep(100);
cout<<" ||---| |---||"<<endl;
Sleep(100);
cout<<" ||---| |---||"<<endl;
Sleep(100);
cout<<" ||---| |---||"<<endl;
Sleep(100);
cout<<" ||---| |---||"<<endl;
Sleep(100);
cout<<"_______| |_______"<<endl;
Sleep(100);
cout<<"LV:"<<i<<endl;
Sleep(100);
//回合开始
po.heart=i*100;
int ms=1;
sc.EX=0;
sc.heart=1000;
while(po.time>=0&&po.heart>0||sc.heart>0){
sc.EX++;
//判断
char sime;
if(ms%2==1){
cout<<sc.name<<"的回合!!!"<<endl;
Sleep(100);
//开始输入
cout<<"请输入(a普攻,s暴击(普攻>=3),d防御,f躲闪,g跳过,m技能(普攻>=3)):";
cin>>sime;
if(sime=='a'){
cout<<"普攻-5"<<endl;
po.heart=po.heart-5;
}else if(sime=='s'){
if(sc.EX>=3){
int random_number=generateRandomNumber(10,i*100-16);
po.heart=po.heart-random_number;
cout<<"暴击"<<"-"<<random_number<<endl;
MessageBox(0,"暴击!","干得好!",64+MB_OK);//弹出弹窗
}else{
Sleep(100);
cout<<"无效"<<"-"<<0<<endl;
MessageBox(0,"接受审判之罪!!!","",64+MB_OK);//弹出弹窗
}
}else if(sime=='m'){
char aime;
if(sc.EX>=3){
Sleep(100);
cout<<"请选择技能(q大招,e平推):";
cin>>aime;
if(aime=='q'){
int random_number1=generateRandomNumber(10,200);
cout<<"大招-"<<random_number1<<endl;
po.heart=po.heart-random_number1;
}else if(aime=='e'){
cout<<"平推-25"<<endl;
po.heart=po.heart-25;
}
}else{
Sleep(100);
cout<<"无效"<<"-"<<0<<endl;
MessageBox(0,"接受审判之罪!!!","",64+MB_OK);//弹出弹窗
}
}
if(po.heart==0&&po.time>0){
po.time=po.time-1;
po.heart=i*100;
}
}else{
cout<<"怪兽的回合!!!"<<endl;
if(po.time==0&&po.heart<=0){
break;
}else{
int random_number2=generateRandomNumber(12,(i*143-87)/2);
if(sime=='d'){
sc.heart=sc.heart-1;
cout<<"普攻-1"<<endl;
}else if(sime=='f'){
int random_number3=generateRandomNumber(1,1000);
if(random_number3%2==0){
sc.heart=sc.heart;
cout<<"真幸运!!"<<endl;
cout<<"无效-0"<<endl;
}
}else{
sc.heart=sc.heart-random_number2;
cout<<"普攻-"<<random_number2<<endl;
}
}
if(sc.heart<=0){
MessageBox(0,"你输了!","你输了这一局!",32+MB_OK);
return 0;
}
}
ms++;
cout<<"怪兽"<<"血量为"<<po.heart<<endl;
cout<<"怪兽"<<"复活次数为"<<po.time<<endl;
cout<<sc.name<<"血量为"<<sc.heart<<endl;
}
if(i==mos){
MessageBox(0,"您赢了!","您赢了这一局!",32+MB_OK);
}else{
MessageBox(0,"希望再赢一次!","你赢了这一局!",32+MB_OK);
}
}
}else{
MessageBox(0,"再见!","欢迎下次再见!",32+MB_OK);//告别提示
return 0;//结束代码
}
return 0;//结束代码
}