C++小游戏超级迷宫2.0

这是超级迷宫2.0
摘要由CSDN通过智能技术生成

#include<bits/stdc++.h> 
#include<conio.h>
#include<windows.h>
using namespace std;
void Color(int a){
    if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
    if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
    if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
    if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
    if(a==-5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN);
}
struct node{int x,y,w,turn,kind;bool life;}B[1001];
void Setpos(int x,int y){COORD pos;pos.X=y*2,pos.Y=x;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
int bl,boom,dooring,T,win,x,y,speed=300,spnum=0,Score,Bspeed=5,Mapsize=18;
int M[35][35],M2[35][35];
int dx[5]={0,-1,0,1,0},dy[5]={0,0,1,0,-1};// 上右下左 
void Delete(int x,int y)
{
    if(x<=0||x>=Mapsize||y<=0||y>=Mapsize) return;
    M[x][y]=0;M2[x][y]=0;
    for(int i=1;i<=bl;i++) if(B[i].x==x&&B[i].y==y) B[i].life=0;
    Setpos(x,y);cout<<"  ";
}
void Move(int i){
    int x0=B[i].x,y0=B[i].y,t=B[i].turn,j=0,r=2*(rand()%2)-1;
    while(j<4){
    if(M[x0+dx[t]][y0+dy[t]]==0){
    B[i].x=x0+dx[t];
    B[i].y=y0+dy[t];
    B[i].turn=t;break;}
    else if(B[i].w==2&&M2[x0+dx[t]][y0+dy[t]]==1){
        Delete(x0+dx[t],y0+dy[t]);
    B[i].x=x0+dx[t];
    B[i].y=y0+dy[t];
    B[i].turn=t;break;}
        j++;
        if(j==1) t+=r;if(j==2) t-=2*r;if(j==3) t--;
        if(t>4) t-=4;if(t<1) t+=4;
    }
    return;
}
void Cout(int i,int j,int a,int x)
{
    int c=5;
    if(x==0) a=M[i][j];
    if(x==404) c=4;
    if(a==0&&i%2==0&&j%2==0) return;
    if(i<0||j<0||i>Mapsize||j>Mapsize) return;
    Setpos(i,j);
    if(i==x&&j==y) Color(1),cout<<"●";
    else if(x!=0&&a==0) Color(0),cout<<"  ";
    else if(a==1) Color(c),cout<<"↑";
    else if(a==2) Color(c),cout<<"→";
    else if(a==3) Color(c),cout<<"↓";
    else if(a==4) Color(c),cout<<"←"; 
    else if(a==5) Color(7),cout<<"■";
    else if(a==6) Color(3),cout<<"★";
    else if(a==7) Color(2),cout<<"◆";
}
void Map(int a){
    for(int i=1-a;i<=Mapsize-1+a;i++)
    for(int j=1-a;j<=Mapsize-1+a;j++){Cout(i,j,a,0);}
    Setpos(32,3);Color(1),cout<<"Score: "<<Score;
    Setpos(32,10);Col

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值