abcdefg
2025-05-25 14:27:39
发布于:广东
#include<iostream>
#include<ctime>
#include<string>
#include<windows.h>
#include<cstdio>
#include<cmath>
#include<fstream>
using namespace std;
int x=100,coin=100,buy_time,cd_=0,buy[1010],kill_=0,player=0,game=0;
string name[5]={"花似雪","N","N"},gname,shop[10]={"血量(10血)","血量(20血)","血量(30血)","血量(50血)","缩短CD 1秒","缩短CD 2秒","伤害(1血)","伤害(2血)","角色(一只姜)"};
bool isKeyPressed(int key) {
return (GetAsyncKeyState(key)&0x8000)!=0;
}
void play_mode(){
srand(static_cast<unsigned int>(time(0)));
int n,ox=rand()%30+x-10,j=x,kill,choice,f=0,m_kill=0,f2=0;
string g;
double p=0,p1=0,p2=0,p3=0;
system("cls");
cout<<"是否参加新手教程\n1.是 2.否\n";
cin>>n;
if(n==1){
system("cls");
cout<<"新手引导:\n请按下 1 键使用普攻\n";
while(true){
if (isKeyPressed('1')) {
cout<<"我方使用普攻,造成了敌方1点伤害"<<endl;
break;
}
}
cout<<"请按下 2 键使用一技能\n";
while(true){
if (isKeyPressed('2')) {
if(player==0){
cout<<"我方使用一技能 滔滔火海,造成了敌方"<<10+kill_<<"点伤害"<<endl;
}
break;
}
}
cout<<"请按下 3 键使用二技能\n";
while(true){
if (isKeyPressed('3')) {
if(player==0){
cout<<"我方使用二技能 暴力破解,造成了敌方"<<12+kill_<<"点伤害"<<endl;
}
break;
}
}
cout<<"请按下 4 键使用大招\n";
while(true){
if (isKeyPressed('4')) {
if(player==0){
cout<<"我方使用大招 水来土掩,造成了敌方"<<20+kill_<<"点伤害"<<endl;
}
break;
}
}
system("pause");
}
system("cls");
while(true){
cout<<"请选择出战角色:\n1.花似雪 2.一只姜 3.Macw07\n";
cin>>choice;
if(choice==1){
gname="花似雪";
player=0;
break;
}
else if(choice==2&&name[1]=="一只姜"){
gname="一只姜";
player=1;
break;
}
else if(choice==3&&name[2]=="Macw07"){
gname="Macw07";
player=2;
break;
}
cout<<"你没有这个角色。\n";
}
cout<<"你的角色为:"<<gname<<endl;
choice=rand()%3;
cout<<"敌方的角色为:";
if(choice==0){
cout<<"法兰西玫瑰\n";
}
else if(choice==1){
cout<<"复仇者_黑客_ZDZL\n";
}
else if(choice==2){
cout<<"陈臻武\n";
}
system("pause");
while(true){
f++;
f2++;
system("cls");
cout<<"我方血量:"<<x<<endl;
cout<<"敌方血量:"<<ox<<endl;
cout<<"普攻CD:"<<p<<endl;
cout<<"1技能CD:"<<p1<<endl;
cout<<"2技能CD:"<<p2<<endl;
cout<<"大招CD:"<<p3<<endl;
if (isKeyPressed('1')) {
if(p<=0){
cout<<"我方使用普攻,造成了敌方1点伤害"<<endl;
p=1;
ox-=1;
}
}
else if (isKeyPressed('2')) {
if(p1<=0){
if(player==0){
cout<<"我方使用一技能 滔滔火海,造成了敌方"<<10+kill_<<"点伤害"<<endl;
ox-=10+kill_;
}
else if(player==1){
cout<<"我方使用一技能 眩晕药水,使敌方眩晕2秒"<<endl;
f-=20;
}
else if(player==2){
cout<<"我方使用一技能 AC狗饲养员,使自己回6滴血"<<endl;
x+=6;
}
p1=6-cd_;
}
}
else if (isKeyPressed('3')) {
if(p2<=0){
if(player==0){
cout<<"我方使用二技能 暴力破解,造成了敌方"<<12+kill_<<"点伤害"<<endl;
ox-=12+kill_;
}
else if(player==1){
cout<<"我方使用二技能 绝命毒师,使敌方掉落了5枚金币,并造成了"<<5+kill_<<"点伤害"<<endl;
ox-=5+kill_;
coin+=5;
}
else if(player==2){
cout<<"我方使用二技能 AC帖,对敌方造成"<<16+kill_<<"精神伤害"<<endl;
ox-=16+kill_;
}
p2=8-cd_;
}
}
else if (isKeyPressed('4')) {
if(p3<=0){
if(player==0){
cout<<"我方使用大招 水来土掩,造成了敌方"<<20+kill_<<"点伤害"<<endl;
ox-=20+kill_;
}
else if(player==1){
cout<<"我方使用大招 摄魂余生,使敌方造成了每秒2点的持续性伤害"<<endl;
m_kill*=2;
}
else if(player==2){
cout<<"我方使用二技能 来AC,对敌方造成"<<8+kill_<<"实体伤害,自己回16滴血,捡到对方10个金币"<<endl;
x+=16;
ox-=8+kill_;
coin+=10;
}
p3=12-cd_;
}
}
if(f2%10==0){
ox-=m_kill;
cout<<"我方造成了"<<m_kill<<"点的持续性伤害\n";
}
if(ox<=0){
cout<<"胜利!";
cout<<"\n你获得了100金币\n";
coin+=100;
x=j;
system("pause");
return;
}
else if(x<=0){
cout<<"失败!";
cout<<"\n你失去了20金币\n";
if(x-20>=0){
coin-=20;
}
x=j;
system("pause");
return;
}
if(f==5){
kill=rand()%2+2;
cout<<"敌方使用普攻,造成了"<<kill<<"点随机伤害";
x-=kill;
f=0;
}
Sleep(100);
if(p>0){
p-=0.1;
}
if(p1>0){
p1-=0.1;
}
if(p2>0){
p2-=0.1;
}
if(p3>0){
p3-=0.1;
}
}
}
void out_mode(){
system("cls");
cout<<"感谢游玩!";
exit(0);
}
void look_mode(){
char n;
bool flag=true;
system("cls");
cout<<"已购买:\n";
for(int i=0;i<buy_time;i++){
cout<<i+1<<"."<<shop[buy[i]]<<endl;
flag=false;
}
if(flag){
cout<<"空\n";
}
system("pause");
return;
}
void shop_mode(int sign){
int choice;
system("cls");
if(sign==1){
cout<<"金币不够,请重新购买\n";
}
else if(sign==2){
cout<<"输入错误,请重新输入\n";
}
cout<<"你现在有"<<coin<<"金币\n";
cout<<"1.血量(10血) 100金币\n2.血量(20血) 180金币\n3.血量(30血) 270金币\n4.血量(50血) 450金币\n5.缩短CD 1秒 350金币\n6.缩短CD 2秒 500金币\n7.伤害(1血) 400金币\n8.伤害(2血) 500金币\n9.角色(一只姜) 600金币\n10.角色(Macw07) 1000金币\n11.返回主页面\n请问你要购买哪个?";
cin>>choice;
if(choice==1){
if(coin>=100){
coin-=100;
x+=10;
buy[buy_time]=0;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==2){
if(coin>=180){
coin-=180;
x+=20;
buy[buy_time]=1;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==3){
if(coin>=270){
coin-=270;
x+=30;
buy[buy_time]=2;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==4){
if(coin>=450){
coin-=450;
x+=50;
buy[buy_time]=3;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==5){
if(coin>=350){
coin-=350;
cd_+=1;
buy[buy_time]=4;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==6){
if(coin>=500){
coin-=500;
cd_+=2;
buy[buy_time]=5;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==7){
if(coin>=400){
coin-=400;
kill_+=1;
buy[buy_time]=6;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==8){
if(coin>=500){
coin-=500;
kill_+=1;
buy[buy_time]=7;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==9){
if(coin>=600){
coin-=600;
name[1]="一只姜";
player=1;
buy[buy_time]=8;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==10){
if(coin>=1000){
coin-=1000;
name[2]="Macw07";
player=2;
buy[buy_time]=9;
buy_time++;
shop_mode(0);
}
else{
shop_mode(1);
}
}
else if(choice==11){
return;
}
else{
shop_mode(2);
}
}
void load_mode(){
ofstream file("存档.code");
if (file.is_open()) {
file <<name[1]<<" "<<name[2]<<" "<<coin<<" "<<x<<" "<<cd_<<" "<<buy_time<<" "<<kill_;
for(int i=0;i<buy_time;i++){
file<<" "<<buy[i];
}
file.close();
}
}
void read_load_mode(){
ifstream file("存档.code");
if (file.is_open()) {
file >>name[1]>>name[2]>>coin>>x>>cd_>>buy_time>>kill_;
for(int i=0;i<buy_time;i++){
file>>buy[i];
}
file.close();
}
}
void home(){
int n;
cout<<"欢迎参加 天空之战\n1.休闲模式 2.商店 3.退出 4.购买记录 5.存档 6.读档\n请输入选择:";
cin>>n;
switch(n){
case 1:
play_mode();
break;
case 2:
shop_mode(0);
break;
case 3:
out_mode();
break;
case 4:
look_mode();
break;
case 5:
load_mode();
break;
case 6:
read_load_mode();
break;
default:
system("cls");
cout<<"请重新输入。\n";
home();
}
}
int main(){
while(true){
system("cls");
home();
}
}
全部评论 2
1周前 来自 广东
0真有实力666
2025-05-29 来自 广东
0
有帮助,赞一个