#include<bits/stdc++.h>
using namespace std;
struct hero {
char name[20];
}hero[6];//英雄名字
// srand(time(0)),[m,n]->rand%(n-m+1)+m;//亂數生成范圍書寫通式
struct action {
char act[20];
}action[20];//技能
struct result{
char jg[8];
}result[6];//比賽勝負結果
int flaghero[100]={0};
int act[100]={0}; //英雄、技能去重
int score1=0;
int score2=0;//統計得分
int pd;
int main(){
strcpy(hero[0].name,"蓋倫");
strcpy(hero[1].name,"提莫");
strcpy(hero[2].name,"劍圣");
strcpy(hero[3].name,"銳雯");
strcpy(hero[4].name,"劍姬");
strcpy(hero[5].name,"亞索");
strcpy(action[0].act,"放了個屁給");
strcpy(action[1].act,"拿了把大刀砍向");
strcpy(action[2].act,"怒目猙獰地盯著");
strcpy(action[3].act,"大聲吼向");
strcpy(action[4].act,"打了個大嗝給");
strcpy(action[5].act,"用小拳拳捶向");
strcpy(result[0].jg,"戰勝了");
strcpy(result[1].jg,"輸給了");
strcpy(result[2].jg,"險勝了");
strcpy(result[3].jg,"慘敗給");
strcpy(result[4].jg,"完勝了");
strcpy(result[5].jg,"惜敗給");
while(pd!=1){
srand(time(0));
int a = rand()%(5-0+1)+0;
int b = rand()%(5-0+1)+0;
int c = rand()%(5-0+1)+0;
int d = rand()%(5-0+1)+0;
int e = rand()%(5-0+1)+0;
if(c%2==0)score1++;
else score2++;
flaghero[a]=1;
while(flaghero[b])
{
b = rand()%(5-0+1)+0;
}
flaghero[a]=0;//英雄去重
act[d]=1;
while(act[e])
{
e = rand()%(5-0+1)+0;
}
act[d]=0;//技能去重
printf("開始游戲");
getchar();
printf("1號玩家選擇角色:");
getchar();
printf("%s",hero[a].name);
getchar();
printf("2號玩家選擇角色:");
getchar();
printf("%s",hero[b].name);
getchar();
printf("開始決斗");
getchar();
printf("%s%s%s",hero[a].name,action[d].act,hero[b].name);
getchar();
printf("%s%s%s",hero[b].name,action[e].act,hero[a].name);
getchar();
printf("決斗結束");
getchar();
printf("%s%s%s",hero[a].name,result[c].jg,hero[b].name);
getchar();
printf("1號玩家選手:2號玩家選手比分為 %d:%d",score1,score2);
getchar();
printf("\n");
}
return 0;
}
以上是用c語言書寫的一個簡易的雙人游戲,其中英雄選擇、技能、勝負都是隨機的,
如何進行游戲?編譯運行完,瘋狂按回車就好了
界面時這樣的

非常簡陋哈哈哈哈哈
如果把英雄改成某種特定的xx,再把技能改成特定的xx,在特地的情況下,應該是會有些許樂趣,哈哈哈哈
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/241926.html
標籤:其他
上一篇:C語言游戲——“2048”
下一篇:g題卡片帶師
