首先要安装DEV-C++
这个游戏前几年还有,但是现在没有了。
游戏没有了,但c++程序员还在。
已经尽力复刻了
在c++里,//后面的是注释,可以删掉,不影响程序运行。
这里说一下,我有些c++帖子有人要python的代码,本人不会python,只会c++,敬请谅解。
代码:
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- struct SKill{
- char name[25];
- int mp;
- int power;
- };
-
- struct JueSe{
- //属性
- char name[25];
- int hp;
- int mp;
- int power;
- int defenth;
- int skills;
- struct SKill sk[5];
- void show(){
- printf("名字:%s\nhp:%d\nmp:%d\npower:%d\ndefenth:%d\n",name,hp,mp,power,defenth);
- }
- //技能
- void skill(struct JueSe* js,int i){
- printf("%s打出一招%s,耗费自己%d的蓝!\n",name,sk[i].name,sk[i].mp);
- mp-=sk[i].mp;
- printf("打得%s浑身抖动,掉了%d的血!\n",js->name,sk[i].power-js->defenth);
- js->hp-=sk[i].power-js->defenth;
- }
-
- };
- //全局
- struct JueSe js1,js2;
-
- int round=1;
- int n;
-
- void initGame();
-
- void showGame();
-
- void ctolGame();
- int main()
- {
- initGame();
- while(1)
- {
- js1.show();
- js2.show();
- ctolGame();
- showGame();
- }
- return 0;
- }
- void initGame()
- {
- strcpy(js1.name,"郭靖");
- js1.hp=1000;
- js1.mp=500;
- js1.power=20;
- js1.defenth=10;
- js1.skills=4;
- strcpy(js1.sk[0].name,"降龙十八掌");
- js1.sk[0].power=60;
- js1.sk[0].mp=30;
- strcpy(js1.sk[1].name,"九阴白骨爪");
- js1.sk[1].power=160;
- js1.sk[1].mp=130;
- strcpy(js1.sk[2].name,"打狗棒法");
- js1.sk[2].power=260;
- js1.sk[2].mp=230;
- strcpy(js1.sk[3].name,"王八拳");
- js1.sk[3].power=360;
- js1.sk[3].mp=330;
-
- strcpy(js2.name,"欧阳锋");
- js2.hp=1000;
- js2.mp=500;
- js2.power=20;
- js2.defenth=20;
- js2.skills=3;
- strcpy(js2.sk[0].name,"蛤蟆钻洞");
- js2.sk[0].power=50;
- js2.sk[0].mp=20;
- strcpy(js2.sk[1].name,"蛤蟆通天");
- js2.sk[1].power=250;
- js2.sk[1].mp=100;
- strcpy(js2.sk[2].name,"蛤蟆吼");
- js2.sk[2].power=150;
- js2.sk[2].mp=120;
- }
- void showGame()
- {
- printf("---------------round%d---------------\n",round);
- round++;
-
-
- js1.skill(&js2,n);
- int m=rand()% js2.skills;
- js2.skill(&js1,m);
-
-
- }
-
- void ctolGame()
- {
- printf("请输入:");
- scanf("%d",&n);
-
- }
复制代码
附件:
小游戏.zip
|