雷霆游戏
2026-08-17 08:54:27
发布于:浙江
#include<bits/stdc++.h>
#include<conio.h>
using namespace std;
// color 0F 黑
// color F0 白
// color C0 红
// color D0 紫
// color A0 黄绿
// color 9F 蓝
// color B0 天蓝
// color E0 金黄
char _;
int life=300,life2,mlife=300,mlife2;
int att_min=40,att_max=50,att2_min,att2_max;
int def=8,def2;
int shanghai;
int shanbi=60;
int k;
int sbt,pft;
int fanwei=1;
int nx,ny;
char maps[11][110][110]={
{},
{
{'.',' ','.',' ','.',' ','*',' ','*',' ','.',' ','.',' ','*',' ','.',' ','.'},
{'.',' ','1',' ','*',' ','*',' ','*',' ','.',' ','*',' ','*',' ','.',' ','*'},
{'.',' ','.',' ','.',' ','.',' ','.',' ','1',' ','.',' ','*',' ','*',' ','X'},
{'.',' ','*',' ','*',' ','*',' ','.',' ','.',' ','2',' ','.',' ','*',' ','.'},
{'1',' ','.',' ','.',' ','*',' ','*',' ','*',' ','.',' ','.',' ','*',' ','.'},
{'.',' ','.',' ','1',' ','.',' ','*',' ','.',' ','2',' ','*',' ','.',' ','.'},
{'*',' ','*',' ','*',' ','.',' ','*',' ','.',' ','*',' ','.',' ','1',' ','.'},
{'*',' ','*',' ','*',' ','.',' ','.',' ','.',' ','*',' ','.',' ','.',' ','.'},
{'*',' ','*',' ','.',' ','2',' ','.',' ','*',' ','2',' ','*',' ','.',' ','.'},
{'*',' ','*',' ','*',' ','*',' ','.',' ','.',' ','.',' ','.',' ','.',' ','*'}
}
};
bool vis[11][110][110];
struct mods{
string name;
int life;
int att_min,att_max;
int sbt,pft;
int def;
mods(string n,int l,int amin,int amax,int s,int p,int d){
name=n;
life=l;
att_min=amin;
att_max=amax;
sbt=s;
pft=p;
def=d;
}
};
int rnd(int r_min,int r_max){
return rand()%(r_max-r_min+1)+r_min;
}
int att(int x){
if(x==1) return rnd(att_min,att_max);
else return rnd(att2_min,att2_max);
}
void wait(int t){
clock_t c=clock();
while(clock()-c<t);
}
void say(string s){
for(auto a:s){
wait(50);
printf("%c",a);
}
wait(200);
}
void say_(string s){
for(auto a:s){
wait(20);
printf("%c",a);
}
}
bool shan(int t){
char c;
k=rand()%4;
if(k==0) c='w';
if(k==1) c='a';
if(k==2) c='s';
if(k==3) c='d';
printf("按下 %c 闪避!\n",c-32);
clock_t ct=clock();
_=_getch();
if(_==c||_==c-32){
if(clock()-ct>t){
printf("太慢了!\n");
wait(50);
system("color C0");
wait(200);
system("color 0F");
return false;
}
else{
printf("成功!\n");
wait(50);
system("color A0");
wait(200);
system("color 0F");
return true;
}
}else{
printf("失败!\n");
wait(50);
system("color C0");
wait(200);
system("color 0F");
return false;
}
}
int po(int t){
int res=0;
char c;
while(1){
k=rand()%3;
if(k==0) c='j';
if(k==1) c='k';
if(k==2) c='l';
printf("按下 %c 键破防!\n",c-32);
clock_t ct=clock();
_=_getch();
if((_==c||_==c-32)&&clock()-ct<=t){
res++;
t*=0.85;
}else break;
k=rand()%5;
if(k==0) system("color D0");
if(k==1) system("color E0");
if(k==2) system("color F0");
if(k==3) system("color A0");
if(k==4) system("color B0");
wait(50);
system("color 0F");
}
return res+1;
}
int gongji(int t,string name){
say("我方攻击时间!\n");
say("按下 J 攻击!\n");
_=_getch();
if(_!='j'&&_!='J'){
printf("失手!\n");
wait(50);
system("color F0");
wait(200);
system("color 0F");
say("你没有成功对 "+name+" 造成伤害\n");
return 0;
}
wait(50);
system("color C0");
wait(200);
system("color 0F");
say(name+" 进行了防御!\n");
int ndef2=max(0,def2-po(t));
printf("好样的!\n");
wait(50);
system("color C0");
wait(200);
system("color 0F");
return max(1,att(1)-ndef2);
}
int fangyu(int t,string name){
say(name+" 的攻击时间!\n");
if(rand()%100<shanbi){
if(shan(t)) return 0;
return att(2);
}
say("按下 I 防御!\n");
_=_getch();
if(_!='i'&&_!='I'){
printf("防御失败!即将承受真实伤害!\n");
wait(50);
system("color C0");
wait(100);
system("color 0F");
wait(100);
system("color C0");
wait(100);
system("color 0F");
return att(2);
}
wait(50);
system("color C0");
wait(200);
system("color 0F");
return max(1,att(2)-def);
}
bool fight(mods guai){
say("开始与 "+guai.name+" 战斗!\n");
mlife2=life2=guai.life;
att2_min=guai.att_min;
att2_max=guai.att_max;
def2=guai.def;
sbt=guai.sbt;
pft=guai.pft;
while(life&&life2){
wait(1000);
system("cls");
shanghai=min(gongji(rnd(pft-100,pft+100),guai.name),life2);
say("你对 "+guai.name+" 造成了 ");
printf("%d",shanghai);
wait(60);
say(" 点伤害, "+guai.name+" 剩余 ");
life2-=shanghai;
printf("%d/%d",life2,mlife2);
wait(60);
say(" 点血量!\n");
if(!life2) break;
wait(1000);
system("cls");
shanghai=min(fangyu(rnd(sbt-100,sbt+100),guai.name),life);
say("你受到了 ");
printf("%d",shanghai);
wait(60);
say(" 点伤害,剩余 ");
life-=shanghai;
printf("%d/%d",life,mlife);
wait(60);
say(" 点血量!\n");
if(shanghai==0){
say("短暂的间隔让你有了喘息的机会\n");
say("你的血量恢复 ");
printf("%d",k=rnd(5,20));
wait(60);
say(" 点,当前血量 ");
life=min(life+k,mlife);
printf("%d/%d",life,mlife);
wait(60);
say(" 点!\n");
}
}
if(life) return true;
else return false;
}
void xianshi(int nx,int ny,int nm){
for(int i=0;i<=9;i++){
for(int j=0;j<=18;j++){
if(i>=nx-fanwei&&i<=nx+fanwei&&j>=ny-fanwei*2&&j<=ny+fanwei*2){
if(i==nx&&j==ny) printf("S");
else if(maps[nm][i][j]=='.'||maps[nm][i][j]==' '||vis[nm][i][j]) printf("%c",maps[nm][i][j]);
else printf("?");
}else printf(" ");
}
printf("\n");
}
}
int main(){
srand(time(0));
mods one=mods("一级怪",150,25,35,1000,1500,5);
mods two=mods("二级怪",200,30,40,900,1350,8);
nx=ny=0;
while(1){
system("cls");
xianshi(nx,ny,1);
_=_getch();
while(_!='a'&&_!='A'&&_!='w'&&_!='W'&&_!='s'&&_!='S'&&_!='d'&&_!='D') _=_getch();
switch(_){
case'W':
case'w':{
if(nx-1>=0&&maps[1][nx-1][ny]!='*') nx--;
else if(nx-1>=0) vis[1][nx-1][ny]=true;
break;
}
case'A':
case'a':{
if(ny-2>=0&&maps[1][nx][ny-2]!='*') ny-=2;
else if(ny-2>=0) vis[1][nx][ny-2]=true;
break;
}
case'S':
case's':{
if(nx+1<=9&&maps[1][nx+1][ny]!='*') nx++;
else if(nx+1<=9) vis[1][nx+1][ny]=true;
break;
}
case'D':
case'd':{
if(ny+2<=18&&maps[1][nx][ny+2]!='*') ny+=2;
else if(ny+2<=18) vis[1][nx][ny+2]=true;
break;
}
}
if(maps[1][nx][ny]=='1'){
if(fight(one)){
say("你击败了一只 一级怪\n");
maps[1][nx][ny]='.';
}else break;
}
else if(maps[1][nx][ny]=='2'){
if(fight(two)){
say("你击败了一只 二级怪\n");
maps[1][nx][ny]='.';
}else break;
}else if(maps[1][nx][ny]=='X'){
say("你 过关!!!");
return 0;
}
}
say("你 倒下了……");
return 0;
}
全部评论 4
d
2天前 来自 浙江
0d
2天前 来自 浙江
0d
2天前 来自 浙江
0d
2天前 来自 浙江
0




















有帮助,赞一个