/ Vijos / 讨论 / 游戏 /

hhhh

#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h>
using namespace std;
int i,j,sum=0,t,si;
char n='2',a[100][100],b[100][100];
int shu[100],xo=70,yo=30,s1,s2,x=40,y=20,zhadan[50][90][50],zhashu=0,fangxiang;
string c[1000]={"0","你","的","任","务","是","到","达","指","定","位","置",",","完","成","任","务","!",};
chenbai(char n){
if(n=='1') if(MessageBox(NULL,"你赢了","管理员",MB_YESNO)!=7){
system("cls");
system("color 4E");
printf("完成任务,你的死亡次数%d\n",sum);
Sleep(1000);
system("pause");
};
if(n=='2') if(MessageBox(NULL,"你输了","管理员",MB_YESNO)!=7){
system("cls");
for(i=1;i<=500;i++){
system("mode con cols=20 lines=10");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED);
cout<<"\n\n\n\n\n 你挂了";
Sleep(200);
system("cls");
}
system("pause");
}
if(n=='3') if(MessageBox(NULL,"你碰到炸弹","管理员",MB_YESNO)!=7);
}
luanma(){
if(MessageBox(NULL,"游戏出现乱码??如果有,按YES 否则,按NO","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"请更改默认值","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"不会更改默认值??","无聊小游戏",MB_YESNO)==7)return 0;
system("cls");
printf("......");
Sleep(1000);
system("cls");
if(MessageBox(NULL,"右键屏幕缓冲区。","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"单击默认值","无聊小游戏。",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"将默认代码页改为简体中文。","无聊小游戏",MB_YESNO)==7)return 0;
Sleep(4000);
if(MessageBox(NULL,"然后……重启游戏!","无聊小游戏",MB_YESNO)==7)return 0;
}
guizei(){
if(MessageBox(NULL,"在游戏里,你是o","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"老规矩,w,a,s,d控制!","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"当然,你也可以用W,A,S,D或8,2,4,6控制!","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"(更新) 还有,你也可以用上下左右键控制!","无聊小游戏——更新",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"你的任务是到达指定位置,完成任务!","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"注意!千万不要碰到炸弹!","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"注意!只能死(炸弹个数-3)次!","无聊小游戏",MB_YESNO)==7)return 0;
if(MessageBox(NULL,"好,开始吧!","无聊小游戏",MB_YESNO)==7)return 0;
}
kaitou(){
printf("\t \(_\) \(_\)无聊小游戏\(_\) \(_\)\n");
printf("\t \1 1.开始无聊! \2\n");
printf("\t \2 2.规则 \1\n");
printf("\t \1 3.chu xian luan ma? \2\n");
printf("\t \2 \1 ( ^_^ )/~~拜拜|\1 \2 \1\n");
}
void ll(){
for(i=1;i<=xo;i++) a[1][i]='=';
shu[1]=1;
for(i=2;i<=yo-1;i++){
a[i][1]='|';
for(j=2;j<=xo-1;j++){
a[i][j]=' ';
}
a[i][xo]='|';
shu[i]=i;
}
for(i=1;i<=xo;i++) a[yo][i]='=';
shu[yo]=yo;
}
void zha(int d);
int kaishi();
int fang(char n);
void zou();
int pengzha();
int main(){
srand((unsigned)time(NULL));
ll();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN|FOREGROUND_BLUE);
system("mode con cols=50 lines=30");
for(;n!='1';){
kaitou();
luanma();
n=getch();
if(n=='2'||n=='3'){
if(n=='2')guizei();
else luanma();
}
system("cls");
}
kaishi();
system("mode con cols=82 lines=45");
s1=2+rand()%(yo-2);
s2=2+rand()%(xo-2);
a[s1][s2]='.';
x=2+rand()%(yo-2);
y=2+rand()%(xo-2);
a[x][y]='o';
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN);
printf("\n游戏开始,目标位:");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED);
printf("%d %d\n",s2,s1);;
zha(1);
int ss=zhashu+1;
Sleep(ss*300);
system("cls");
zou();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("\n你的位置:%d %d\n",y,x);
for(;a[x][y]!='*';){
n=getch();
a[x][y]=' ';
fang(n);
if(n=='q'||n=='1'||n=='Q')
switch(fangxiang){
case 5: if(a[x-1][y]!='#'&&a[x-1][y]!='='&&a[x-1][y]!='|'){b[x-1][y]=a[x-1][y];a[x-1][y]='#';if(b[x-1][y]=='*')zhashu--;break;}

case 2: if(a[x+1][y]!='#'&&a[x+1][y]!='='&&a[x+1][y]!='|'){b[x+1][y]=a[x+1][y];a[x+1][y]='#';if(b[x+1][y]=='*')zhashu--;break;}
case 1: if(a[x][y-1]!='#'&&a[x][y-1]!='='&&a[x][y-1]!='|'){b[x][y-1]=a[x][y-1];a[x][y-1]='#';if(b[x][y-1]=='*')zhashu--;break;}
case 3: if(a[x][y+1]!='#'&&a[x][y+1]!='='&&a[x][y+1]!='|'){b[x][y+1]=a[x][y+1];a[x][y+1]='#';if(b[x][y+1]=='*')zhashu--;break;}
}
if(n=='e'||n=='0'||n=='E'){
switch(fangxiang){
case 5: if(a[x-1][y]=='#')a[x-1][y]=b[x-1][y];if(a[x-1][y]=='*')zhashu++;break;
case 2: if(a[x+1][y]=='#')a[x+1][y]=b[x+1][y];if(a[x+1][y]=='*')zhashu++;break;
case 1: if(a[x][y-1]=='#')a[x][y-1]=b[x][y-1];if(a[x][y-1]=='*')zhashu++;break;
case 3: if(a[x][y+1]=='#')a[x][y+1]=b[x][y+1];if(a[x][y+1]=='*')zhashu++;break;
}
}
if(a[x][y]=='.'){
system("color 4E");
chenbai('1');
return 0;
}
if(a[x][y]=='*') pengzha();
system("cls");
a[x][y]='o';
zou();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED|FOREGROUND_BLUE);
printf("\n你的位置:%d %d",y,x);
zha(2);
}
}
int kaishi(){
system("color F0");
system("mode con cols=28 lines=20");
printf(" 游戏规则\n");
printf(" 1.可以穿墙。\n");
printf(" 2.按Q或1或q键放出方块,遮住炸弹,E或0或e键打破方块。\n");
printf("\n最后,欢迎大家来向我提一切有关动作bug或者游戏地图bug的意见\n");
printf("版权guoxingyu12345(洛谷账号)或guoxingyu12345(Vijos账号)所有\n\n");
if(MessageBox(NULL,"有bug洛谷私信至“垃圾一个”(uid:85933)","无聊小游戏",MB_YESNO)==7);
if(MessageBox(NULL,"或加入https://vijos.org/d/a12345/join?code=12345","无聊小游戏",MB_YESNO)==7);
Sleep(2000);
system("cls");
printf("好了,游戏准备开始");
Sleep(500);
system("cls");
for(i=3;i>=1;i--){
printf("%d",i);
Sleep(1000);
system("cls");
}
system("mode con cols=82 lines=45");
system("color 0C");
for(i=5;i>=1;i--)
{
printf("\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t游戏还有%d秒开始",i);
Sleep(1000);
system("cls");
}
return 0;
}
void zha(int d){
if(d==1){
zhashu=5+rand()%10;
for(i=1;i<=zhashu;i++)
a[2+rand()%(yo-2)][2+rand()%(xo-2)]='*';
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED);
printf("有%d个炸弹!!!\n",zhashu);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN|FOREGROUND_RED);
printf("炸弹位置\n");
for(i=1;i<=yo;i++)
for(j=1;j<=xo;j++)
if(a[i][j]=='*'){
t++;
printf("%d %d %d\n",t,i,j);
}
}
else printf("\n还剩下%d个炸弹",zhashu);
}
void zou(){
int z=1;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN);
for(i=1;i<=yo;i++){
for(j=1;j<=xo;j++){
if(a[i][j]=='*'||a[i][j]=='.'||a[i][j]=='o'){
if(a[i][j]=='*'){
if(i==x&&j==y) z=0;
else printf(" ");
}
if(a[i][j]=='.')printf(" ");
if(a[i][j]=='o'||z==0){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED);
printf("o");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN);
z=1;
}
}
else printf("%c",a[i][j]);
}
printf("%d\n",shu[i]);
}

}
int pengzha(){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED);
system("cls");
zou();
Sleep(1000);
system("cls");
zou();
Sleep(1000);
system("cls");
zou();
Sleep(1000);
chenbai('3');
sum++;
if(x+1==yo) x--;
else x++;
if(sum>zhashu-2) chenbai('2');
}
int fang(char n){
if((n=='8'||n=='w'||n=='W'||n==72)&&a[x-1][y]!='#'){
x--;
fangxiang=5;
}
if((n=='2'||n=='s'||n=='S'||n==80)&&a[x+1][y]!='#'){
x++;
fangxiang=2;
}
if((n=='4'||n=='a'||n=='A'||n==75)&&a[x][y-1]!='#'){
y--;
fangxiang=1;
}
if((n=='6'||n=='d'||n=='D'||n==77)&&a[x][y+1]!='#'){
y++;
fangxiang=3;
}
if(y==1) y=xo-1;
if(y==xo) y=2;
if(x==1) x=yo-1;
if(x==yo) x=2;
}

3 条评论

  • 1