小游戏的名称:浴血奋战
内容你试试就知道了~
作者用了1周编了这个游戏。
版本1.0,分两个文件。
这是第1个文件:
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<conio.h>
#include<windows.h>
using namespace std;
int wood=0,stone=0,diamond=0,breakstone=0,meat=0,fars=100,live=100,hungry=100,things_do=0;
int fight=1,monster_life=66,real_live=100,real_hungry;
string user,wait_for_night="黑天倒计时",go_for_castle="前往城堡中";
string wepons[5]={"木剑","石剑","铁剑","钻石剑","世界崩解之剑"};
string monsters[4]={"变异僵尸","诡异蜘蛛","丛林巨人","末日幽灵"};
string animals[4]={"牛","猪","羊","鸡"};
void sleep_second(int s)
{
_sleep(1000*s);
}
void ko()
{
if(real_live<=0)
{cout<<user<<" 死了!游戏结束!";
sleep_second(60);}
}
void down_count(string action,int s)
{
for(int i=s;i>=0;i--)
{
cout<<action<<endl;
cout<<"剩余"<<i<<"秒";
sleep_second(1);
system("cls");
}
}
int rands()
{
srand(time(0));
return rand()%100;
}
void night()
{
int t=rands();
if(t<3)
{
cout<<"没想到你找到了一个传送门,你走了进去..."<<endl;
cout<<"[奖励]战斗力+5;生命值加满;距离-10。"<<endl;
real_live=100;
fight+=5;
fars-=10;
sleep_second(2);
cout<<"攻击力="<<fight<<"\n生命值=100\n距离="<<fars;
}
else
{
cout<<"真不巧,程序走丢了!(功能开发中)\n ××\n ___";
}
system("cls");
}
void find()
{
int t=rands();
if(t<50)
cout<<"呜呜,你什么都没有找到!";
else if(t<70)
{
cout<<"还可以,你找到了木头。";
wood++;
}
else if(t<85)
{
cout<<"不错,你找到了石头。";
stone++;
}
else if(t<90)
{
cout<<"很好,你找到了钻石!";
diamond++;
}
else
{
cout<<"厉害,你找到了崩解之石!";
breakstone++;
}
}
void information()
{
cout<<"游戏浴血奋战,版本1.1(内测中)。\n内部设置了外挂,可以在代码区里找一找如何使用外挂\n饥饿值尚未开始启用,请耐心等待\n按任意键继续...\n";
getch();
system("cls");
}
void food()
{
things_do++;
int t=rands();
if(t<20)
cout<<"你遇到了牛。";
else if(t<40)
cout<<"你遇到了猪。";
else if(t<60)
cout<<"你遇到了鸡。";
else if(t<80)
cout<<"你遇到了羊。";
else cout<<"你什么也没找到!";
if(t<80)
{
cout<<"疯狂拼杀中...";
sleep_second(5);
int t2=rands();
if(t2<50)
cout<<"你获得了1块肉\n";
else
cout<<"你获得了2块肉\n";
meat+=t2/49;
}
}
void maker()
{
things_do+1;
cout<<"请问你要合成?\n1:木剑\n2:石剑\n3:钻石剑\n4:世界崩解之剑\n";
int t;
cin>>t;
if(t==1)
if(wood>=5)
{
wood-=5;
cout<<"已合成木剑(自动使用)。"<<endl;
fight=max(fight,3);
}
else
cout<<"木头不够!";
if(t==2)
if(stone>=5)
{
stone-=5;
cout<<"已合成石剑(自动使用)。"<<endl;
fight=max(fight,5);
}
else
cout<<"石头不够!";
if(t==3)
if(diamond>=5)
{
diamond-=5;
cout<<"已合成钻石剑(自动使用)。"<<endl;
fight=max(fight,10);
}
else
cout<<"钻石不够!";
if(t==4)
if(breakstone>=5)
{
breakstone-=5;
cout<<"已合成世界崩解之剑(自动使用)。"<<endl;
fight=max(fight,20);
}
else
cout<<"崩解之石不够!";
}
void go()
{
cout<<"要做什么?\n";
cout<<"1:采集资源\n";
cout<<"2:采集食物\n";
cout<<"3:坐等天黑,去打怪\n";
cout<<"4:继续前进\n";
int t;
cin>>t;
system("cls");
if(t==1)
find();
if(t==2)
food();
if(t==3)
{down_count(wait_for_night,60-things_do*5);night();}
if(t==4)
{
down_count(go_for_castle,10);
fars-=1;
cout<<"剩余距离:"<<fars;
}
}
void now()
{
cout<<"用户名:"<<user;
cout<<"血量:"<<real_live;
cout<<"距离:"<<fars;
cout<<"木头="<<wood<<" 石头="<<stone<<" 钻石="<<diamond<<" 崩解之石="<<breakstone;
sleep_second(5);
system("cls");
}
void final()
{
string final="你已经抵达城堡,最终的考验,在等着你的到来...";
if(fars<=0)
{
for(int i=0;i<final.length();i++)
{
cout<<final[i];
_sleep(40);
}
for(int i=1;i<=10;i++)
{
cout<<i<<"/10末日幽灵(该怪物攻击力=6,血量=66)"<<endl;
for(int j=1;;j++)
{
cout<<"回合"<<j;
if(j==1)
monster_life=66;
monster_life-=fight;
real_live-=6;
cout<<"你剩余"<<real_live<<"血\n怪物剩余"<<monster_life<<"血"<<endl;
ko();
}
cout<<"[奖励]攻击力+1";
fight++;
system("cls");
}
MessageBox(0,"在你的努力下,公主被救了出来!VICTORY!","提示-胜利",MB_OK);
}
}
void home()
{
final();
cout<<"\n你要...\n1:探险 2:状态\n3:说明 4:合成\n0:退出\n";
int t;
cin>>t;
if(t==1)
go();
if(t==2)
now();
if(t==3)
information();
if(t==4)
maker();
if(t==0)
{cout<<"请手动关闭窗口,欢迎再次游玩浴血奋战1.1!";
sleep_second(60);}
}
//恭喜你找到了外挂藏匿之处!使用名称“公主拯救者”开启外挂!
void show_user()
{
cout<<" 浴血奋战\n";
cout<<"代码国的C++公主被困在城堡里,伟大的勇者们啊,拿起你们的武器,去拯救公主吧!"<<endl;
cout<<"请输入名字:";
cin>>user;
if(user=="公主拯救者")
{
cout<<"(外挂)你就是天选之子,";
real_live=666;
hungry=666;
}
cout<<"赶快营救公主吧!\n";
sleep_second(2);
}
int main()
{
system("title 浴血奋战1.1");
show_user();
for(;;)
home();
return 0;
}
这是第2个文件:
#include<iostream>
using namespace std;
void firework_1()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
}
void firework_2()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" · · · · · "<<endl;
}
void firework_3()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
}
void firework_4()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
}
void firework_5()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
}
void firework_6()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
}
void firework_7()
{
cout<<" "<<endl;
cout<<" @ @ @ @ @ "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
}
void firework_8()
{
cout<<" ^ ^ ^ ^ ^ "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
}
void firework_9()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" @ @ @ @ @ "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
}
void firework_10()
{
cout<<" "<<endl;
cout<<" ^ ^ ^ ^ ^ "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
}
void firework_11()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
}
void firework_12()
{
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" · · · · · "<<endl;
cout<<" "<<endl;
}
int main()
{
cout<<"烟花启动中";
_sleep(500);
cout<<".";
_sleep(500);
cout<<".";
_sleep(500);
cout<<"."<<endl;
_sleep(300);
system("cls");
firework_1();
_sleep(300);
system("cls");
firework_2();
_sleep(300);
system("cls");
firework_3();
_sleep(300);
system("cls");
firework_4();
_sleep(300);
system("cls");
firework_5();
_sleep(300);
system("cls");
firework_6();
_sleep(300);
system("cls");
firework_7();
_sleep(300);
system("cls");
firework_8();
_sleep(300);
system("cls");
firework_9();
_sleep(300);
system("cls");
firework_10();
_sleep(300);
system("cls");
firework_11();
_sleep(300);
system("cls");
firework_12();
_sleep(300);
system("cls");
cout<<"~~~~~再见~~~~~"<<endl;
return 0;
}
别忘了点赞关注哦!