小游戏awa

第一种

给粉丝的awa

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
struct note{
     char a[105];
    int hp;
int gj;
};
int s;
note player[100];
int hit1,hit2,k,g[11],pdh1=0,pdh2=0,n;
void shuru();
void gj();
void youxi();
void slowsay(char a[]){
     for(int i=0;i<strlen(a);i++){
    cout<<a[i];
        Sleep(25);
    }
}
int main(){
     srand((unsigned)time(NULL));
     slowsay("欢迎来到名字竞技场 by Steve_bm");
     cout<<endl;
     slowsay("V 1.2");
     cout<<endl;
    cout<<"请输入人数:";
cout<<"人数不能小于2!"<<endl;  
cin>>n;
shuru();
     youxi();
     return 0;
}
void gj(){
     int op1,op2;
     op1=rand()%n+1;
     op2=rand()%n+1;
     if((op1==op2)||(player[op1].hp==0||player[op2].hp==0)){
    while(1){
        op1=rand()%n+1;
            op2=rand()%n+1;
            if((op1!=op2)&&(player[op1].hp!=0&&player[op2].hp!=0)) break;
        }
    }
hit1=rand()%player[op1].gj+1;
k=player[op2].hp;
    player[op2].hp-=hit1;
 
     cout<<player[op1].a<<"对"<<player[op2].a<<"发起了攻击/<-_->\\"<<endl;
     Sleep(500);
     if(hit1>=((player[op1].gj/3)*2)){
     cout<<player[op1].a<<"暴击!!!\\[^.^]/"<<endl;
player[op2].hp-=hit1;
player[op2].hp-=hit1;
hit1=hit1*3;} 
    cout<<player[op2].a<<"受到了"<<hit1<<"点伤害!<[T^T]>";
     Sleep(250);
     cout<<player[op2].a<<"的生命值:"<<k<<"下降了"<<hit1<<"!!!|(o^O)|<---|-"<<endl;
     cout<<player[op2].a<<"现在的生命值剩余"<<player[op2].hp;  
     if(player[op2].hp<=0) player[op2].hp=0;  
     if(player[op2].hp<=0){
s++;
    cout<<endl<<player[op2].a<<"倒下了!!!\\(*_*)/"<<endl<<"死亡"<<s<<"人";
    } 
}
void youxi(){
    Sleep(1200);
    for(int t=1;t<=n;t++){
         int n1=player[t].a[0]+200;
         int q1=player[t].a[strlen(player[t].a)-1];
         player[t].hp=(rand()%n1+30)*9;
        player[t].gj=(rand()%q1+30)*7;
    }
system("cls");
    for(int b=1;b<=n;b++){
         cout<<player[b].a<<" "<<"HP:"<<player[b].hp<<" "<<"攻击力:"<<player[b].gj<<endl;
         cout<<endl;
    }
     cout<<endl;
     Sleep(3000);
     cout<<3<<endl<<endl<<endl;
     cout<<2<<endl<<endl<<endl;
     cout<<1<<endl<<endl<<endl;
     cout<<"现在开始!"<<endl<<endl<<endl;
     Sleep(1500);
     int w;
    int f=0;
while(1){
    gj();
        Sleep(1000);
         cout<<endl;
         for(int i=1;i<=n;i++){
            if(player[i].hp==0) f++;
        if(player[i].hp>0) w=i;
    }
        if(f==n-1) break;
f=0;
}
    Sleep(1500);
     cout<<"胜利者是";
cout<<player[w].a<<"!"<<endl;  
for(int m=1;m<=n;m++){
         if(player[m].hp==0){
         cout<<player[m].a<<"第"<<m+1<<"名"<<endl;
        }
    }
    
    char l;
     Sleep(3000);
     cout<<"Do you want to play again?(Y/N)(jia de!!!)"<<endl;
     cin>>l;
    if(l=='Y'||l=='y'){youxi();
system("cls");
    for(int h=1;h<=n;h++){
        memset(player[h].a,0,sizeof(player[h].a));
         }
        
    }
    else{
        exit(0);
    }
}
void shuru(){
    for(int l=1;l<=n;l++){
        cout<<"请输入玩家"<<l<<"的名字(名字不超过10字符,最小3字符,不能有汉字!):"<<endl;
    scanf("%s",player[l].a);
    }
    int yy[11]={0};
    for(int i=1;i<n;i++){
        for(int o=i+1;o<=n;o++){
            for(int q=0;q<strlen(player[i].a);q++){
                if(player[i].a[q]==player[o].a[q]) yy[i]++;
            }
        }
    }
    for(int u=1;u<=n;u++){
        if(yy[u]==strlen(player[u].a)){
            system("cls");
              cout<<"输入的名字不能相同!"<<endl;
               Sleep(100);
               cout<<"请重新输入!"<<endl;
              shuru();
        }
        else youxi();
    }
}

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值