声明:此为小跳蛙和Believe_R_出品,转载请声明出处!!!
#include<bits/stdc++.h>
#include<windows.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
using namespace std
;
int N
=15,Numk
=50,Numl
=5,Numd
=100,Nan
=40,Hp
=10,Beb
;
struct node
{
int x
,y
,vf
,bv
;
inline void init() {x
=rand()%N
+1,y
=rand()%N
+1,bv
=rand()%3+1;}
inline void move() {x
++;if(x
>N
) init(),x
=1;}
}k
[10005],l
[10005],d
[10005];
int x
,y
,hp
,score
,mp
[25][25],udf
,numc
,lanf
,bulf
;
inline void add(int &x
,int y
) {x
+=y
,x
=max(x
,1),x
=min(x
,N
);}
void color(int a
) {SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE
),a
);}
inline int read()
{
int r
=0;char c
=getchar();
while(c
>'9'||c
<'0') c
=getchar();
while(c
>='0'&&c
<='9') (r
*=10)+=c
-'0',c
=getchar();
return r
;
}
inline void print(int x
,int y
,string s
)
{
HANDLE hOut
;COORD pos
;
hOut
=GetStdHandle(STD_OUTPUT_HANDLE
),pos
.X
=y
,pos
.Y
=x
;
SetConsoleCursorPosition(hOut
,pos
),cout
<<s
;
}
inline char check_press(int x
)
{
Sleep(100);
for(int i
=1;i
<=10;i
++) {if(KEY_DOWN(x
)) return 1;Sleep(10);}
return 0;
}
inline void set_windows(int x1
,int y1
,int x2
,int y2
)
{
HANDLE hOut
=GetStdHandle(STD_OUTPUT_HANDLE
);SMALL_RECT rc
;
rc
.Left
=x1
,rc
.Top
=y1
,rc
.Right
=x2
,rc
.Bottom
=y2
;
SetConsoleWindowInfo(hOut
, TRUE
, &rc
);
}
inline void disap_mouse()
{
ShowCursor(false);
HANDLE hOut
=GetStdHandle(STD_OUTPUT_HANDLE
);
CONSOLE_CURSOR_INFO cci
;
GetConsoleCursorInfo(hOut
,&cci
);
cci
.bVisible
=false;
SetConsoleCursorInfo(hOut
,&cci
);
}
inline char check_die()
{
for(int i
=1;i
<=Numk
;i
++) if(k
[i
].x
==x
&&k
[i
].y
==y
) return k
[i
].init(),k
[i
].x
=1,0;
return 1;
}
inline char check_luck()
{
for(int i
=1;i
<=Numl
;i
++) if(l
[i
].x
==x
&&l
[i
].y
==y
) return l
[i
].init(),l
[i
].x
=1,numc
+=(rand()%10+5)*bulf
,0;
return 1;
}
inline char check_dowm()
{
for(int i
=1;i
<=Numd
;i
++) if((d
[i
].x
==x
&&d
[i
].y
==y
)||(d
[i
].x
>=N
&&d
[i
].y
<=N
)) return d
[i
].init(),d
[i
].x
=1,numc
+=(rand()%10+5)*bulf
,0;
return 1;
}
inline void move_thi()
{
for(int i
=1;i
<=Numk
;i
++) if(k
[i
].vf
==0) k
[i
].move();
for(int i
=1;i
<=Numl
;i
++) if(l
[i
].vf
==0) l
[i
].move();
for(int i
=1;i
<=Numd
;i
++) if(d
[i
].vf
==0) d
[i
].move();
}
inline void move_peo()
{
if(KEY_DOWN(87)&&!udf
) add(x
,-1);
if(KEY_DOWN(38)&&!udf
) add(x
,-1);
if(KEY_DOWN(104)&&!udf
) add(x
,-1);
if(KEY_DOWN(87)||KEY_DOWN(38)||KEY_DOWN(104)) color(112),print(7,N
+5,"↑"),color(7);else print(7,N
+5,"↑");
if(KEY_DOWN(83)&&!udf
) add(x
,1);
if(KEY_DOWN(40)&&!udf
) add(x
,1);
if(KEY_DOWN(101)&&!udf
) add(x
,1);
if(KEY_DOWN(83)||KEY_DOWN(40)||KEY_DOWN(101)) color(112),print(11,N
+5,"↓"),color(7);else print(11,N
+5,"↓");
if(KEY_DOWN(65)) add(y
,-1);
if(KEY_DOWN(37)) add(y
,-1);
if(KEY_DOWN(100)) add(y
,-1);
if(KEY_DOWN(65)||KEY_DOWN(37)||KEY_DOWN(100)) color(112),print(9,N
+3,"←"),color(7);else print(9,N
+3,"←");
if(KEY_DOWN(68)) add(y
,1);
if(KEY_DOWN(39)) add(y
,1);
if(KEY_DOWN(102)) add(y
,1);
if(KEY_DOWN(68)||KEY_DOWN(39)||KEY_DOWN(102)) color(112),print(9,N
+7,"→"),color(7);else print(9,N
+7,"→");
}
inline void die()
{
system("cls"),print(0,0," ");
if(lanf
==1)
{
puts("*****ZDT : HaHaHaaaaa! YOU DIED!!!*****\n"),Sleep(2500);
printf("\n ***********YOU SCORE IS:%d***********\n",score
),Sleep(2500);
}
if(lanf
==0)
{
puts("*****ZDT:你终于知道 死 这个字怎么写了!!!*****\n"),Sleep(2500);
printf("\n ****************你的分数是:%d****************\n",score
),Sleep(2500);
}
if(lanf
==1) puts("\n TRY AGAIN? (y/n)");
if(lanf
==0) puts("\n 再来一局 (y/n)");
}
inline void init()
{
system("cls"),srand(time(0)),printf(" ");
for(int i
=1;i
<=N
;i
++) printf("~");
puts("");
for(int i
=1;i
<=N
;i
++)
{
printf("|");
for(int i
=1;i
<=N
;i
++) printf(" ");
puts("|");
}
printf(" ");
for(int i
=1;i
<=N
;i
++) printf("~");
puts(""),x
=N
,y
=N
/2,hp
=Hp
,score
=0,numc
=Beb
*bulf
;
for(int i
=1;i
<=Numk
;i
++) k
[i
].init(),k
[i
].y
=N
+1,k
[i
].vf
=k
[i
].bv
-1;
for(int i
=1;i
<=Numl
;i
++) l
[i
].init(),l
[i
].y
=N
+1,l
[i
].vf
=l
[i
].bv
-1;
for(int i
=1;i
<=Numd
;i
++) d
[i
].init(),d
[i
].y
=N
+1,d
[i
].vf
=d
[i
].bv
-1;
print(1,N
+2," "),printf("The bloods you still have");
print(3,N
+2," "),printf("The score you have now is");
print(5,N
+2," "),printf("The bullet you have is");
for(int i
=1;i
<=Hp
/30;i
++)
{
print(12+i
,N
+2,"-");
for(int i
=2;i
<=30;i
++) printf("-");
}
print(13+Hp
/30,N
+2,"-");
for(int i
=2;i
<=Hp
%30;i
++) printf("-");
}
inline void Begin()
{
disap_mouse(),set_windows(10,10,80,50),system("cls");
printf("\n"),printf("WELCOME TO THE GAME:\n"),color(14);
printf(
"\n"
"BBBBee U U L FFFFFF L Y Y \n"
"B B U U L F L Y Y \n"
"B B U U L F L Y Y \n"
"BBBBBB U U L FFFFFF L YY \n"
"B B U U L F L YY \n"
"B B U U L F L YY \n"
"BBBB^^ UUUU LLLLLL F LLLLLL YY \n"
"\n"
);
color(12),printf("烤蛙出品,侵权必究!QWQ\n\nBelieve_R_ 赞助开发\n\n");
color(7),Sleep(500),puts("PLEASE PRESS 'Enter' TO CONTINUE");
while(1) {if(KEY_DOWN(13)) break;}
Sleep(200),system("cls"),puts("Your Language?/你的语言?"),lanf
=0;
while(1)
{
print(2,0," ");
if(lanf
==1) puts(" 中文 ");else color(112),puts(" 中文 "),color(7);
print(3,0," ");
if(lanf
==0) puts(" English ");else color(112),puts(" English"),color(7);
if(KEY_DOWN(13)||KEY_DOWN(108)) break;
if(KEY_DOWN(87)||KEY_DOWN(83)||KEY_DOWN(38)||KEY_DOWN(40)||KEY_DOWN(104)||KEY_DOWN(101)) lanf
=1-lanf
;
Sleep(100);
}
int t
=0;
Sleep(200),system("cls");
if(lanf
==1) puts("Do you know the rule of the game?");
if(lanf
==0) puts("你知道此游戏的规则吗\n");
while(1)
{
if(lanf
==1)
{
print(2,0," ");
if(t
==1) puts(" Yes ");else color(112),puts(" Yes "),color(7);
print(3,0," ");
if(t
==0) puts(" No ");else color(112),puts(" No "),color(7);
}
if(lanf
==0)
{
print(2,0," ");
if(t
==1) puts(" 是 ");else color(112),puts(" 是 "),color(7);
print(3,0," ");
if(t
==0) puts(" 否 ");else color(112),puts(" 否 "),color(7);
}
if(KEY_DOWN(13)||KEY_DOWN(108)) break;
if(KEY_DOWN(87)||KEY_DOWN(83)||KEY_DOWN(38)||KEY_DOWN(40)||KEY_DOWN(104)||KEY_DOWN(101)) t
=1-t
;
Sleep(100);
}
if(t
==1)
{
Sleep(200),system("cls");
if(lanf
==1)
{
puts("Before playing this game please read these carefully:\n"),Sleep(500);
puts("\n1. You'll be asked to input 7 game parameters before the game starts.\n"),Sleep(500);
puts("\n2. The symbol '!' is the Upgrade Roadblock. If you didn't shut it off before it get to the botton, your bloods will -1!\n"),Sleep(500);
puts("\n3. The symbol '&' is the obstacle which means you cannot let '*' touch the '#'.\n"),Sleep(500);
puts("\n4. The symbol '+' is the midic which means you can recover by touching the '!'.\n"),Sleep(500);
puts("\n5. At first, you will have some bloods. You must go further before you died!\n"),Sleep(500);
puts("\n6. If you press 'Q', the bullets will be fired. But the bullets was limited, it only can be increased by touching '+'\n"),Sleep(500);
puts("\n7. If you press 'Space', the system will give you a sighting telescope. But it can't earse the Roadblock\n"),Sleep(500);
puts("\n\nHappy Games...... QwQ\n"),Sleep(500);
puts("PLEASE PRESS 'Enter' TO CONTINUE");
}
if(lanf
==0)
{
puts("在玩之前,请认真阅读以下提示:\n"),Sleep(500);
puts("\n1. 你将输入7个游戏参数。\n"),Sleep(500);
puts("\n2. 符号'!'是恐怖障碍物。如果你没有在它到达底部之前射掉它,你将会扣一滴血!\n"),Sleep(500);
puts("\n3. 符号'&'是障碍物,一旦你自己('*')碰到障碍物,生命值将会掉1个单位!\n"),Sleep(500);
puts("\n4. 符号'+'可以给你补血,每次你自己('*')碰到'+'会恢复1个单位!\n"),Sleep(500);
puts("\n5. 一开始你会有n个单位的生命,你必须在生命值耗完之前获得最高的分数!\n"),Sleep(500);
puts("\n6. 如果你按下'Q',将会发射子弹。但是子弹的数量是有限的,只有你碰到了'+'才会增加!\n"),Sleep(500);
puts("\n7. 如果你按下'空格',将会调出瞄准镜。但是瞄准镜并不能清除障碍物!\n"),Sleep(500);
puts("\n\nHappy Games...... QwQ\n"),Sleep(500);
puts("请按回车键以继续!");
}
}
while(1) {if(KEY_DOWN(13)) break;}
system("cls");
}
inline void choose()
{
int t
=2;
Sleep(200);
if(lanf
==1) puts("Please choose the Difficulty: \n");
if(lanf
==0) puts("请选择游戏难度:\n");
while(1)
{
if(lanf
==1)
{
print(2,0," ");
if(t
!=5) puts(" Quick: No bullets ");else color(112),puts(" Quick: No bullets "),color(7);
print(3,0," ");
if(t
!=4) puts(" Peaceful: Please play within 'int'! ");else color(112),puts(" Peaceful: Please play within 'int'! "),color(7);
print(4,0," ");
if(t
!=3) puts(" Easy: Suitable for the Freshmen ");else color(112),puts(" Easy: Suitable for the Freshmen! "),color(7);
print(5,0," ");
if(t
!=2) puts(" Middle: Time to race! ");else color(112),puts(" Middle: Time to race! "),color(7);
print(6,0," ");
if(t
!=1) puts(" Hard: Impossible to get 2500! ");else color(112),puts(" Hard: Impossible to get 2500! "),color(7);
print(7,0," ");
if(t
!=0) puts(" User-Defined ");else color(112),puts(" User-Defined "),color(7);
}
if(lanf
==0)
{
print(2,0," ");
if(t
!=5) puts(" 手速 [没有子弹!] ");else color(112),puts(" 手速 [没有子弹!] "),color(7);
print(3,0," ");
if(t
!=4) puts(" 和平 [不要把int玩爆呀!] ");else color(112),puts(" 和平 [不要把int玩爆呀!] "),color(7);
print(4,0," ");
if(t
!=3) puts(" 简单 [新手建议!] ");else color(112),puts(" 简单 [新手建议!] "),color(7);
print(5,0," ");
if(t
!=2) puts(" 普通 [是时候比速度了!] ");else color(112),puts(" 普通 [是时候比速度了!] "),color(7);
print(6,0," ");
if(t
!=1) puts(" 困难 [2500? 不可能的!] ");else color(112),puts(" 困难 [2500? 不可能的!] "),color(7);
print(7,0," ");
if(t
!=0) puts(" 用户自定义 ");else color(112),puts(" 用户自定义 "),color(7);
}
if(KEY_DOWN(13)||KEY_DOWN(108)) break;
if(KEY_DOWN(38)||KEY_DOWN(87)||KEY_DOWN(104)) t
=(t
+1)%6;
if(KEY_DOWN(40)||KEY_DOWN(83)||KEY_DOWN(98)) t
=(t
+5)%6;
Sleep(100);
}
Nan
=40;
if(t
==5) {N
=30,Numk
=65,Numl
=0,Numd
=0,Hp
=5,Beb
=0,bulf
=0;return;}
if(t
==4) {N
=30,Numk
=15,Numl
=20,Numd
=0,Hp
=20,Beb
=500,bulf
=1;return;}
if(t
==3) {N
=30,Numk
=25,Numl
=10,Numd
=1,Hp
=20,Beb
=100,bulf
=1;return;}
if(t
==2) {N
=30,Numk
=40,Numl
=8,Numd
=1,Hp
=15,Beb
=20,bulf
=1;return;}
if(t
==1) {N
=30,Numk
=40,Numl
=5,Numd
=2,Hp
=12,Beb
=20,bulf
=1;return;}
system("cls"),t
=0,Sleep(100);
if(lanf
==1) puts("Do you want to be able to shoot the bullets?");
if(lanf
==0) puts("请选择你能否发射子弹!");
while(1)
{
if(lanf
==1)
{
print(2,0," ");
if(t
==1) puts(" Yes ");else color(112),puts(" Yes "),color(7);
print(3,0," ");
if(t
==0) puts(" No ");else color(112),puts(" No "),color(7);
}
if(lanf
==0)
{
print(2,0," ");
if(t
==1) puts(" 是 ");else color(112),puts(" 是 "),color(7);
print(3,0," ");
if(t
==0) puts(" 否 ");else color(112),puts(" 否 "),color(7);
}
if(KEY_DOWN(13)||KEY_DOWN(108)) break;
if(KEY_DOWN(87)||KEY_DOWN(83)||KEY_DOWN(38)||KEY_DOWN(40)||KEY_DOWN(104)||KEY_DOWN(101)) t
=1-t
;
Sleep(100);
}
bulf
=1-t
,t
=0,system("cls"),Sleep(100);
if(lanf
==1) puts("Please choose your pattern\nIf you choose Pattern 1, you can go up and down, while Pattern 2 can't!\n");
if(lanf
==0) puts("请选择你的模式:\n如果你选择了模式1,你可以上下左右移动;而模式2只能左右移动!\n");
while(1)
{
if(lanf
==1)
{
print(3,0," ");
if(t
==1) puts(" Pattern 1:←↑↓→ ");else color(112),puts(" Pattern 1:←↑↓→ "),color(7);
print(4,0," ");
if(t
==0) puts(" Pattern 2:←→ ");else color(112),puts(" Pattern 2:←→ "),color(7);
}
if(lanf
==0)
{
print(3,0," ");
if(t
==1) puts(" 模式1:←↑↓→ ");else color(112),puts(" 模式1:←↑↓→ "),color(7);
print(4,0," ");
if(t
==0) puts(" 模式2:←→ ");else color(112),puts(" 模式2:←→ "),color(7);
}
if(KEY_DOWN(13)||KEY_DOWN(108)) break;
if(KEY_DOWN(87)||KEY_DOWN(83)||KEY_DOWN(38)||KEY_DOWN(40)||KEY_DOWN(104)||KEY_DOWN(101)) t
=1-t
;
Sleep(100);
}
udf
=t
;
system("cls"),t
=-1;
while(t
<3||t
>35)
{
if(lanf
==1) puts("Please Input an Integer: The Size of the Game(from 3 to 35):\n");
if(lanf
==0) puts("请输入一个整数:游戏界面的大小(3 ~ 35)\n");
print(2,0," "),t
=read(),N
=t
,system("cls");
}
system("cls"),t
=-1;
while(t
<1||90<t
)
{
if(lanf
==1) puts("Please Input an Integer: The Number of Bullets(from 1 to 90):\n");
if(lanf
==0) puts("请输入一个整数:障碍物的数量(1 ~ 90)\n");
print(2,0," "),t
=read(),Numk
=t
,system("cls");
}
system("cls"),t
=-1;
while(t
<1||90<t
)
{
if(lanf
==1) puts("Please Input an Integer: The Number of Backpack(from 1 to 90):\n");
if(lanf
==0) puts("请输入一个整数:回血包的数量(1 ~ 90)\n");
print(2,0," "),t
=read(),Numl
=t
,system("cls");
}
system("cls"),t
=-1;
while(t
<1||90<t
)
{
if(lanf
==1) puts("Please Input an Integer: The Number of Upgrade Bullets(from 1 to 90):\n");
if(lanf
==0) puts("请输入一个整数:恐怖障碍物的数量(1 ~ 90)\n");
print(2,0," "),t
=read(),Numd
=t
,system("cls");
}
system("cls"),t
=-1;
while(t
<1||t
>100)
{
if(lanf
==1) puts("Please Imput an Integer: The Total HP of You(from 1 to 100):\n");
if(lanf
==0) puts("请输入一个整数:初始生命值(1 ~ 100)\n");
print(2,0," "),t
=read(),Hp
=t
,system("cls");
}
system("cls"),t
=-1;
while(t
<1||t
>100)
{
if(lanf
==1) puts("Please Input an Integer: The Bullet You Have at First(from 1 to 100):\n");
if(lanf
==0) puts("请输入一个整数:初始子弹数(1 ~ 100)\n");
print(2,0," "),t
=read(),Beb
=t
,system("cls");
}
}
inline void work()
{
init();
while(1)
{
for(int i
=1;i
<=Numk
;i
++) (k
[i
].vf
+=1)%=k
[i
].bv
;
for(int i
=1;i
<=Numl
;i
++) (l
[i
].vf
+=1)%=l
[i
].bv
;
for(int i
=1;i
<=Numd
;i
++) (d
[i
].vf
+=1)%=d
[i
].bv
;
for(int i
=1;i
<=Numk
;i
++) if(k
[i
].y
<=N
&&k
[i
].x
>0&&k
[i
].vf
==0) print(k
[i
].x
,k
[i
].y
," ");
for(int i
=1;i
<=Numl
;i
++) if(l
[i
].y
<=N
&&l
[i
].x
>0&&l
[i
].vf
==0) print(l
[i
].x
,l
[i
].y
," ");
for(int i
=1;i
<=Numd
;i
++) if(d
[i
].y
<=N
&&d
[i
].x
>0&&d
[i
].vf
==0) print(d
[i
].x
,d
[i
].y
," ");
move_thi(),move_peo();
for(int i
=1;i
<=Numk
;i
++) if(k
[i
].y
<=N
&&k
[i
].x
>0&&k
[i
].vf
==0) color(4),print(k
[i
].x
,k
[i
].y
,"&"),color(7);
for(int i
=1;i
<=Numl
;i
++) if(l
[i
].y
<=N
&&l
[i
].x
>0&&l
[i
].vf
==0) color(2),print(l
[i
].x
,l
[i
].y
,"+"),color(7);
for(int i
=1;i
<=Numd
;i
++) if(d
[i
].y
<=N
&&d
[i
].x
>0&&d
[i
].vf
==0) color(14),print(d
[i
].x
,d
[i
].y
,"!"),color(7);
int die
=check_die(),luck
=check_luck(),dowm
=check_dowm();
if(!die
) {print(hp
/30+13,N
+2+hp
%30," ");}
if(!luck
) {print(hp
/30+13,N
+2+hp
%30,"-");}
if(!dowm
) {print(hp
/30+13,N
+2+hp
%30," ");}
if(!die
) hp
--,score
--;if(!luck
) hp
++,score
+=20;if(!dowm
) hp
--,score
--;
if(hp
<0) return;
int xx
=0,xw
=1,_81
=0,_32
=0;
for(int i
=1;i
<=Numk
;i
++) if(k
[i
].y
==y
&&xx
<k
[i
].x
&&k
[i
].x
<x
) xx
=k
[i
].x
,xw
=i
;
for(int i
=1;i
<=Numl
;i
++) if(l
[i
].y
==y
&&xx
<l
[i
].x
&&l
[i
].x
<x
) xx
=l
[i
].x
,xw
=i
+Numk
;
for(int i
=1;i
<=Numd
;i
++) if(d
[i
].y
==y
&&xx
<d
[i
].x
&&d
[i
].x
<x
) xx
=d
[i
].x
,xw
=i
+Numk
+Numl
;
if(KEY_DOWN(81)&&numc
>0)
{
numc
--,color(112),print(7,N
+8," Q "),color(7),_81
=1;
if(xx
!=0&&numc
>0) for(int i
=x
-1;i
>=xx
;i
--) print(i
,y
,"|");
}
else print(7,N
+8," Q ");
if(KEY_DOWN(32)) {for(int i
=x
-1;i
>xx
;i
--) print(i
,y
,"|");_32
=1,color(112),print(11,N
+8," Space "),color(7);}else print(11,N
+8," Space ");
print(x
,y
,"*");
for(int i
=N
+28;i
<=N
+35;i
++) print(1,i
," ");
for(int i
=N
+28;i
<=N
+35;i
++) print(3,i
," ");
for(int i
=N
+25;i
<=N
+30;i
++) print(5,i
," ");
print(1,N
+29,":"),printf("%d",hp
);
print(3,N
+29,":"),printf("%d",score
);
print(5,N
+26,":"),printf("%d",numc
);
Sleep(Nan
),print(x
,y
," ");
if(xx
!=0&&numc
>0&&_81
)
{
for(int i
=x
;i
>=xx
;i
--) print(i
,y
," ");
if(xw
<=Numk
) k
[xw
].init(),k
[xw
].x
=0,score
++;
else if(xw
<=Numk
+Numl
) l
[xw
-Numk
].init(),l
[xw
-Numk
].x
=0,score
+=20,numc
+=rand()%10;
else d
[xw
-Numk
-Numl
].init(),d
[xw
-Numk
-Numl
].x
=0,numc
+=rand()%10,score
++;
}
if(_32
==1) {for(int i
=x
-1;i
>xx
;i
--) print(i
,y
," ");}
score
++;
}
}
int main()
{
Begin();
while(1)
{
choose(),work(),die();
while(1) {if(KEY_DOWN(89)) break;if(KEY_DOWN(78)) return 0;}
system("cls");
}
return 0;
}
转载请注明原文地址: https://mac.8miu.com/read-55283.html