小游戏(c++版)
首先要安装DEV-C++这个游戏前几年还有,但是现在没有了。
游戏没有了,但c++程序员还在。
已经尽力复刻了
在c++里,//后面的是注释,可以删掉,不影响程序运行。
这里说一下,我有些c++帖子有人要python的代码,本人不会python,只会c++,敬请谅解。
代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct SKill{
char name;
int mp;
int power;
};
struct JueSe{
//属性
char name;
int hp;
int mp;
int power;
int defenth;
int skills;
struct SKill sk;
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.name,sk.mp);
mp-=sk.mp;
printf("打得%s浑身抖动,掉了%d的血!\n",js->name,sk.power-js->defenth);
js->hp-=sk.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.name,"降龙十八掌");
js1.sk.power=60;
js1.sk.mp=30;
strcpy(js1.sk.name,"九阴白骨爪");
js1.sk.power=160;
js1.sk.mp=130;
strcpy(js1.sk.name,"打狗棒法");
js1.sk.power=260;
js1.sk.mp=230;
strcpy(js1.sk.name,"王八拳");
js1.sk.power=360;
js1.sk.mp=330;
strcpy(js2.name,"欧阳锋");
js2.hp=1000;
js2.mp=500;
js2.power=20;
js2.defenth=20;
js2.skills=3;
strcpy(js2.sk.name,"蛤蟆钻洞");
js2.sk.power=50;
js2.sk.mp=20;
strcpy(js2.sk.name,"蛤蟆通天");
js2.sk.power=250;
js2.sk.mp=100;
strcpy(js2.sk.name,"蛤蟆吼");
js2.sk.power=150;
js2.sk.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);
}
附件:
页:
[1]