击败大魔王游戏
2024-12-28 14:03:34
发布于:广东
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
const int N = 1000;
int n=N,cs=11,hp,pw,d,s,px,py,m=1,num=1,cnt;
double sum = 1.0;
int x = n/2,y = n/2;
char mp[N+5][N+5];
bool flag = 1;
int ff=1;
int r(int i,int j){
return rand()%(j-i+1)+i;
}void up(){
int g = rand()%55+1;
int f = rand()%4+1;
cout << "已开始抽取加成,按任意键抽取"<<endl;
getch();
if(g<=1)g = 10;
else if(g<=3)g = 9;
else if(g<=6)g = 8;
else if(g<=10)g = 7;
else if(g<=15)g = 6;
else if(g<=21)g = 5;
else if(g<=28)g = 4;
else if(g<=36)g = 3;
else if(g<=45)g = 2;
else g = 1;
int SUM = sum;
if(f==1)cout << "生命增加"<<SUM*2*g<<endl;
else if(f==2)cout << "攻击力增加"<<SUM*g<<endl;
else if(f==3)cout << "防御增加"<<SUM*g<<endl;
else cout << "移速增加"<<SUM*g<<endl;
if(f==1)hp += sum*2*g;
else if(f==2)pw += num*g;
else if(f==3)d += num*g;
else s += num*g;
getch();
return;
}void win(char co,int hh){
cout << "你赢了"<<endl;
cout << "汲取了敌人的血量:"<<hh<<"*60%="<<(int)(hh*0.6)<<endl;
hp += hh * 0.8;
int _ = sum;
if(co=='C')sum+=1.0/sum*num*0.5;
if(co=='B')sum+=1.0/sum*num*1;
if(co=='A')sum+=1.0/sum*num*5;
if(co=='S')sum+=1.0/sum*num*10;
if(co=='X')sum+=1.0/sum*num*20;
cnt++;
getch();
if(int(sum)>_){
cout << "恭喜你从"<<_<<"级升到了"<<int(sum)<<"级"<<endl;
cout << "你可以抽取"<<int(sum)-_<<"次奖励"<<endl;
for(int i=1;i<=int(sum)-_;i++)up();
}return;
}void init(){
int cx=rand()%n+1,cy = rand()%n+1;
x = y = n/2;
for(int i=0;i<=n+1;i++){
for(int j=0;j<=n+1;j++){
if(i<1 or i>n or j<1 or j>n){
mp[i][j] = '#';
continue;
}if(i==cx and j==cy){
mp[i][j] == '0';
continue;
}
if(i==n/2 and j==n/2){
mp[i][j] = '@';
continue;
}
int num = rand()%128+1;
if(num>=64)mp[i][j] = '.';
else if(num>=32)mp[i][j] = 'C';
else if(num>=16)mp[i][j] = 'B';
else if(num>=8)mp[i][j] = 'A';
else if(num>=4)mp[i][j] = '$';
else if(num>=2)mp[i][j] = 'S';
else mp[i][j] = 'X';
}
}
}void draw(){
system("cls");
for(int i=x-cs/2;i<=x+cs/2;i++){
for(int j=y-cs/2;j<=y+cs/2;j++){
cout << mp[i][j] <<" ";
}cout << endl;
}cout << endl;
num = (abs(x-n/2)+abs(y-n/2))/6+1;
cout << "血量:"<<hp<<endl;
cout << "攻击力:"<<pw<<endl;
cout << "防御力:"<<d<<endl;
cout << "速度:"<<s<<endl;
cout << "当前等级:"<<(int)sum<<endl;
cout << "怪物等级:"<<num<<endl;
if(num>=100 and ff==1){
cout << "达成成就:怪物猎手"<<endl;
ff=2;
}if(num>=1000 and ff == 2){
cout << "达成成就:你是我的神"<<endl;
}
}bool move(int dx,int dy){
mp[x][y] = '.';
x += dx;y += dy;
char co = mp[x][y];
mp[x][y] = '@';
num = (abs(x-n/2)+abs(y-n/2))/6+1;
if(num<=0)num = 1;
if(co=='O')return 2;
if(co=='#'){
mp[x][y] = '#';
x-=dx;y-=dy;
return 1;
}
draw();
int gh,gp,gd,gs;
if(co=='.')return 1;
else if(co=='C'){
gh = num*num*r(5,8);
gp = num*num*r(2,5);
gd = num*num*r(1,3);
gs = num*num*r(3,5);
}else if(co=='B'){
gh = num*num*r(8,20);
gp = num*num*r(8,12);
gd = num*num*r(4,8);
gs = num*num*r(6,12);
}else if(co=='A'){
gh = num*num*r(30,50);
gp = num*num*r(10,20);
gd = num*num*r(15,25);
gs = num*num*r(20,40);
}else if(co=='S'){
gh = num*num*r(50,100);
gp = num*num*r(20,40);
gd = num*num*r(30,50);
gs = num*num*r(40,80);
}else if(co=='X'){
gh = num*num*r(100,200);
gp = num*num*r(40,60);
gd = num*num*r(50,70);
gs = num*num*r(60,100);
}else if(co=='$'){
up();
return 1;
}
cout << endl;
cout << "对方是"<<co<<"级怪"<<endl;
cout << "对方实力:"<<endl;
cout << "血量:"<<gh<<endl;
cout << "攻击力:"<<gp<<endl;
cout << "防御力:"<<gd<<endl;
cout << "速度:"<<gs<<endl;
cout << endl;
cout << "我方实力:"<<endl;
cout << "血量:"<<hp<<endl;
cout << "攻击力:"<<pw<<endl;
cout << "防御力:"<<d<<endl;
cout << "速度:"<<s<<endl<<endl;
Sleep(1000);
int hh = gh,ds=0;
bool flag3 = 1;
if(gs>s){
cout << "敌方移速更高"<<endl;
if(m==2 and rand()%100>60){
cout << "盾兵被动触发"<<endl;
cout << "免疫这次伤害"<<endl;
cout << "造成"<<ceil((d>=gp?1:gp-d)*0.3)<<"的真实伤害"<<endl;
gh -= ceil((d>=gp?1:gp-d)*0.3);
cout << "他还剩"<<gh<<"点血"<<endl;
if(gh<=0){
win(co,hh);
draw();
return 1;
}
}else{
cout << "他对你造成了"<<(d>=gp?1:gp-d)<<"点伤害"<<endl;
hp -= (d>=gp?1:gp-d);
cout << "你还剩"<<hp<<"点血"<<endl;
}
Sleep(100);
if(flag3 and hp<=0 and m==3){
cout << "医疗兵被动触发"<<endl;
cout << "恢复"<<int(sum*10) << "点血"<<endl;
hp += sum * 10;
flag3 = 0;
}cout << endl;
if(hp<=0){
cout << "你输了";
flag = 0;
getch();
return 0;
}
}else cout << "我方移速更高"<<endl;
while(true){
Sleep(500);
int pp = 0;
if(m==4 and rand()%30 and !ds){
ds = 2;
cout << "生物学家被动触发"<<endl;
cout << "你对他造成了"<<(gd>=pw?1:pw-gd)<<"+"<<int(pw*0.4)<<"点伤害"<<endl;
pp = pw*0.4;
}else if(ds){
cout << "你对他造成了"<<(gd>=pw?1:pw-gd)<<"+"<<int(pw*0.4)<<"点伤害"<<endl;
pp = pw*0.4;
ds--;
}else if(m==1 and gp > hp and rand()%100>20){
pp = pw;
cout << "战士被动触发"<<endl;
cout << "你对他造成了"<<(gd>=pw?1:pw-gd);
cout <<"+"<<pp<<"点伤害"<<endl;
}else{
cout << "你对他造成了"<<(gd>=pw?1:pw-gd)<<"点伤害"<<endl;
}gh -= (gd>=pw?1:pw-gd)+pp;
cout << "他还剩"<<gh<<"点血"<<endl;
cout << endl;
if(gh<=0){
win(co,hh);
draw();
return 1;
}
Sleep(100);
if(m==2 and rand()%100>60){
cout << "盾兵被动触发"<<endl;
cout << "免疫这次伤害"<<endl;
cout << "造成"<<ceil((d>=gp?1:gp-d)*0.3)<<"的真实伤害"<<endl;
gh -= ceil((d>=gp?1:gp-d)*0.3);
cout << "他还剩"<<gh<<"点血"<<endl;
if(gh<=0){
win(co,hh);
draw();
return 1;
}
}else{
cout << "他对你造成了"<<(d>=gp?1:gp-d)<<"点伤害"<<endl;
hp -= (d>=gp?1:gp-d);
cout << "你还剩"<<hp<<"点血"<<endl;
}
if(flag3 and hp<=0 and m==3){
cout << "医疗兵被动触发"<<endl;
cout << "恢复"<<int(sum*10) << "点血"<<endl;
hp += sum * 10;
flag3 = 0;
}cout << endl;
if(hp<=0){
cout << "你输了";
getch();
flag = 0;
return 0;
}
}
}
int main(){
srand(time(0));
cout << "请选择你的角色"<<endl;
cout << "A.战士 如果对面生命高于我方则每次攻击80%打出双倍伤害"<<endl;
cout << "B.盾兵 被攻击时有40%概率免伤并反弹30%的向上取整真实伤害"<<endl;
cout << "C.治疗兵 第一次死亡后回复经验值*10的血量"<<endl;
cout << "D.生物学家 攻击时有30%使用毒药连续三回合在攻击之后造成攻击力40%的真实伤害"<<endl;
char js;cin >> js;
if(js=='A' or js=='a'){
m = 1;
hp = 10;
pw = 5;
d=3;
s=4;
}if(js=='B' or js=='b'){
m = 2;
hp = 6;
pw = 4;
d=6;
s=3;
}if(js=='C' or js=='c'){
m=3;
hp = 12;
pw = 4;
d=3;
s=5;
}if(js=='D' or js=='d'){
m=4;
hp = 5;
pw = 6;
d=2;
s=3;
}cout << "开局奖励"<<endl;
up();
while(flag){
init();
draw();
while(1+1==2){
char index = getch();
px = py = 0;
if(index == 'w')px = -1;
if(index == 'a')py = -1;
if(index == 's')px = 1;
if(index == 'd')py = 1;
if(!move(px,py))break;
}
}system("cls");
cout << "你死了(*_*)"<<endl;
cout << "你一共击败了"<<cnt<<"个怪"<<endl;
}
开局会先抽取一次奖励
后每升一级抽取一次奖励
wasd移动必须小写
抽完奖励后需随便按一键才能继续游戏
战斗机制如下
移速高的一方优先攻击
伤害等于攻击减对方防御
四个角色都有被动详细请自行打开游戏
怪物参数等于怪物等级怪物等级随机参数
怪物等级游戏内会显示
具体请看move函数
游戏内图标为下
我 @
路 .
怪物CBASX
奖励箱 $
传送门 ?专为肝帝打造 地图大小为1000*1000 地图中会有一个传送门 当你把所有该打完后可以进入此传送门重新刷新地图
# 边界墙
怪物等级 X > S > A > B > C
已更新一次代码
需重新复制
公测玩家:#include 「欢愉」花火
最佳MVP:
全部评论 3
我要进参与者名单!!!
1周前 来自 广东
2我去这么强
2024-12-22 来自 广东
1就是两个小盆友无聊( ̄、 ̄),灵光一现,开腾讯会议玩出来的小游戏(欸嘿)
1周前 来自 广东
1
太强辣
1周前 来自 广东
0
有帮助,赞一个