问题标题: c++游戏代码

0
0
已解决
郝天尘
郝天尘
资深光能
资深光能

如上

郝天尘在2022-08-28 08:54:47追加了内容

我的

#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
#include<queue>
#include<ctype.h>
#define A 17    //地图的高
#define B 17    //地图的宽
#define C 30    //雷的总数
using namespace std;
 
//全局变量
DWORD a,b;
char map[A][B],news,spare;
int BoomTotalNum,floatx,floaty,flag[A][B],flagnum,mode,slect[A][B],game;
 
//颜色属**
const WORD FORE_BLUE  =  FOREGROUND_BLUE;    //蓝色文本属**
const WORD FORE_GREEN = FOREGROUND_GREEN;    //绿色文本属**
const WORD FORE_RED   =   FOREGROUND_RED;    //红色文本属**
 
//开垦地图结构体
struct node {
    int x;
    int y;
};
queue <node> dui;
 
//打印位置
void position(int x,int y) {
    COORD pos={x,y};
    HANDLE Out=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(Out,pos);
}
 
//隐藏光标
void Hide() {
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);  
    CONSOLE_CURSOR_INFO CursorInfo;  
    GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息  
    CursorInfo.bVisible = false; //隐藏控制台光标  
    SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态   
}
 
//初始化
void Beginning() {
    while(!dui.empty()) {
        dui.pop();
    }
    game=1;
    //BoomTotalNum=C;
    floatx=A/2;
    floaty=B/2;
    flagnum=0;
    BoomTotalNum=C;
    mode=0;
    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);    //获得标准输出设备句柄  
    CONSOLE_SCREEN_BUFFER_INFO csbi;                        //定义窗口缓冲区信息结构体  
    GetConsoleScreenBufferInfo(handle_out, &csbi);          //获得窗口缓冲区信息
    int x,y;
    srand((unsigned)time(0));
    for(int i=0;i<A;i++) for(int j=0;j<B;j++) {
        map[i][j]=' ';
        flag[i][j]=0;
        slect[i][j]=0;
    }
    while(BoomTotalNum) {
        x=rand()%A;
        y=rand()%B;
        if(map[x][y]==' ') {
            map[x][y]='@';
            BoomTotalNum--;
        }
    }
    SetConsoleTextAttribute(handle_out, FORE_GREEN);  
    for(int i=0;i<A;i++) {
        for(int j=0;j<B;j++) printf("█");
        printf("\n");
    }
    position(floaty*2,floatx);
    SetConsoleTextAttribute(handle_out, FORE_RED);  
    printf("");    //光标位置
    position(5,22);
    printf("按“空格”切换模式");
    position(5,23);
    printf("按“Enter”确认");
    position(5,24);
    printf("按“方向键”选择方块");
    
}
 
//打印地图的一块儿
void Lump(int xx,int yy) {
    switch(map[xx][yy]) {
        case '1' : printf("①");break;    //周围雷的数量(下同)
        case '2' : printf("②");break;
        case '3' : printf("③");break;
        case '4' : printf("④");break;
        case '5' : printf("⑤");break;
        case '6' : printf("⑥");break;
        case '7' : printf("⑦");break;
        case '8' : printf("⑧");break;
        case ' ' :
            if(xx==floatx&&yy==floaty) {
                if(flag[xx][yy]==0) {
                    if(mode%2==0) printf("");
                    else printf("");
                }
                else printf("");
            }
            else {
                if(flag[xx][yy]==0) printf("█");
                else printf("");
            }
            break;
        case '@' :
            if(xx==floatx&&yy==floaty) {
                if(flag[xx][yy]==0) {
                    if(mode%2==0) printf("");
                    else printf("");
                }
                else printf("");
            }
            else {
                if(flag[xx][yy]==0) printf("█");
                else printf("");
            }
            break;
        case 'x' : if(floatx==xx&&floaty==yy) printf(""); else printf("  ");break;    //已经挖开的空白
    }
}
 
//移动光标
void Move() {
    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);    //获得标准输出设备句柄  
    CONSOLE_SCREEN_BUFFER_INFO csbi;                        //定义窗口缓冲区信息结构体  
    GetConsoleScreenBufferInfo(handle_out, &csbi);          //获得窗口缓冲区信息
    int xxx,yyy;
    xxx=floatx;
    yyy=floaty;
    switch(news) {
        case 72 : floatx--;break;    //上
        case 80 : floatx++;break;    //下
        case 75 : floaty--;break;    //左
        case 77 : floaty++;break;    //右
    }
    if(floatx==-1) floatx=A-1; floatx%=A;    //两端穿模处理
    if(floaty==-1) floaty=B-1; floaty%=B;
    
    position(yyy*2,xxx);
    SetConsoleTextAttribute(handle_out, FORE_GREEN);
    Lump(xxx,yyy);    //删除原位置
    
    if(map[floatx][floaty]=='x') {
        position(floaty*2,floatx);
        printf("  ");
    }
    
    position(floaty*2,floatx);
    SetConsoleTextAttribute(handle_out, FORE_BLUE);  
    Lump(floatx,floaty);    //更新新位置
}
 
//插旗和排雷模式切换
void Mode() {
    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);    //获得标准输出设备句柄  
    CONSOLE_SCREEN_BUFFER_INFO csbi;                        //定义窗口缓冲区信息结构体  
    GetConsoleScreenBufferInfo(handle_out, &csbi);          //获得窗口缓冲区信息
    mode++;
    SetConsoleTextAttribute(handle_out, FORE_BLUE);
    position(floaty*2,floatx);
    if(mode%2==0) printf("");
    else printf("");
    
    position(44,9);
    if(mode%2==0) {
        SetConsoleTextAttribute(handle_out, FORE_BLUE);  
        printf("建设模式");
    }
    else {
        SetConsoleTextAttribute(handle_out, FORE_RED);  
        printf("挖掘模式");
    }
}
 
//该点周围地雷数
int Boomnum(int xx,int yy) {
    int num=0;
    if((xx-1>=0)&&(yy-1>=0)&&(map[xx-1][yy-1]=='@')) num++;
    if((xx-1>=0)&&(yy+0>=0)&&(map[xx-1][yy]=='@')) num++;
    if((xx-1>=0)&&(yy+1<B) &&(map[xx-1][yy+1]=='@')) num++;
    if((xx+0>=0)&&(yy-1>=0)&&(map[xx][yy-1]=='@')) num++;
    if((xx+0>=0)&&(yy+1<B) &&(map[xx][yy+1]=='@')) num++;
    if((xx+1<A)&&(yy-1>=0) &&(map[xx+1][yy-1]=='@')) num++;
    if((xx+1<A)&&(yy+0>=0) &&(map[xx+1][yy]=='@')) num++;
    if((xx+1<A)&&(yy+1<B)  &&(map[xx+1][yy+1]=='@')) num++;
    return num;
}
 
//更新地图
void Open() {
    node c;
    node d;
    while(!dui.empty()) {
        dui.pop();
    }
    c.x=floatx;
    c.y=floaty;
    dui.push(c);
    slect[c.x][c.y]=1;
    while(!dui.empty()) {
        c=dui.front();
        dui.pop();
        if(Boomnum(c.x,c.y)!=0) {
            map[c.x][c.y]=(Boomnum(c.x,c.y)+48);
            continue;
        }
        else {
            map[c.x][c.y]='x';                                                                                                                                                                                                                                                                                                                                                                                                                                     
            if((c.x-1>=0)&&(c.y-1>=0)&&(map[c.x-1][c.y-1]==' ')&&(slect[c.x-1][c.y-1]==0)) {
                d.x=c.x-1;
                d.y=c.y-1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x-1>=0)&&(c.y-0>=0)&&(map[c.x-1][c.y]==' ')&&(slect[c.x-1][c.y]==0)) {
                d.x=c.x-1;
                d.y=c.y-0;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x-1>=0)&&(c.y+1<B)&&(map[c.x-1][c.y+1]==' ')&&(slect[c.x-1][c.y+1]==0)) {
                d.x=c.x-1;
                d.y=c.y+1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x-0>=0)&&(c.y-1>=0)&&(map[c.x][c.y-1]==' ')&&(slect[c.x][c.y-1]==0)) {
                d.x=c.x-0;
                d.y=c.y-1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x-0>=0)&&(c.y+1<B)&&(map[c.x][c.y+1]==' ')&&(slect[c.x][c.y+1]==0)) {
                d.x=c.x-0;
                d.y=c.y+1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x+1<A)&&(c.y-1>=0)&&(map[c.x+1][c.y-1]==' ')&&(slect[c.x+1][c.y-1]==0)) {
                d.x=c.x+1;
                d.y=c.y-1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x+1<A)&&(c.y-0>=0)&&(map[c.x+1][c.y]==' ')&&(slect[c.x+1][c.y]==0)) {
                d.x=c.x+1;
                d.y=c.y-0;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x+1<A)&&(c.y+1<B)&&(map[c.x+1][c.y+1]==' ')&&(slect[c.x+1][c.y+1]==0)) {
                d.x=c.x+1;
                d.y=c.y+1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
        }
    }
}
 
int main() {
    freopen("排名.txt","r",stdin);
    Relife:    //重玩处
    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);    //获得标准输出设备句柄  
    CONSOLE_SCREEN_BUFFER_INFO csbi;                        //定义窗口缓冲区信息结构体  
    GetConsoleScreenBufferInfo(handle_out, &csbi);          //获得窗口缓冲区信息
    
    Hide();        //隐藏光标
    Beginning();//初始化地图
    a=GetTickCount();
    while(1) {
        if(kbhit()!=0) {
            spare=getch();
            
            //按其他
            if((spare!=(-32))&&(spare!=13)&&(spare!=' ')) continue;//跳过
            
            //按Enter
            if(spare==13) {    //确认
                //排雷
                if(mode%2==0) {
                    if(map[floatx][floaty]=='@'&&flag[floatx][floaty]==0) {
                        break;    //触雷
                        game=0;
                    }
                    
                    if(flag[floatx][floaty]==1) continue;    //有旗跳过
                    Open();
                    position(0,0);
                    SetConsoleTextAttribute(handle_out, FORE_GREEN);
                    for(int i=0;i<A;i++) {
                        for(int j=0;j<B;j++) Lump(i,j);
                        printf("\n");
                    }
                    position(floaty*2,floatx);
                    SetConsoleTextAttribute(handle_out, FORE_BLUE);
                    Lump(floatx,floaty);
                }
                
                //插拔旗
                else {
                    
                    //不能插旗的地方
                    if(map[floatx][floaty]=='x'||(map[floatx][floaty]>'0'&&map[floatx][floaty]<'9'))
                        continue;    //跳过
                    
                    //插旗
                    if(flag[floatx][floaty]==0) {
                        flagnum++;
                        flag[floatx][floaty]=1;
                        position(floaty*2,floatx);
                        SetConsoleTextAttribute(handle_out, FORE_BLUE);
                        Lump(floatx,floaty);
                    }
                    
                    //拔旗
                    else {
                        flagnum--;
                        flag[floatx][floaty]=0;
                        position(floaty*2,floatx);
                        SetConsoleTextAttribute(handle_out, FORE_BLUE);
                        Lump(floatx,floaty);
                    }
                }
            }
            
            //按空格
            if(spare==' ') Mode();    //切换模式
            
            //按方向键
            if(spare==-32) {
                news=getch();
                Move();    //移动光标
            }
            for(int i=0;i<A;i++) for(int j=0;j<B;j++) if(map[i][j]=='x'||(map[i][j]>'0'&&map[i][j]<'9')) game++;
            if(game==A*B-C+1) break;
            else game=1;
            SetConsoleTextAttribute(handle_out, FORE_RED);
            position(44,5);
            printf("剩余雷数:%d ",C-flagnum);
        }
        else Sleep(10);
        b=GetTickCount();
        SetConsoleTextAttribute(handle_out, FORE_RED);
        position(44,7);
        printf("用时:");    //用时
        if((b-a)/60000<10) printf("0");
        printf("%d:",(b-a)/60000);
        if(((b-a)/1000)%60<10) printf("0");
        printf("%d:",((b-a)/1000)%60);
        if(((b-a)/10)%100<10) printf("0");
        printf("%d",((b-a)/10)%100);
    }
    SetConsoleTextAttribute(handle_out, FORE_RED);
    position(5,5);
    if(game==1) printf("游戏结束!");
    else printf("建设成功!");
    position(5,8);
    printf("任意键重玩");
    scanf("%c%c",&spare,&spare);
    system("cls");
    position(0,0);
    goto Relife;
}

 


0
已采纳
被禁言 汪声旭
汪声旭
高级守护
高级守护
#include<iostream>
#include<cstdio>
#include<windows.h>
#include<conio.h>
using namespace std;
int SIZ = 20;
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;
HANDLE hCon;
enum Color { DARKBLUE = 1, DARKGREEN, DARKTEAL, DARKRED, DARKPINK, DARKYELLOW, GRAY, DARKGRAY, BLUE, GREEN, TEAL, RED, PINK, YELLOW, WHITE };
void SetColor(Color c) {
    if(hCon == NULL)
        hCon = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hCon, c);
}
SYSTEMTIME sys;
//sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds,sys.wDayOfWeek
struct PLAYER {
    int x,y;
    int hp;
    int gun;
    int direct;
} p1,p2;
int map[1005][1005];
int abs(int x) {
    if(x < 0) return -x;
    return x;
}
void locate(int x,int y) {
    coord.X=y - 1;
    coord.Y=x - 1;
    SetConsoleCursorPosition(hout,coord);
}
void print_map() {
    locate(1,1);
    SetColor(GRAY);
    for(int i = 1; i <= SIZ; i++) cout<<"■";
    locate(SIZ,1);
    for(int i = 1; i <= SIZ; i++) cout<<"■";
    for(int i = 2; i < SIZ; i++) {
        locate(i,1);
        cout<<"■";
        locate(i,SIZ*2-1);
        cout<<"■";
    }
    locate(SIZ+1,1);
    SetColor(WHITE);
}
void create_tree(int x,int y) {
    map[x][y] = map[x+1][y] = map[x-1][y] = map[x][y+1] = map[x][y-1] = 2;
}
void use_map(int x) {
    if(x == 1) {
        SIZ = 20;
        SetColor(DARKGREEN);
        map[16][6]=map[15][6]=map[17][6]=map[16][7]=map[16][5]=map[14][13]=map[13][12]=map[13][13]=2;
        for(int i = 2; i < SIZ; i++) {
            for(int j = 2; j < SIZ; j++) {
                if(map[i][j] == 2) {
                    locate(i,j*2-1);
                    cout<<"■";
                }
            }
        }
        SetColor(GRAY);
        for(int i = 5; i <= 15; i++) {
            map[i][i] = 1;
            locate(i,i*2-1);
            cout<<"■";
        }
        SetColor(WHITE);
    } else if(x == 2) {
        SIZ = 30;
        SetColor(GRAY);
        for(int i = 4; i <= 26; i++) {
            if(i == 13 || i == 14 ||i == 15) continue;
            map[i][4] = map[4][i] = map[26][i] = map[i][26] = 1;
        }
        for(int i = 1; i <= SIZ; i++) {
            for(int j = 1; j <= SIZ; j++) {
                if(map[i][j] == 1) {
                    locate(i,j*2-1);
                    cout<<"■";
                }
            }
        }
        SetColor(DARKGREEN);
        for(int i = 10; i<=20; i++) {
            if(i == 13 || i == 17) continue;
            map[i][10] = map[10][i] = map[20][i] = map[i][20] = 2;
        }
        create_tree(5,5);
        create_tree(18,18);
        for(int i = 1; i <= SIZ; i++) {
            for(int j = 1; j <= SIZ; j++) {
                if(map[i][j] == 2) {
                    locate(i,j*2-1);
                    cout<<"■";
                }
            }
        }
        SetColor(WHITE);
    }
}
void cleanbody(int x,int y);
void putbody(int x,int y,int z);
void player_init() {
    p1.hp = p2.hp = 300;
    p1.gun = p2.gun = 1;
    p1.direct = 4;
    p2.direct = 2;
    p1.x = 2;
    p1.y = 2;
    p2.x = SIZ - 1;
    p2.y = SIZ - 1;
    putbody(p1.x,p1.y,1);
    putbody(p2.x,p2.y,2);
}
void mapinit() {
    for(int i = 1; i <= SIZ; i++) {
        map[i][1] = map[1][i] = map[SIZ][i] = map[i][SIZ] = 1;
    }
}
void init() {
    printf("Use Which Map?\n");
    int x;
    cin>>x;
    system("cls");
    use_map(x);
    mapinit();
    print_map();
    player_init();
}
void putbody(int x,int y,int z) {
    if(z == 1) SetColor(BLUE);
    else if(z == 2) SetColor(RED);
    locate(x,y*2-1);
    cout<<"■";
    SetColor(WHITE);
}
void cleanbody(int x,int y) {
    locate(x,y*2-1);
    cout<<" ";
}
/*
    LIST
    direct:
        w 1
        a 2
        s 3
        d 4
    gun:
        usp 1
        mimigun 2
        awp 3
    block:
        void 0
        stone 1
        tree 2
        player 3
        clip 4
*/
bool judge(int x,int y) {
    if(map[x][y] == 1) return false;
    if(map[x][y] == 2) return false;
    if(map[x][y] == 3) return false;
    return true;
}
bool judge_gun(int x,int y) {
    if(map[x][y] == 1) return 0;
    if(map[x][y] == 2) return 0;
    if(map[x][y] == 3) {
        if(p1.x == x && p1.y == y) p1.hp -= 50;//此处暂时不管威力
        else p2.hp -= 50;
        return 0;
    }
    return 1;
}
int cnt;
struct Clip {
    int x,y;
    int derect;
    int force;
    int start;
    bool flag;
} clip[1000000];
void create_clip(int y,int x,int a,int b) {
    int X,Y;
    if(y == 1) {
        if(!judge_gun(a-1,b)) return;
        X = a-1;
        Y = b;
    } else if(y == 2) {
        if(!judge_gun(a,b-1)) return;
        X = a;
        Y = b-1;
    } else if(y == 3) {
        if(!judge_gun(a+1,b)) return;
        X = a+1;
        Y = b;
    } else if(y == 4) {
        if(!judge_gun(a,b+1)) return;
        X = a;
        Y = b+1;
    }
    cnt++;
    GetLocalTime( &sys );
    clip[cnt].start = sys.wMilliseconds + sys.wSecond * 60 + sys.wHour * 3600;
    clip[cnt].x = X;
    clip[cnt].y = Y;
    if(x == 1) {
        clip[cnt].derect = p1.direct;
    } else if(x == 2) {
        clip[cnt].derect = p2.direct;
    }
}
void shoot(int x) {
    if(x == 1) {
        create_clip(p1.direct,1,p1.x,p1.y);
    } else if(x == 2) {
        create_clip(p2.direct,2,p2.x,p2.y);
    }
}
void clean_clip(int x,int y) {
    locate(x,y*2-1);
    cout<<"  ";
    locate(1,1);
}
void print_clip(int x,int y,int i) {
    if(clip[i].flag) {
        clean_clip(x,y);
        return;
    }
    locate(x,y*2-1);
    SetColor(YELLOW);
    cout<<"''";
    locate(1,1);
//  system("pause");
}
void clipmove() {
    GetLocalTime( &sys );
    int t = sys.wMilliseconds + sys.wSecond * 60 + sys.wHour * 3600;
    for(int i = 1; i <= cnt; i++) {
        if(clip[i].flag) continue;
        if(abs(clip[i].start - t) > 50) {
            clip[i].start = t;
            int x = clip[i].x;
            int y = clip[i].y;
            if(clip[i].derect==1) {
                if(!judge_gun(clip[i].x-1,clip[i].y)) {
                    clip[i].flag = 1;
                    clean_clip(x,y);
                    continue;
                }
                clean_clip(clip[i].x,clip[i].y);
                clip[i].x--;
                print_clip(clip[i].x,clip[i].y,i);
            } else if(clip[i].derect==2) {
                if(!judge_gun(clip[i].x,clip[i].y-1)) {
                    clip[i].flag = 1;
                    clean_clip(x,y);
                    continue;
                }
                clean_clip(clip[i].x,clip[i].y);
                clip[i].y--;
                print_clip(clip[i].x,clip[i].y,i);
            } else if(clip[i].derect==3) {
                if(!judge_gun(clip[i].x+1,clip[i].y)) {
                    clip[i].flag = 1;
                    clean_clip(x,y);
                    continue;
                }
                clean_clip(clip[i].x,clip[i].y);
                clip[i].x++;
                print_clip(clip[i].x,clip[i].y,i);
            } else if(clip[i].derect==4) {
                if(!judge_gun(clip[i].x,clip[i].y+1)) {
                    clip[i].flag = 1;
                    clean_clip(x,y);
                    continue;
                }
                clean_clip(clip[i].x,clip[i].y);
                clip[i].y++;
                print_clip(clip[i].x,clip[i].y,i);
            }
        }
    }
}
void judge_hp() {
    int x = p1.hp;
    int y = p2.hp;
    if(x<0 && y<0 && x > y) swap(x,y);
    if(x <= 0) {
        locate(1,1);
        system("cls");
        printf("** OVER!\nTHE WINNER IS P2!");
        Sleep(5000);
        printf("\n-MADE BY Floatiy-");
        exit(0);
    } else if(y <= 0) {
        locate(1,1);
        system("cls");
        printf("** OVER!\nTHE WINNER IS P1!");
        Sleep(5000);
        printf("\n-MADE BY Floatiy-");
        exit(0);
    }
}
void prog() {
    char ch;
    while(true) {
        if(kbhit()) {
            ch=getch();
            if(ch == 'w' && judge(p1.x-1,p1.y)) {
                p1.direct = 1;
                cleanbody(p1.x,p1.y);
                map[p1.x][p1.y] = 0;
                putbody(--p1.x,p1.y,1);
                map[p1.x][p1.y] = 3;
            } else if(ch == '8' && judge(p2.x-1,p2.y)) {
                p2.direct = 1;
                cleanbody(p2.x,p2.y);
                map[p2.x][p2.y] = 0;
                putbody(--p2.x,p2.y,2);
                map[p2.x][p2.y] = 3;
            } else if(ch == 'a' && judge(p1.x,p1.y-1)) {
                p1.direct = 2;
                cleanbody(p1.x,p1.y);
                map[p1.x][p1.y] = 0;
                putbody(p1.x,--p1.y,1);
                map[p1.x][p1.y] = 3;
            } else if(ch == '4' && judge(p2.x,p2.y-1)) {
                p2.direct = 2;
                cleanbody(p2.x,p2.y);
                map[p2.x][p2.y] = 0;
                putbody(p2.x,--p2.y,2);
                map[p2.x][p2.y] = 3;
            } else if(ch == 's' && judge(p1.x+1,p1.y)) {
                p1.direct = 3;
                cleanbody(p1.x,p1.y);
                map[p1.x][p1.y] = 0;
                putbody(++p1.x,p1.y,1);
                map[p1.x][p1.y] = 3;
            } else if(ch == '5' && judge(p2.x+1,p2.y)) {
                p2.direct = 3;
                cleanbody(p2.x,p2.y);
                map[p2.x][p2.y] = 0;
                putbody(++p2.x,p2.y,2);
                map[p2.x][p2.y] = 3;
            } else if(ch == 'd' && judge(p1.x,p1.y+1)) {
                p1.direct = 4;
                cleanbody(p1.x,p1.y);
                map[p1.x][p1.y] = 0;
                putbody(p1.x,++p1.y,1);
                map[p1.x][p1.y] = 3;
            } else if(ch == '6' && judge(p2.x,p2.y+1)) {
                p2.direct = 4;
                cleanbody(p2.x,p2.y);
                map[p2.x][p2.y] = 0;
                putbody(p2.x,++p2.y,2);
                map[p2.x][p2.y] = 3;
            } else if(ch == '0') {
                shoot(2);
            } else if(ch == ' ') {
                shoot(1);
            }
            Sleep(20);
        }
        clipmove();
        judge_hp();
    }
}
void welcome() {
    printf("操作方法:\n玩家1 wasd控制移动,空格攻击\n玩家2 数字小键盘4568控制移动,0攻击\n");
    Sleep(2000);
}
int main() {
    welcome();
    GetLocalTime( &sys );
    init();
    prog();
    return 0;
}
 

网上

0
0
郝天尘
郝天尘
资深光能
资深光能

#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
#include<queue>
#include<ctype.h>
#define A 17    //地图的高
#define B 17    //地图的宽
#define C 30    //雷的总数
using namespace std;
 
//全局变量
DWORD a,b;
char map[A][B],news,spare;
int BoomTotalNum,floatx,floaty,flag[A][B],flagnum,mode,slect[A][B],game;
 
//颜色属**
const WORD FORE_BLUE  =  FOREGROUND_BLUE;    //蓝色文本属**
const WORD FORE_GREEN = FOREGROUND_GREEN;    //绿色文本属**
const WORD FORE_RED   =   FOREGROUND_RED;    //红色文本属**
 
//开垦地图结构体
struct node {
    int x;
    int y;
};
queue <node> dui;
 
//打印位置
void position(int x,int y) {
    COORD pos={x,y};
    HANDLE Out=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(Out,pos);
}
 
//隐藏光标
void Hide() {
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);  
    CONSOLE_CURSOR_INFO CursorInfo;  
    GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息  
    CursorInfo.bVisible = false; //隐藏控制台光标  
    SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态   
}
 
//初始化
void Beginning() {
    while(!dui.empty()) {
        dui.pop();
    }
    game=1;
    //BoomTotalNum=C;
    floatx=A/2;
    floaty=B/2;
    flagnum=0;
    BoomTotalNum=C;
    mode=0;
    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);    //获得标准输出设备句柄  
    CONSOLE_SCREEN_BUFFER_INFO csbi;                        //定义窗口缓冲区信息结构体  
    GetConsoleScreenBufferInfo(handle_out, &csbi);          //获得窗口缓冲区信息
    int x,y;
    srand((unsigned)time(0));
    for(int i=0;i<A;i++) for(int j=0;j<B;j++) {
        map[i][j]=' ';
        flag[i][j]=0;
        slect[i][j]=0;
    }
    while(BoomTotalNum) {
        x=rand()%A;
        y=rand()%B;
        if(map[x][y]==' ') {
            map[x][y]='@';
            BoomTotalNum--;
        }
    }
    SetConsoleTextAttribute(handle_out, FORE_GREEN);  
    for(int i=0;i<A;i++) {
        for(int j=0;j<B;j++) printf("█");
        printf("\n");
    }
    position(floaty*2,floatx);
    SetConsoleTextAttribute(handle_out, FORE_RED);  
    printf("");    //光标位置
    position(5,22);
    printf("按“空格”切换模式");
    position(5,23);
    printf("按“Enter”确认");
    position(5,24);
    printf("按“方向键”选择方块");
    
}
 
//打印地图的一块儿
void Lump(int xx,int yy) {
    switch(map[xx][yy]) {
        case '1' : printf("①");break;    //周围雷的数量(下同)
        case '2' : printf("②");break;
        case '3' : printf("③");break;
        case '4' : printf("④");break;
        case '5' : printf("⑤");break;
        case '6' : printf("⑥");break;
        case '7' : printf("⑦");break;
        case '8' : printf("⑧");break;
        case ' ' :
            if(xx==floatx&&yy==floaty) {
                if(flag[xx][yy]==0) {
                    if(mode%2==0) printf("");
                    else printf("");
                }
                else printf("");
            }
            else {
                if(flag[xx][yy]==0) printf("█");
                else printf("");
            }
            break;
        case '@' :
            if(xx==floatx&&yy==floaty) {
                if(flag[xx][yy]==0) {
                    if(mode%2==0) printf("");
                    else printf("");
                }
                else printf("");
            }
            else {
                if(flag[xx][yy]==0) printf("█");
                else printf("");
            }
            break;
        case 'x' : if(floatx==xx&&floaty==yy) printf(""); else printf("  ");break;    //已经挖开的空白
    }
}
 
//移动光标
void Move() {
    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);    //获得标准输出设备句柄  
    CONSOLE_SCREEN_BUFFER_INFO csbi;                        //定义窗口缓冲区信息结构体  
    GetConsoleScreenBufferInfo(handle_out, &csbi);          //获得窗口缓冲区信息
    int xxx,yyy;
    xxx=floatx;
    yyy=floaty;
    switch(news) {
        case 72 : floatx--;break;    //上
        case 80 : floatx++;break;    //下
        case 75 : floaty--;break;    //左
        case 77 : floaty++;break;    //右
    }
    if(floatx==-1) floatx=A-1; floatx%=A;    //两端穿模处理
    if(floaty==-1) floaty=B-1; floaty%=B;
    
    position(yyy*2,xxx);
    SetConsoleTextAttribute(handle_out, FORE_GREEN);
    Lump(xxx,yyy);    //删除原位置
    
    if(map[floatx][floaty]=='x') {
        position(floaty*2,floatx);
        printf("  ");
    }
    
    position(floaty*2,floatx);
    SetConsoleTextAttribute(handle_out, FORE_BLUE);  
    Lump(floatx,floaty);    //更新新位置
}
 
//插旗和排雷模式切换
void Mode() {
    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);    //获得标准输出设备句柄  
    CONSOLE_SCREEN_BUFFER_INFO csbi;                        //定义窗口缓冲区信息结构体  
    GetConsoleScreenBufferInfo(handle_out, &csbi);          //获得窗口缓冲区信息
    mode++;
    SetConsoleTextAttribute(handle_out, FORE_BLUE);
    position(floaty*2,floatx);
    if(mode%2==0) printf("");
    else printf("");
    
    position(44,9);
    if(mode%2==0) {
        SetConsoleTextAttribute(handle_out, FORE_BLUE);  
        printf("建设模式");
    }
    else {
        SetConsoleTextAttribute(handle_out, FORE_RED);  
        printf("挖掘模式");
    }
}
 
//该点周围地雷数
int Boomnum(int xx,int yy) {
    int num=0;
    if((xx-1>=0)&&(yy-1>=0)&&(map[xx-1][yy-1]=='@')) num++;
    if((xx-1>=0)&&(yy+0>=0)&&(map[xx-1][yy]=='@')) num++;
    if((xx-1>=0)&&(yy+1<B) &&(map[xx-1][yy+1]=='@')) num++;
    if((xx+0>=0)&&(yy-1>=0)&&(map[xx][yy-1]=='@')) num++;
    if((xx+0>=0)&&(yy+1<B) &&(map[xx][yy+1]=='@')) num++;
    if((xx+1<A)&&(yy-1>=0) &&(map[xx+1][yy-1]=='@')) num++;
    if((xx+1<A)&&(yy+0>=0) &&(map[xx+1][yy]=='@')) num++;
    if((xx+1<A)&&(yy+1<B)  &&(map[xx+1][yy+1]=='@')) num++;
    return num;
}
 
//更新地图
void Open() {
    node c;
    node d;
    while(!dui.empty()) {
        dui.pop();
    }
    c.x=floatx;
    c.y=floaty;
    dui.push(c);
    slect[c.x][c.y]=1;
    while(!dui.empty()) {
        c=dui.front();
        dui.pop();
        if(Boomnum(c.x,c.y)!=0) {
            map[c.x][c.y]=(Boomnum(c.x,c.y)+48);
            continue;
        }
        else {
            map[c.x][c.y]='x';                                                                                                                                                                                                                                                                                                                                                                                                                                     
            if((c.x-1>=0)&&(c.y-1>=0)&&(map[c.x-1][c.y-1]==' ')&&(slect[c.x-1][c.y-1]==0)) {
                d.x=c.x-1;
                d.y=c.y-1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x-1>=0)&&(c.y-0>=0)&&(map[c.x-1][c.y]==' ')&&(slect[c.x-1][c.y]==0)) {
                d.x=c.x-1;
                d.y=c.y-0;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x-1>=0)&&(c.y+1<B)&&(map[c.x-1][c.y+1]==' ')&&(slect[c.x-1][c.y+1]==0)) {
                d.x=c.x-1;
                d.y=c.y+1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x-0>=0)&&(c.y-1>=0)&&(map[c.x][c.y-1]==' ')&&(slect[c.x][c.y-1]==0)) {
                d.x=c.x-0;
                d.y=c.y-1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x-0>=0)&&(c.y+1<B)&&(map[c.x][c.y+1]==' ')&&(slect[c.x][c.y+1]==0)) {
                d.x=c.x-0;
                d.y=c.y+1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x+1<A)&&(c.y-1>=0)&&(map[c.x+1][c.y-1]==' ')&&(slect[c.x+1][c.y-1]==0)) {
                d.x=c.x+1;
                d.y=c.y-1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x+1<A)&&(c.y-0>=0)&&(map[c.x+1][c.y]==' ')&&(slect[c.x+1][c.y]==0)) {
                d.x=c.x+1;
                d.y=c.y-0;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
            if((c.x+1<A)&&(c.y+1<B)&&(map[c.x+1][c.y+1]==' ')&&(slect[c.x+1][c.y+1]==0)) {
                d.x=c.x+1;
                d.y=c.y+1;
                dui.push(d);
                slect[d.x][d.y]=1;
            }
        }
    }
}
 
int main() {
    freopen("排名.txt","r",stdin);
    Relife:    //重玩处
    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);    //获得标准输出设备句柄  
    CONSOLE_SCREEN_BUFFER_INFO csbi;                        //定义窗口缓冲区信息结构体  
    GetConsoleScreenBufferInfo(handle_out, &csbi);          //获得窗口缓冲区信息
    
    Hide();        //隐藏光标
    Beginning();//初始化地图
    a=GetTickCount();
    while(1) {
        if(kbhit()!=0) {
            spare=getch();
            
            //按其他
            if((spare!=(-32))&&(spare!=13)&&(spare!=' ')) continue;//跳过
            
            //按Enter
            if(spare==13) {    //确认
                //排雷
                if(mode%2==0) {
                    if(map[floatx][floaty]=='@'&&flag[floatx][floaty]==0) {
                        break;    //触雷
                        game=0;
                    }
                    
                    if(flag[floatx][floaty]==1) continue;    //有旗跳过
                    Open();
                    position(0,0);
                    SetConsoleTextAttribute(handle_out, FORE_GREEN);
                    for(int i=0;i<A;i++) {
                        for(int j=0;j<B;j++) Lump(i,j);
                        printf("\n");
                    }
                    position(floaty*2,floatx);
                    SetConsoleTextAttribute(handle_out, FORE_BLUE);
                    Lump(floatx,floaty);
                }
                
                //插拔旗
                else {
                    
                    //不能插旗的地方
                    if(map[floatx][floaty]=='x'||(map[floatx][floaty]>'0'&&map[floatx][floaty]<'9'))
                        continue;    //跳过
                    
                    //插旗
                    if(flag[floatx][floaty]==0) {
                        flagnum++;
                        flag[floatx][floaty]=1;
                        position(floaty*2,floatx);
                        SetConsoleTextAttribute(handle_out, FORE_BLUE);
                        Lump(floatx,floaty);
                    }
                    
                    //拔旗
                    else {
                        flagnum--;
                        flag[floatx][floaty]=0;
                        position(floaty*2,floatx);
                        SetConsoleTextAttribute(handle_out, FORE_BLUE);
                        Lump(floatx,floaty);
                    }
                }
            }
            
            //按空格
            if(spare==' ') Mode();    //切换模式
            
            //按方向键
            if(spare==-32) {
                news=getch();
                Move();    //移动光标
            }
            for(int i=0;i<A;i++) for(int j=0;j<B;j++) if(map[i][j]=='x'||(map[i][j]>'0'&&map[i][j]<'9')) game++;
            if(game==A*B-C+1) break;
            else game=1;
            SetConsoleTextAttribute(handle_out, FORE_RED);
            position(44,5);
            printf("剩余雷数:%d ",C-flagnum);
        }
        else Sleep(10);
        b=GetTickCount();
        SetConsoleTextAttribute(handle_out, FORE_RED);
        position(44,7);
        printf("用时:");    //用时
        if((b-a)/60000<10) printf("0");
        printf("%d:",(b-a)/60000);
        if(((b-a)/1000)%60<10) printf("0");
        printf("%d:",((b-a)/1000)%60);
        if(((b-a)/10)%100<10) printf("0");
        printf("%d",((b-a)/10)%100);
    }
    SetConsoleTextAttribute(handle_out, FORE_RED);
    position(5,5);
    if(game==1) printf("游戏结束!");
    else printf("建设成功!");
    position(5,8);
    printf("任意键重玩");
    scanf("%c%c",&spare,&spare);
    system("cls");
    position(0,0);
    goto Relife;
}

0
被禁言 汪声旭
汪声旭
高级守护
高级守护
#include<stdio.h>
#include<ctime>
#include<time.h> //suiji
#include<windows.h> //SLEEP函数
struct Player //玩家结构体,并初始化player
{
char name[21];
int attack;
int defense;
int health;
long int max_health;
int level;
int exp;
int range_exp;
long int max_exp;
} player= {"勇者",50,40,100,100,1,0,0,100};
struct Enemy //怪的结构体,并初始化各种怪
{
char name[20];
char wupin[12];
int attack;
int defense;
int health;
int money;
long int exp;
int wupin_sign;
int wupinpro;
int double_attack;
int miss;
} strongman= {"森林巨人","黄金圣衣",40,50,350,200,100,1,2,1,0},
witch= {"森林女巫","银甲",25,15,100,50,50,2,2,1,1},
xiyi= {"森林蜥蜴","铁甲",18,10,50,30,35,3,3,2,2},
big_strongman= {"森林巨人王","巨人晶石",40*5,50*5,200*5,200*5,100*5,4,4,2,0},
lion= {"草原雄狮","绝世好剑",60,30,280,200,100,5,2,1,0},
horse= {"草原野马","碧血剑",28,12,90,50,50,6,2,1,1},
bee= {"草原黄蜂","长剑",17,11,60,30,35,7,3,2,2},
shitu= {"使徒","\0",60*8,30*8,280*8,200*8,100*8,9,1,1,0},
guai= {"\0","\0",0,0,0,0,0,0,0,0,0};
struct Place
{
int bar,hotel,forest1,forest2,forest3,grass1,grass2,grass3;
} place= {1,2,3,4,5,6,7,8};

int max_exp=0;
int choose_number=0,s=0,strongman_arm=0,battle=0,money=500,place_sign=9;
int cao=3,jijiubao=2,baiyao=2,superbaiyao=1,boom=3,dubiao=2,atom_boom=1;
int fang=0,fang1=10,fang1n=0,fang2=20,fang2n=0,fang3=40,fang3n=0,fang4=100,fang4n=0;
int gong=0,gong1=8,gong1n=0,gong2=15,gong2n=0,gong3=25,gong3n=0,gong4=60,gong4n=0;
int jingyancao=0,jingyanbao=0,jingyanshi=0;
char gongname[20]="无",fangname[20]="无";
char proof;

void AddWupin(int);
int AttackResult();
void BattleAct();
void ChooseWupin();
void DisplayState();
void OrdinaryAct();
int SuiJi();
int SuiJi100();
void WhetherLevelUp();
void SlowDisplay(char *);

int main()
{

int i=0,j=0,k=0;
char player_name[21];
Sleep(1000);
printf("--------------------------欢迎来到 [苍穹世界] 2.2 测试版-----------------------\n\n\n");
//如果想使用**,名字请输入:“**斗士 ”。
Sleep(1000);
printf("这里是苍穹世界! 雅莉**国的罗茜公主被陌生人绑架了!\n\n\n 伟大的勇者啊~拿起你们的武器,营救公主!\n\n\n输入你的名字: (20个字符)\n\n\n");
scanf("%s",player_name);
strncpy(player.name,player_name,20);
if(strcmp(player.name,"**斗士")==0)
{
printf("\n\n\n封印多年的圣剑血统啊!你终于觉醒了!\n\n\n**斗士,你成为了天选之人,请你救出公主吧!\n\n\n");
player.attack=999;
player.defense=999;
player.health=9999;
player.max_health=9999;
}
getchar();

OrdinaryAct();
return 0;
}

int SuiJi()
{
srand((unsigned)time(NULL));
return rand()%10;
}

int SuiJi100()
{
srand((unsigned)time(NULL));
return rand()%100;
}

void ChooseWupin() //选择物品 并使用
{
printf("物品: 1,止血草%d个 2,急救包%d个 3,云南白药%d个 4,超级云南白药%d个 5,手雷%d个 6,毒标%d个 7,手抛式**%d个 8,经验草%d个 9,经验包%d个 10,经验石%d个 11,巨人晶石%d个 0,返回\n\n\n",cao,jijiubao,baiyao,superbaiyao,boom,dubiao,atom_boom,jingyancao,jingyanbao,jingyanshi,strongman_arm);
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
if(cao>0)
{
printf("使用止血草,HP增加60\n\n\n");
cao--;
if(player.health+60>player.max_health)player.health=player.max_health;
else player.health+=60;
}
else printf("没有止血草了\n\n\n");
break;
case 2:
if(jijiubao>0)
{
printf("使用急救包,HP增加80\n\n\n");
jijiubao--;
if(player.health+80>player.max_health)player.health=player.max_health;
else player.health+=80;
}
else printf("没有急救包了\n\n\n");
break;
case 3:
if(baiyao>0)
{
printf("使用云南白药,HP增加120\nz\n\n");
baiyao--;
if(player.health+120>player.max_health)player.health=player.max_health;
else player.health+=120;
}
else printf("没有云南白药了\n\n\n");
break;
case 4:
if(superbaiyao>0)
{
printf("使用超级云南白药,HP增加200\n\n\n");
superbaiyao--;
if(player.health+200>player.max_health)player.health=player.max_health;
else player.health+=200;
}
else printf("没有超级云南白药了\n\n\n");
break;
case 5:
if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击**物品
{
if(boom>0)
{
printf("使用手雷,敌人HP减少100\n\n\n");
boom--;
guai.health-=100;
AttackResult();
}
}
else printf("非战斗状态,不能使用手雷!\n\n\n");
break;
case 6:
if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击**物品
{
if(dubiao>0)
{
printf("使用毒标,敌人HP减少200\n\n\n");
dubiao--;
guai.health-=200;
AttackResult();
}
}
else printf("非战斗状态,不能使用毒标!\n\n\n");
break;
case 7:
if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击**物品
{
if(atom_boom>0)
{
printf("使用手抛式**,敌人HP减少666666666\n\n\n");
atom_boom--;
guai.health-=666666666;
AttackResult();
}
}
else printf("非战斗状态,不能使用手抛式**!\n\n\n");
break;
case 8:
if(jingyancao>0 && player.level<1000)
{

printf("使用经验草,等级增加10级\n\n\n");
jingyancao--;
player.level+=10;
printf("等级:%d\n",player.level);
}
else    if(jingyancao<1)
{
printf("没有经验草了\n\n\n");
}
else printf("等级超过45级,修为太高,无法使用。\n\n\n");
break;
case 9:
if(jingyanbao>0 && player.level<1000)
{
if(player.level>44&&player.level<1000)
{
int sheng;
sheng=45-player.level;
player.level+=sheng;
printf("使用经验包,等级增加%d级",sheng);
printf("等级:%d\n",player.level);
}
else
{

printf("使用经验包,等级增加2级\n\n\n");
jingyanbao--;
player.level+=2;
printf("等级:%d\n",player.level);
}
}
else if(jingyanbao<1)
{
printf("没有经验包了");
}
else printf("等级超过45级,修为太高,无法使用。\n\n\n");
break;
case 10:
if(jingyanshi>0 && player.level<1000)
{
if(player.level>42&&player.level<1000)
{
int sheng;
sheng=45-player.level;
player.level+=sheng;
printf("使用经验石,等级增加%d级\n",sheng);
printf("等级:%d\n",player.level);
}
else
{
printf("使用经验石,等级增加10级\n");
jingyanshi--;
player.level+=10;
}
}
else if(jingyanshi<1)
{
printf("没有经验石了\n\n\n");
}
else printf("等级超过45级,修为太高,无法使用。\n\n\n");
break;
case 11:
if(strongman_arm>0 && player.level<10000)
{
if(player.level>29&&player.level<10000)
{
int sheng;
sheng=45-player.level;
player.level+=sheng;
printf("使用巨人晶石,等级增加%d级",sheng);
printf("等级:%d\n",player.level);
}
else
{
printf("使用巨人晶石,等级增加16级\n\n\n");
strongman_arm--;
player.level+=16;
printf("等级:%d\n",player.level);
}
}
else if(strongman_arm<1)
{
printf("没有巨人晶石了。\n\n\n");
}
else printf("等级超过45级,修为太高,无法使用。\n\n\n");
break;
case 0:
break;
default:
printf("ChooseWupin error!\n\n\n");
}
}

int AttackResult() //攻击结果:判断是否获胜 是否获得物品 和 是否升级
{
if(guai.health<=0)
{
battle=0;
printf("战斗胜利!获得金币%d,经验%d\n\n\n",guai.money,guai.exp);
player.exp+=guai.exp;
player.range_exp+=guai.exp;
money+=guai.money;
s=SuiJi();
if(s<guai.wupinpro)
{
printf("从敌人尸骸中发现");
printf("%s\n\n\n",guai.wupin);
AddWupin(guai.wupin_sign);
}
WhetherLevelUp();
if(strcmp(guai.name,"使徒")==0)
{
printf("战斗胜利,救出公主!!!");
getchar();
getchar();
exit(0);
}
return 1; //攻击有结果了返回1,否则返回0,用于判断是否继续做战斗行为
}
else
{
int s=SuiJi();

if((guai.attack+s-player.defense/3)<0)
{
player.health-=1;
printf("%s反击,你的HP减少了 1\n\n",guai.name);
}
else
{
player.health-=guai.attack+s-player.defense/3;
printf("%s反击,你的HP减少了%d\n\n",guai.name,guai.attack+s-player.defense/3);
}
if(player.health<0)
{
battle=0;
printf("%s战**!金币掉落%d\n\n\n",player.name,player.level*500);
money-=player.level*500;
player.health=player.max_health/5;
OrdinaryAct();//
return 1;
}
}
return 0;
}
void AddWupin(int wupin_sign)
{

switch(wupin_sign)
{
case 1:
fang4n++;
break;
case 2:
fang3n++;
break;
case 3:
fang2n++;
break;
case 4:
strongman_arm=1;
break;
case 5:
gong4n++;
break;
case 6:
gong3n++;
break;
case 7:
gong2n++;
break;
default:
printf("AddWupin error\n\n\n");
}

}
void WhetherLevelUp()
{
int i=0,j=0;
int l1=player.range_exp/100;
int l2=player.range_exp/300;
int l3=player.range_exp/600;
if(player.level<=15&&l1>0) //15级以下,经验足够 都满足则升级
{
if(l1==1)
{
printf("%s",player.name);
printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3;
player.defense+=2;
player.max_health+=20;
player.health=player.max_health;
player.level++;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=100;
}
else
{
printf("好厉害!连升%d级!",l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l1,2*l1,20*l1);
player.exp=(player.exp+guai.exp) || player.exp-((player.exp+guai.exp) || player.exp)%100;
player.attack+=3*l1;
player.defense+=2*l1;
player.max_health+=20*l1;
player.health=player.max_health;
player.level+=l1;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=100*l1;
}
}
else if(player.level<=40&&l2>0)
{
if(l2==1)
{
printf("%s",player.name);
printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3;
player.defense+=2;
player.max_health+=20;
player.health=player.max_health;
player.level++;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=300;
}
else
{
printf("好厉害!连升%d级!",l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l2,2*l2,20*l2);
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3*l2;
player.defense+=2*l2;
player.max_health+=20*l2;
player.health=player.max_health;
player.level+=l2;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=300*l2;
}
}
else if(l3>0)
{
if(l3==1)
{
printf("%s",player.name);
printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3;
player.defense+=2;
player.max_health+=20;
player.health=player.max_health;
player.level++;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=600;
}
else
{
printf("好厉害!连升%d级!",l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l3,2*l3,20*l3);
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3*l3;
player.defense+=2*l3;
player.max_health+=20*l3;
player.health=player.max_health;
player.level+=l3;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=600*l3;
}
}
}
void OrdinaryAct() //正常行为菜单(移动,物品,对话,查看状态,装备,退出游戏)
{

while(1)
{
// \(1000);
// system("cls");
puts("=============================================================================");
printf("要做什么?\n\n\n 1,移动 2,道具 3,对话 4,查看状态 5,装备 6,关于游戏 0,退出游戏\n\n\n");
puts("=============================================================================");
switch(scanf("%d",&choose_number),choose_number)
{
case 1: //显示移动菜单
printf("要去哪里?\n\n\n");
printf("1,happy酒吧 2,**方舟酒店 3,北朝商会 4,红玉拍卖行 5,冒险荒野\n\n\n");
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
place_sign=place.bar; //记录目前位置-酒吧
// OrdinaryAct();
break;
case 2:
place_sign=place.hotel; //进入旅店
printf("金币:%d",money);
printf("要**吗? 200个金币 1,是 0,否\n\n\n");
choose_number=1;
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
if(money-200<0) //判断钱是否够
{
printf("Sorry,你的钱不够~\n\n\n");
printf("金币:%d",money);
}
else
{
printf("好好休息\nHP满\n第二天了\n\n");
printf("金币:%d\n",money);
money-=200; //花费200住店费
player.health=player.max_health; //体力满
}
break;
case 0:
printf("下次再来!\n\n\n");
break;
default:
printf("hotel talk error!\n\n\n");
}
place_sign=0;
break;
case 3:
int yongju,gong,fang;
printf("请问您要购买什么类型的物品?\n\n\n 1,攻击装备 2,防御装备 3,一次**伤害武器\n\n\n");
scanf("%d",&yongju);
switch(yongju)
{
case 1:
printf("请问您要购买什么武器?\n\n\n 1,匕首¥300 2,长剑¥500 3,碧血剑¥1000\n\n\n");
scanf("%d",&gong);
switch(gong)
{
case 1:
if(money>=300)
{
gong1n++;
money=money-300;
printf ("匕首+1\n");
printf("匕首:%d个\n",gong1n);
printf("金币:%d\n",money);
break;
}
else
{
printf("钱不够!\n");
printf("金币:%d\n",money);
break;
}
case 2:
if(money>=500)
{
gong2n++;
money=money-500;
printf ("长剑+1\n");
printf("长剑:%d个\n",gong2n);
printf("金币:%d\n",money);
break;
}
else
{
printf("钱不够!\n");
printf("金币:%d\n",money);
break;
}
case 3:
if(money>=1000)
{
gong3n++;
money=money-1000;
printf ("碧血剑+1\n");
printf("碧血剑:%d个\n",gong3n);
printf("金币:%d\n",money);
break;
}
else
{
printf("钱不够!\n");
printf("金币:%d\n",money);
break;
}
default:
printf("对不起,我们只会打造以上武器。");
break;

}
break;
case 2:
int fang;
printf("请问您要购买什么防具?\n\n\n 1,布衣¥300 2,铁甲¥500 3,银甲¥1000\n\n\n");
scanf("%d",&fang);
switch(fang)
{
case 1:
if(money>=300)
{
fang1n++;
money=money-300;
printf ("布衣+1\n");
printf("布衣:%d个\n",fang1n);
printf("金币:%d\n",money);
}
else
{
printf("钱不够!\n");
printf("金币:%d\n",money);
}

break;
case 2:
if(money>=500)
{
fang2n++;
money=money-500;
printf ("铁甲+1\n");
printf("铁甲:%d个\n",fang2n);
printf("金币:%d\n",money);
}
else
{
printf("钱不够!\n");
printf("金币:%d",money);
}
break;
case 3:
if(money>=1000)
{
fang3n++;
money=money-1000;
printf ("银甲+1\n");
printf("银甲:%d个\n",fang3n);
printf("金币:%d\n",money);
}
else
{
printf("钱不够!\n");
printf("金币:%d\n",money);
}
default:
printf("对不起,我们只会打造以上防具。");
break;

}
printf("金币:%d\n",money);
break;
case 3:
printf("请问您要购买什么一次**伤害武器?\n 1,手雷 2,毒镖 3,手抛式**\n\n\n");
int yi;
scanf("%d",&yi);
switch(yi)
{
case 1:
if(money>=300 && boom<5)
{
boom++;
money=money-300;
printf("手雷+1\n");
printf("手雷:%d\n",boom);
printf("金币:%d\n",money);
}
else
{
printf("钱不够!\n");
printf("金币:%d",money);
}
break;
case 2:
if(money>=600 && dubiao<4)
{
dubiao++;
money=money-600;
printf("毒镖+1\n");
printf("毒镖:%d\n",dubiao);
printf("金币:%d\n",money);
}
else
{
printf("钱不够!\n");
printf("金币:%d\n",money);
}
break;
case 3:
if(money>=0 && atom_boom<23333333333)
{
atom_boom=atom_boom+233;
money=money+1500;
printf("手抛式**+2\n");
printf("手抛式**:%d\n",atom_boom);
printf("金币:%d\n",money);
}
else
{
printf("钱不够!\n\n\n");
printf("金币:%d\n",money);
}

break;
}
}
break;
case 4:
printf ("欢迎您光临本拍卖行,请问您要卖什么东西?\n\n");
printf("攻击装备: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个\n",gong1n,gong2n,gong3n,gong4n);
printf("防御装备: 5,布衣:%d个 6,铁甲:%d个 7,银甲:%d个 8,黄金圣衣:%d个\n9,巨人晶石:%d个 0,返回\n\n\n",fang1n,fang2n,fang3n,fang4n,strongman_arm);
int pai,shu,i;
scanf("%d",&pai);
switch(pai)
{
case 1:
printf("请问您要出售几件?");
scanf("%d",&shu);
if(gong1n>=shu)
{
gong1n=gong1n-shu;
money=money+shu*240;
printf("匕首:%d\n",gong1n);
printf("金币:%d\n",money);
break;
}
else
{
printf("装备数不够,无法出售!\n");
break;
}
break;
case 2:
printf("请问您要出售几件?\n");
scanf("%d",&shu);
if(gong2n>=shu)
{
gong2n=gong2n-shu;
money=money+shu*400;
printf("长剑:%d\n",gong2n);
printf("金币:%d\n",money);
break;
}
else
{
printf("装备数不够,无法出售!\n");
break;
}
case 3:
printf("请问您要出售几件?\n");
scanf("%d",&shu);
if(gong3n>=shu)
{
gong3n=gong3n-shu;
money=money+shu*800;
printf("碧血剑:%d\n",gong3n);
printf("金币:%d\n",money);
break;
}
else
{
printf("装备数不够,无法出售!\n");
break;
}
case 4:
printf("请问您要出售几件?\n");
scanf("%d",&shu);
if(gong4n>=shu)
{
gong4n=gong4n-shu;
money=money+shu*1500;
printf("绝世好剑:%d\n",gong4n);
printf("金币:%d\n",money);
break;
}
else
{
printf("装备数不够,无法出售!\n");
break;
}
case 5:
printf("请问您要出售几件?\n");
scanf("%d",&shu);
if(fang1n>=shu)
{
fang1n=fang1n-shu;
money=money+shu*240;
printf("布衣:%d\n",fang1n);
printf("金币:%d\n",money);
break;
}
else
{
printf("装备数不够,无法出售!\n");
break;
}
case 6:
printf("请问您要出售几件?\n");
scanf("%d",&shu);
if(fang2n>=shu)
{
fang2n=fang2n-shu;
money=money+shu*500;
printf("铁甲:%d\n",fang2n);
printf("金币:%d\n",money);
break;
}
else
{
printf("装备数不够,无法出售!\n");
break;
}
case 7:
printf("请问您要出售几件?\n");
scanf("%d",&shu);
if(fang3n>=shu)
{
fang3n=fang3n-shu;
money=money+shu*800;
printf("银甲:%d\n",fang3n);
printf("金币:%d\n",money);
break;
}
else
{
printf("装备数不够,无法出售!\n");
break;
}
break;
case 8:
printf("请问您要出售几件?\n");
scanf("%d",&shu);
if(fang1n>=shu)
{
fang4n=fang4n-shu;
money=money+shu*1500;
printf("黄金圣衣:%d\n",fang4n);
printf("金币:%d\n",money);
break;
}
else
{
printf("装备数不够,无法出售!\n");
break;
}
case 9:
printf("请问您要出售几颗?");
scanf("%d",&shu);
if(strongman_arm>=shu)
{
strongman_arm=strongman_arm-shu;
money=money+shu*2000;
printf("巨人晶石:%d\n",strongman_arm);
printf("金币:%d\n",money);
}
else
{
printf("晶石数不够,无法出售!\n");
break;
}
break;
case 0:
break;
break;
default:
printf("没有该装备,无法出售!\n");
break;
}

break;
case 5:
int yewai;
while(1)
{
puts("=============================================================================");
printf("要去哪冒险呢?");
printf("\n\n 1,神秘沼泽 危险程度:★\n\n 2,星耀草原 危险程度:★\n\n 3,诡异森林 危险程度:★★★\n\n 4,荒漠矿场 危险程度:★★★\n\n 5,炽热炎洞 危险程度:★★★★\n\n 6,花朵宫殿 危险程度:★★★★★\n\n 0,离开\n");
puts("=============================================================================");
scanf("%d",&yewai);
switch(yewai)
{
case 1:
place_sign=place.forest1;
s=SuiJi();
if(s<7)
{
battle=1;
guai=xiyi;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=witch;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
printf("这里安全\n\n\n");
//不用调用OAct函数,会自动执行OAct函数;
}
break;
case 3:
place_sign=place.forest2;
s=SuiJi();
if(s<7)
{
battle=1;
guai=witch;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=strongman;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
printf("这里安全\n\n\n");
}
break;
case 5:
place_sign=place.forest3;
s=SuiJi();
if(s<7)
{
battle=1;
guai=strongman;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=big_strongman;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
printf("这里安全\n\n\n");
}
break;
case 2:
place_sign=place.grass1;
s=SuiJi();
if(s<7)
{
battle=1;
guai=bee;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=horse;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
printf("这里安全\n\n\n");
}
break;
case 4:
place_sign=place.grass2;
s=SuiJi();
if(s<7)
{
battle=1;
guai=horse;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=lion;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
printf("这里安全\n\n\n");
}
break;
case 6:
place_sign=place.grass3;
s=SuiJi();
if(s<7)
{
battle=1;
guai=lion;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
if(strongman_arm)
{
printf("神秘老人:\n\n\n 哈哈,年轻人,做的不错,不过...嘿嘿,你上当啦!巨人晶石我要了,公主你也别想带走!\n\n\n");
guai=shitu;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else printf("神秘老人:\n\n\n 年轻人,你好啊.如果你有巨人晶石,我可以告诉你公主的下落哦~\n\n\n");
}
else
{
printf("这里安全\n\n\n");
}
break;
if(yewai!=0)
{
printf("该区域为未知区域,无法进入。\n\n\n");
break;
}
}
if(yewai==0)
{
break;
printf("已离开荒野。");
}
}

}
break;

case 2:
ChooseWupin();
break; //显示道具,并可以使用.
case 3: //对话选项
if(place_sign==place.bar)
{
printf("要和谁说话?\n\n\n1,红发女郎 2,赏金猎人 3,酒吧老板 4,药品商人\n\n\n"); //显示对话人物
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
printf("红发女郎:\n\n\n 吧台边那个Hunter好帅啊!(~脸红~)\n\n\n听说他经常外出打猎,外面的路他应该很熟悉的!\n\n\n");
break;
case 2:
if(fang1n<1&&gong1n<1)
{
printf("赏金猎人:\n\n\n 你要救公主啊!好胆量!\n\n\n 不过外面的世界很险恶,而且越深越危险,这是匕首和布衣,对你会有些帮助的,拿去吧!\n\n\n");
printf("%s心想:哇,这位大叔人真好啊!\n\n\n)",player.name);
gong1n++;
fang1n++;
}
else printf("赏金猎人:\n\n\n 加油吧,年轻人!\n\n\n 不要被外面世界所吓倒!\n\n\n");
break;
case 3:
printf("要喝点什么?\n\n\n 1,二锅头25金币 HP+20 2,XO酒80金币 HP+50 3,人头马面150金币 HP+100 0,返回\n\n\n");
choose_number=1;
while(choose_number)
{
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
if(money<25)
{
printf("钱不够!");
}
else
{
if(player.health+20<=player.max_health)
{
printf("HP+20.");
money-=25;
player.health+=20;
}
else
{
printf("HP满了");
player.health=player.max_health;
}
}
break;
case 2:
if(money<80)
{
printf("钱不够!");
}
else
{
if(player.health+50<=player.max_health)
{
printf("HP+50.");
money-=80;
player.health+=50;
}
else
{
printf("HP满了");
player.health=player.max_health;
}
}
break;
case 3:
if(money<150)
{
printf("钱不够!");
}
else
{
if(player.health+100<=player.max_health)
{
printf("HP+100.");
money-=150;
player.health+=100;
}
else
{
printf("HP满了");
player.health=player.max_health;
}
}
break;
case 0:
printf("下次再来!\n");
break;
default:
printf("输入错误\n\n\n");
break;
}
break;
}
break;
case 4:
printf("你要干什么?\n\n\n 1,买东西 2,聊天 \n\n\n");
int mai;
scanf("%d",&mai);
if(mai==1)
{
printf("买点什么呢?\n1,止血草¥100 HP+60\n2,急救包¥150 HP+80 \n3,云南白药¥250 HP+120\n4,超级云南白药¥400 HP+200 \n5,经验草¥150 经验+300 \n6,经验包¥600 经验+600\n7,经验石¥500 经验+1000 \n0,拜拜\n");
int dongxi;
scanf("%d",&dongxi);
switch(dongxi)
{
case 1:
if(money>=100&&cao<6)
{
cao++;
money=money-100;
printf ("止血草+1\n");
}
else
{
printf("钱不够!\n");
}
break;
case 2:
if(money>=150&&jijiubao<5)
{
jijiubao++;
money=money-150;
printf ("急救包+1\n");
}
else
{
printf("钱不够!\n");
}
break;
case 3:
if(money>=250&&baiyao<4)
{
baiyao++;
money=money-250;
printf ("云南白药+1\n");
}
else
{
printf("钱不够!\n");
}
break;
case 4:
if(money>=400&&superbaiyao<3)
{
superbaiyao++;
money=money-400;
printf ("超级云南白药+1\n");

}
else
{
printf("钱不够!\n");
}
break;
case 5:
if(money>=150)
{
jingyancao++;
money=money-150;
printf ("经验草+1\n");
}
else
{
printf("钱不够!\n");
}
break;
case 6:
if(money>=300)
{
jingyanbao++;
money=money-300;
printf ("经验包+1\n");
}
else
{
printf("钱不够!\n");
}
break;
case 7:
if(money>=500)
{
jingyanshi++;
money=money+500;
printf ("经验石+1\n");
}
else
{
printf("钱不够!\n");
}
break;
}
case 0:
printf("金币:%d\n",money);
printf("再见,欢迎下次再来!\n");
break;

}
if(mai==2)
{
printf("药品商人:去去去,老子没时间陪你聊。\n");
}
}
}
else if(place_sign==place.hotel)
printf("“老板娘!我...”\n\n\n“我忙着呢,没空理你~”\n\n\n");
else printf("这里好像没人可以聊天\n\n\n");
break;
case 4:
DisplayState();
break; //显示状态
case 5: //装备
printf("攻击装备: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个\n\n\n",gong1n,gong2n,gong3n,gong4n);
printf("防御装备: 5,布衣:%d个 6,铁甲:%d个 7,银甲:%d个 8,黄金圣衣:%d个\t\t0,返回\n\n\n",fang1n,fang2n,fang3n,fang4n);
printf("选择要装备的武器或防具:\n\n\n");
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
if(gong1n>=1)
{
printf("拿起了匕首\n\n\n");
gong=gong1;
strcpy(gongname,"匕首");
}
else printf("你没有匕首可以装备\n\n\n");
break;
case 2:
if(gong2n>=1)
{
printf("拿起了长剑\n\n\n");
gong=gong2;
strcpy(gongname,"长剑");
}
else printf("你没有长剑可以装备\n\n\n");
break;
case 3:
if(gong3n>=1)
{
printf("拿起了碧血剑\n\n\n");
gong=gong3;
strcpy(gongname,"碧血剑");
}
else printf("你没有碧血剑可以装备\n\n\n");
break;
case 4:
if(gong4n>=1)
{
printf("拿起了绝世好剑\n\n\n");
gong=gong4;
strcpy(gongname,"绝世好剑");
}
else printf("你没有绝世好剑可以装备\n\n\n");
break;
case 5:
if(fang1n>=1)
{
printf("穿上了布衣\n\n\n");
fang=fang1;
strcpy(fangname,"布衣");
}
else printf("你没有布衣可以装备\n\n\n");
break;
case 6:
if(fang2>=1)
{
printf("穿上了铁甲\n\n\n");
fang=fang2;
strcpy(fangname,"铁甲");
}
else printf("你没有铁甲可以装备\n\n\n");
break;
case 7:
if(fang3n>=1)
{
printf("穿上了银甲\n\n\n");
fang=fang3;
strcpy(fangname,"银甲");
}
else printf("你没有银甲可以装备\n\n\n");
break;
case 8:
if(fang4n>=1)
{
printf("穿上了黄金圣衣\n\n\n");
fang=fang4;
strcpy(fangname,"黄金圣衣");
}
else printf("你没有黄金圣衣可以装备\n\n\n");
break;
case 0:
printf("未更换装备\n\n\n");
break;
default:
printf("change error!");
}
break;
case 6:
printf(" 您好,欢迎您玩苍穹世界。为了给您更好的游戏体验,本团队时不时会优化本游戏,优化后会尽快发布在网上。关于**方面,开启**的方式是设定勇者姓名时,输入“**斗士 ”(不包括双引号)。由于2.0版本的buy,我们在2.0的基**上进行修改,已修复该buy。并且新增了经验草等有助于升级的道具,希望大家喜欢。在这里要感谢离陌同学,他给了我们许多宝贵的建议,谢谢。\n");
break;
case 0:
printf("确定退出游戏?(Y/N)\n\n\n");
getchar();
proof=getchar();
if(proof=='y'||proof=='Y')
{
printf("数据存储中...");
//向文件中更新数据;
getchar();
printf("按回车退出");
getchar();
return;
}
else if(proof=='n'||proof=='N')printf("继续游戏!\n\n\n");
else printf("继续!\n\n\n");
break;
default:
printf("输入错误!\n\n\n");
}
}
}
void DisplayState()
{
printf("%s 攻击力:%d+%d=%d 防御力:%d+%d=%d HP:%d/%d \n\n\n",player.name,player.attack,gong,player.attack+gong,player.defense,fang,player.defense+fang,player.health,player.max_health);
printf("武器: %s 防具: %s \n\n\n",gongname,fangname);
printf("等级:%d 经验:%d/%d 还需要%d经验升级 金币:%d \n\n\n",player.level,player.exp,player.max_exp,player.max_exp-player.exp,money);
}
void BattleAct()
{
while(1)
{
puts("=============================================================================");
printf("要怎么办?\n\n\n 1,攻击 2,物品 3,查看状态 4,逃跑\n\n\n");
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
s=SuiJi();
printf("%s攻击! %sHP减少%d\n\n\n",player.name,guai.name,player.attack+s+gong-guai.defense/3);
guai.health-=player.attack+s+gong-guai.defense/3;
if(AttackResult())return; //如果攻击有结果(敌人或玩家战**)退出函数
else continue;
case 2:
ChooseWupin();
break; //选择物品,可以使用,战斗中允许使用攻击**物品
case 3:
DisplayState();
break; //显示状态
case 4:
s=SuiJi();
if(s<4) //40%的概率可以逃跑
{
printf("%s逃跑了~\n\n\n",player.name);
battle=0;
return;
}
else printf("%s逃跑失败!\n\n\n",player.name);
break;
default:
printf("输入错误,重新输入!\n\n\n");
}
}
}
void printf(char *p)
{
while(1)
{
if(*p!=0)
printf("%c",*p++);
else
break;
Sleep(100);
}
}

--------------------------------来源网上

0
被禁言 汪声旭
汪声旭
高级守护
高级守护

#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
using namespace std;
typedef BOOL (WINAPI *PROCSETCONSOLEFONT)(HANDLE, DWORD);
PROCSETCONSOLEFONT SetConsoleFont;
POINT Windowpos(){POINT pt;GetCursorPos(&pt);HWND h=GetForegroundWindow();ScreenToClient(h,&pt);
pt.x=(pt.x+4)/8+0.5;pt.y=pt.y/16+0.5;//鼠标矫正此处 
swap(pt.x,pt.y);return pt;}
int mouse;POINT pt;
void Print(int a){HMODULE hKernel32 = GetModuleHandle("kernel32");SetConsoleFont = (PROCSETCONSOLEFONT)GetProcAddress(hKernel32,"SetConsoleFont");SetConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE),a);}
int ti(float a) {return ((int)(a*10+5))/10;}
void Setpos(float x,float y){COORD pos;pos.X=ti(y*4)/2;pos.Y=ti(x+2);SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
void Color(int a){if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==-1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);
                  if(a==-8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED);if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
                  if(a==-11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_GREEN|BACKGROUND_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),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN);if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
                  if(a==-6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_BLUE);
                  if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
                  if(a==8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);if(a==9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_GREEN|BACKGROUND_BLUE);if(a==10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE);if(a==11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_BLUE);if(a==12) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);if(a==13) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);if(a==14) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_BLUE);}
void Slow(char *p,int a) {while(1){if(*p!=0) printf("%c",*p++);else break;Sleep(a);}} 

int to(float a) {if(a>0) return int(a+0.5);else if(a<0) return int(-a-0.5);if(a==0) return 0;}
float Sin(int a) {return sin(3.1416*a/180);}float Cos(int a) {return cos(3.1416*a/180);}
float Sin0(int a) {return sin(3.1416*a);}float Cos0(int a) {return cos(3.1416*a);}//多少pai 
//------------------------------------杂七杂八的图像函数。。。------------------------------------
int m[51][101],n[51][101],s[51][101];speacial
int bl,br,Life,level,T,Turnx,Turny,End,Lev,people,unkillT,unkillTmax,Tempty;
float X,X2,Y,Y2,speed=30,Attack=1,Anc,Anv,Anb,cMin,vMin,bMin,skillC,skillV,skillB,Blood,Bloodmax,EXP,EXPmax;

int D[2][5]={{0,1,-1,0,0},{0,0,0,-1,1}};//上下右左 
float Sx=18,Sy=60,Svx=0,Svy=0,Stx,Sty,Sr=0,Sm=0,Svmax=2,Srmax=5;
int Sleep_1,Sleep_1max,Sleep_2,Sleep_3;
int Bean,BeanBoo,BeanBoom,TimeStop,T**der,T**derTime,T**derTurn,Crab;

struct bullet{float x,y,vx,vy,fx1,fx2,fx3;int w,t,k,l,ex1,ex2,ex3;//what,time,kill,life;
float maxsize,angle,maxangle,minangle,xr,ybig,ysmall,v; 
int turn,staytime,num,source;
}B[1000001];//改时别忘了Delete! 
void Delete_B(int i) {
B[i].x=B[i].y=B[i].vx=B[i].vy=B[i].fx1=B[i].fx2=B[i].fx3=B[i].w=B[i].t=B[i].k=B[i].l=B[i].ex1=B[i].ex2=B[i].ex3=0;
B[i].maxsize=B[i].angle=B[i].maxangle=B[i].minangle=B[i].xr=B[i].ybig=B[i].ysmall=B[i].v=B[i].turn=B[i].staytime=B[i].num=B[i].source=0;}
void S(float x,float y){int i=(int)x,j=(int)y;Setpos(i,j/2.0);printf("a");}
void C(float x,float y){int i=(int)x,j=(int)y;Setpos(i,j/2.0);//直接输出该点 
    if(n[i][j]==0) printf(" ");
    if(n[i][j]==1) Color(-1),printf(" ");
    //以下无伤 
    if(n[i][j]==-1) Color(-8),printf(" ");
    if(n[i][j]==-2) Color(-11),printf(" ");
    if(n[i][j]==-3) Color(-5),printf(" ");
    Color(0);
}
void Map(int a){if(a==1){for(register int i=1;i<=50;i++)for(register int j=1;j<=100;j++){if(n[i][j]!=m[i][j]){C(i,j);}}for(register int i=1;i<=50;i++)for(register int j=1;j<=100;j++){m[i][j]=n[i][j];}}}
//Map1:更新地图 
void N(float x,float y,int w){int xx=(int)x,yy=(int)y;//放置点在地图上
if(xx>40||yy>80||xx<1||yy<1) return;
else if(w<0&&n[xx][yy]>=1) return;//白色盖住红色 
else n[xx][yy]=w;}
void Die(){
    system("cls");system("color 0F");
    Slow("You Die !",50);
    system("color 3B");Sleep(10);system("cls");system("color 0F");}
void Win(){
    system("cls");
    for(register int i=0;i<=3;i++)
    {printf("You Win !");
        system("color 1A");Sleep(10);
        system("color 2B");Sleep(10);
        system("color 3C");Sleep(10);
        system("color 4D");Sleep(10);
        system("color 5D");Sleep(10);
        system("color 6E");Sleep(10);
        system("color 7F");Sleep(10);
    }printf("   好敷衍啊...");Lev=1;system("color 0F");Sleep(5000);system("cls");
}
void Circle(int x,int y,int r,int num,int start,int whatnumber,int source){if(r<0) return;if(r==0) num=1;int next=360/num;for(register int i=0;i<num;i++){br++;
    B[br].w=3;B[br].staytime=3;if(whatnumber==0) whatnumber=1;B[br].num=whatnumber;B[br].source=source;
    B[br].t=0;B[br].l=1;B[br].x=x+Sin(i*next+start)*r;B[br].y=y+2*Cos(i*next+start)*r;}}
void Rock_Circle(float x0,float y0,float xr,float ybig,int staytime,int source,int num){
    if(xr<0) return; 
for(register int i=x0-xr;i<=x0+xr;i++){float Ay=ybig*2*sqrt(xr*xr-(i-x0)*(i-x0));for(register float j=y0-Ay;j<y0+Ay;j++){br++;B[br].w=3;B[br].staytime=staytime;B[br].t=0;B[br].l=1;B[br].x=i;B[br].y=to(j);B[br].staytime=staytime;B[br].num=num;
if(num==-3) B[br].num=-2,B[br].ex2=1;
B[br].source=source;B[br].ex1=B[B[br].source].ex1;}}}
void Rock_line(float x0,float y0,float x,float y,int source){
    float Ax=x-x0,Ay=y-y0,R=sqrt(Ax*Ax+Ay*Ay);
    bool yy=0;
    if(Ax<0) swap(x,x0),swap(y,y0),Ax*=-1,Ay*=-1;if(Ay<0) yy=1;
    float ax=Ax/R*1.0,ay=Ay/R*1.0,j=y0,i=x0;
    while(i<=x&&((j<=y&&yy==0)||(j>=y&&yy==1)))
    {
        br++;B[br].w=3;B[br].t=0;B[br].l=1;B[br].x=to(i);B[br].y=to(j);
        B[br].staytime=to(R);B[br].source=source;B[br].num=B[source].num;
        if(source==-2) B[br].source=0,B[br].num=-2;
        i+=ax;j+=ay;
    }
}
void Circle_bomb(int x,int y,int number,int start,float speed,int source,int num){int next=360/number;for(register int i=0;i<number;i++){br++;B[br].w=2;B[br].t=0;B[br].l=1;B[br].source=source;B[br].num=num;
    B[br].vx=Sin(i*next+start)*speed;B[br].x=x-B[br].vx;
    B[br].vy=2*Cos(i*next+start)*speed;B[br].y=y-B[br].vy;
    }}
void Rand_put_Knife(int turn){
    br++;
B[br].w=1;
B[br].t=0;B[br].l=1;
B[br].x=X+rand()%10-5;
B[br].y=1;
B[br].staytime=3;
B[br].turn=turn;
B[br].angle=0+180*turn;
B[br].maxangle=180;B[br].minangle=0;
B[br].v=7;
if(turn==1) B[br].v*=-1;
B[br].ybig=(rand()%25)/10.0+4;//3 导轨扁度 2为圆 
B[br].ysmall=0.01;// ybig* ysmall=刀光横宽倍数  0.25为圆 
B[br].maxsize=0.01;//刀光纵宽
B[br].xr=(rand()%5-2+(Y-B[br].y))/B[br].ybig*1.0;//导轨大小 
}
void Put_Round_Bullet(int ex,float v){//1:反伤 
for(register int i=0;i<=v*4;i+=5) {br++;B[br].w=5;B[br].t=0;B[br].l=1;B[br].x=X;B[br].y=Y;B[br].angle=i+110;B[br].maxangle=600;
B[br].v=60-(int)v;
B[br].staytime=3;B[br].xr=3+v/10.0;
if(ex==1) B[br].ex1=1;
}if(v>=27)
for(register int i=0;i<=v*4;i+=5) {br++;B[br].w=5;B[br].t=0;B[br].l=1;B[br].x=X;B[br].y=Y;B[br].angle=i+110;B[br].maxangle=600;
B[br].v=60-(int)v;
B[br].staytime=3;B[br].xr=4+v/10.0;
if(ex==1) B[br].ex1=1;
}
}
void Rand_put_Bullet(){
    br++;
B[br].w=2;
B[br].t=0;B[br].l=1;
B[br].x=rand()%40;
B[br].y=1;
B[br].vy=(rand()%25+25)/15.0;
}
void put_Bullet(float x,float y,float vx,float vy,int num){
    vx/=2.0;
if(vy!=0) {br++;B[br].w=2;B[br].t=0;B[br].l=1;B[br].x=x;B[br].y=y-1;B[br].vx=vx;B[br].vy=vy;B[br].num=num;if(num==-4) num=-2,B[br].maxsize=5;}
br++;B[br].w=2;B[br].t=0;B[br].l=1;B[br].x=x;B[br].y=y;B[br].vx=vx;B[br].vy=vy;B[br].num=num;if(num==-4) num=-2,B[br].maxsize=5;}
void Rand_sin_Bullet(){
    br++;
B[br].w=6;
B[br].t=0;B[br].l=1;
B[br].x=rand()%40;
B[br].y=1;
B[br].vy=(rand()%25+25)/15.0;B[br].staytime=10;
B[br].angle=0;B[br].xr=3;B[br].v=(rand()%125+25)/2.0;
}
void Rand_back_Bullet(){
    br++;
B[br].w=7;
B[br].t=0;B[br].l=1;
B[br].x=rand()%40;
B[br].y=1;
B[br].ybig=80-(rand()%5)/2.0;
}
void Rand_brouce_Bullet(){//ex2:弹跳数 
    br++;
B[br].w=8;
B[br].t=0;B[br].l=1;
B[br].x=rand()%40;
B[br].y=1;
B[br].vy=(rand()%25+25)/15.0;
B[br].vx=(rand()%50-25)/15.0;
B[br].xr=(rand()%15)/10.0+1.5;
B[br].ex2=3;
}
void Put_brouce_Bullet(int a,float x,float y,float vx,float vy,float ex2){
    vy*=2;
if(a==0) {br++;B[br].w=8;B[br].t=0;B[br].l=1;B[br].x=x;B[br].y=y;B[br].vx=vx;B[br].vy=vy;B[br].xr=1.5;B[br].num=-3;B[br].ex2=ex2;}
if(a==1) Put_brouce_Bullet(0,X,Y,0,-1.5,0);
if(a==2) Put_brouce_Bullet(0,X,Y,0,-2,5),Put_brouce_Bullet(0,X,Y,0,2,5),Put_brouce_Bullet(0,X,Y,-2,0,5),Put_brouce_Bullet(0,X,Y,2,0,5),Put_brouce_Bullet(0,X,Y,-1.414,1.414,5),Put_brouce_Bullet(0,X,Y,-1.414,-1.414,5),Put_brouce_Bullet(0,X,Y,1.414,1.414,5),Put_brouce_Bullet(0,X,Y,1.414,-1.414,5);
if(a==3) for(int i=1;i<=1;i++) Put_brouce_Bullet(0,X+2.5-rand()%50/10,Y+5-rand()%100/10,0,-1-rand()%25/10,0);
}
void Hurt(int x,int y,int ex){
    br++;
B[br].w=4;
B[br].t=0;B[br].l=1;
B[br].x=x;
B[br].y=y;
if(ex==1) B[br].staytime=3,B[br].v=1,B[br].num=-1;//伤 
if(ex==2) B[br].staytime=5,B[br].v=5,B[br].num=-3;//清 
}
void Level_Bullet(){
    if(T<=50&&T%5==0) Rand_put_Bullet();else if(T<=100) return;
    else if(T<=150&&T%5==0) Rand_put_Knife(T%2);else if(T<=200) return;
    else if(T<=250&&T%7==0) Rand_sin_Bullet();else if(T<=300) return;
    else if(T<=350&&T%7==0) Circle_bomb(20,40,15,T%15,2,0,1);else if(T<=400) return;
    else if(T<=450&&T%7==0) Rand_back_Bullet();else if(T<=500) return;
    else if(T<=550&&T%10==0) Rand_brouce_Bullet();else if(T<=600) return;
    else if(T<=1000){if(T%5==0) Rand_put_Bullet();if(T%21==0) Rand_put_Knife(T%2);if(T%39==0) Rand_sin_Bullet();if(T%90==0) Circle_bomb(20,40,15,T%15,2,0,1);if(T%18==0) Rand_back_Bullet();if(T%34==0) Rand_brouce_Bullet();}
    else if(T<=2000){if(T%6==0) Rand_put_Bullet();if(T%17==0) Rand_put_Knife(T%2);if(T%23==0) Rand_sin_Bullet();if(T%60==0) Circle_bomb(20,40,15,T%15,2,0,1);if(T%9==0) Rand_back_Bullet();if(T%28==0) Rand_brouce_Bullet();}
    else {if(T%10==0) Rand_put_Bullet();if(T%13==0) Rand_put_Knife(T%2);if(T%9==0) Rand_sin_Bullet();if(T%40==0) Circle_bomb(20,40,15,T%15,2,0,1);if(T%8==0) Rand_back_Bullet();if(T%27==0) Rand_brouce_Bullet();}
}
void Move_bullet(){
    for(register int i=bl;i<=br;i++){
        if(B[bl].l==0) bl++;
        if(B[i].l==1&&TimeStop==0) B[i].t++;else continue;
    bool del;
        float x=B[i].x,y=B[i].y,vx=B[i].vx,vy=B[i].vy,fx1=B[i].fx1,fx2=B[i].fx2,fx3=B[i].fx3;
        int w=B[i].w,t=B[i].t,k=B[i].k,ex1=B[i].ex1,ex2=B[i].ex2,ex3=B[i].ex3;
    float maxsize=B[i].maxsize,angle=B[i].angle,maxangle=B[i].maxangle,minangle=B[i].minangle,xr=B[i].xr,ybig=B[i].ybig,ysmall=B[i].ysmall,v=B[i].v,turn=B[i].turn;
    int staytime=B[i].staytime,num=B[i].num,source=B[i].source;
        //what,time,kill,life;简化 
//    if(level==1){
        if(Sleep_1==0&&s[to(x)][to(y)]>=1&&s[to(x)][to(y)]<=2&&w==3&&ex1!=1&&num>=0&&num<=1) {Delete_B(source),del=1,Delete_B(i);EXP+=0.3;if(people!=4) Sleep_1=1;
    if(s[to(x)][to(y)]==1){B[i].w=2;B[i].t=0;B[i].l=1;B[i].num=-2;B[i].x=x;B[i].y=y;B[i].vx=to(x)-X;B[i].vy=to(y)-Y;B[i].vx/=2,B[i].vy/=2;B[i].ex1=1;B[i].staytime=2;}
        }

        if(w==1){//maxsize,angle,rx,ybig,v,x0,y0; 
        if(angle>maxangle||angle<minangle) {del=1,Delete_B(i);
        continue;}
        else {int v0=2;float a=angle;
        for(register int A=min(a+v0,a+v+v0);A<max(a+v0,a+v+v0);A+=v0)
        {
        angle+=v0;
        float rsmall=0.1;
        float y1=y+xr*ybig*Sin(angle)*1.0;
        float x1=x+xr*Cos(angle)*1.0;
        float R=1+rsmall*maxsize*Sin(angle)*1.0;
        Rock_Circle((int)x1,(int)y1,to(R),ybig*ysmall,staytime,i,1);
        }if(TimeStop==0) angle=a+v;}
        }//刀 
        if(w==2){
        if(x>40||y>80||x<1||y<1||(abs(vx)<=0.1&&abs(vy)<=0.1)||(people==4&&t>=6&&num<0)) {del=1,Delete_B(i);continue;}
        else {Rock_line(x,y,x+vx,y+vy,i);
        if(ex1==1) vx*=0.9,vy*=0.9;
        if(TimeStop==0) x+=vx,y+=vy;
        }}
        if(w==3) {
        if(ex2==1&&m[to(x)][to(y)]>0&&Sleep_2==0) Delete_B(source),Sleep_2=1;
        if(x>40||y>80||x<1||y<1||t>=staytime||(ex2==1&&m[to(x)][to(y)]>0&&Sleep_2==0)) {del=1,Delete_B(i),N(x,y,0);if(ex1==1||num==-2) s[to(x)][to(y)]=0;continue;}
        if(num!=0) N(x,y,num);
        else N(x,y,1);
        if(ex1==1) s[to(x)][to(y)]=1;else if(num==-2) s[to(x)][to(y)]=2;
        }//残影
        if(w==4){//Hurt
        Circle(x,y,1+t*v,90,1,num,i);if(t>=staytime) del=1,Delete_B(i);
        }
        if(w==5){//Round
        if(angle>maxangle||angle<minangle) {del=1,Delete_B(i);continue;}
        for(register int a=angle;a<angle+v;a+=3){Rock_Circle((int)(X+Sin(a)*xr),(int)(Y+2*Cos(a)*xr),1,0.5,staytime,i,-2);}
        if(TimeStop==0) angle+=v;
        }
        if(w==6){//Sin
        if(x>40||y>80||x<1||y<1) {del=1,Delete_B(i);continue;}
        for(register int a=angle;a<angle+v;a+=3){Rock_Circle((int)(x+Sin(a)*xr),(int)y,1,0.5,staytime,i,1);
        }if(TimeStop==0) angle+=v,x+=vx,y+=vy;
        }
        if(w==7){//Back
        if(x>40||x<1||y<1) {del=1,Delete_B(i);continue;}
        vy=(ybig-y)/10.0+0.2;if(turn==1) vy*=-1;
        if(TimeStop==0) x+=vx,y+=vy;
        if(y>=ybig) turn=1;
        if(turn==0) Rock_line(x,y,x,y+3,i),Rock_line(x-1,y,x-1,y-2,i),Rock_line(x+1,y,x+1,y-2,i);
        else Rock_line(x,y,x,y-3,i),Rock_line(x-1,y,x-1,y+2,i),Rock_line(x+1,y,x+1,y+2,i);
        }
        if(w==8){//Brouce
        if(x>40||y>80||x<1||y<1) {if(x<1) x=1,vx*=-1;if(x>40) x=40,vx*=-1;if(y<1) y=1,vy*=-1;if(y>80) y=80,vy*=-1;ex2--;}
        if(ex2<0) {del=1,Delete_B(i),N(x,y,0);continue;}
        Rock_Circle(x,y,xr,1,2,i,num);
        if(TimeStop==0) x+=vx,y+=vy;
        }
        if(w==9){//Crab_Attack
        vx=rand()%15-7,vy=rand()%29-14;if(ex1==3) vx=rand()%11-5,vy=rand()%11-5;if(ex1==2) vx=rand()%5+2;
        if(TimeStop==0) {float xx=fmax(fmin(x+vx,39),1),yy=fmax(fmin(y+vy,80),1);Rock_line(x,y,xx,yy,-2);x=xx,y=yy;
        if(ex1==3) X=to(x),Y=to(y),unkillT=2,Crab=1;}
        if(x>=39||y>=80||x<=1||y<=1) {del=1,Delete_B(i);if(ex1==3) Crab=2;continue;}
        }
        //    }
    if(del==0){//事实上不用,有continue了 
        B[i].x=x,B[i].y=y,B[i].vx=vx,B[i].vy=vy;B[i].fx1=fx1,B[i].fx2=fx2,B[i].fx3=fx3;
        B[i].w=w,B[i].t=t,B[i].k=k;B[i].ex1=ex1,B[i].ex2=ex2,B[i].ex3=ex3;

    B[i].maxsize=maxsize,B[i].angle=angle,B[i].maxangle=maxangle,B[i].minangle=minangle,B[i].xr=xr,B[i].ybig=ybig,B[i].ysmall=ysmall,B[i].v=v,B[i].turn=turn;
    B[i].staytime=staytime,B[i].num=num,B[i].source=source;
    }//回复 dd
      }
    if(bl>br) bl=br=0,memset(B,0,sizeof(B));
}
void Scissor(){
        if(Stx!=0&&Svx>=0) Svx=max(Svx/2+Stx/10,Svx+Stx/20);
        else if(Stx!=0&&Svx<0) Svx*=-1,Stx*=-1,Svx=max(Svx/2+Stx/10,Svx+Stx/20),Svx*=-1;
        else Svx*=0.9;
        if(Sty!=0&&Svy>=0) Svy=max(Svy/2+Sty/10,Svy+Sty/20);
        else if(Sty!=0&&Svy<0) Svy*=-1,Sty*=-1,Svy=max(Svy/2+Sty/10,Svy+Sty/20),Svy*=-1;
        else Svy*=0.9;
        Svx=max(-Svmax,min(Svmax,Svx));Svy=max(-Svmax,min(Svmax,Svy));
        Sx+=Svx*1.8,Sy+=Svy*1.8;
        Srmax=fmin(1+1.7*sqrt((Svx*Svx)+(Svy*Svy)),2+sqrt((Svx*Svx)+(Svy*Svy)));
        if(Sx<1) Sx=1,Svx*=-0.6;
        if(Sx>39) Sx=39,Svx*=-0.6;
        if(Sy<1) Sy=1,Svy*=-0.6;
        if(Sy>80) Sy=80,Svy*=-0.6;

        Sr=fmax(0,Sr-0.03);//摩擦 
        Rock_Circle(Sx,Sy,1+Sr,1,3,0,-2);
}
void T**der_step(int x0,int y0,float l,int tx,int ty){
    int tt=tx+ty*4,e=0;
    for(register float i=X-3;i<=X+1;i++) for(register float j=Y-8;j<=Y+8;j++) C(i,j);
    if(X<=1||X>=39||Y<=1||Y>=80) e=1;
    X+=l*tx;Y+=2*l*ty;unkillT=2;
    if((X<1||X>39||Y<1||Y>80)&&e==1) {X=x0,Y=y0;return;}
    if(T**der>0&&tt!=T**derTurn&&tt!=0) T**der--,T**derTurn=tt;
    X=max(min((int)X,39),1),Y=max(min((int)Y,80),1);
    Rock_line(x0,y0,X,Y,-2);
}
void Crab_Attack(int x,int y,int a){
    br++;
B[br].w=9;
B[br].t=0;B[br].l=1;
B[br].x=x;
B[br].y=y;
B[br].ex1=a;
}
void Start_level(){level=1;
    system("cls"); 
Slow("  Ready ?! .................. Start !     ",50);
    memset(B,0,sizeof(B));memset(m,0,sizeof(m));memset(n,0,sizeof(n));memset(s,0,sizeof(s));
    bl=br=0;
    X=20,Y=70;
    T=0;Life=1;Blood=Bloodmax;unkillTmax=2;Tempty=1000;
    int an,An,kill,Stop;Turnx=1;Anc=Anv=Anb=unkillT=0;
    while(Life==1&&Lev<10)
    {
        T++;an=0;if(End>0) End--;
        Sleep_1=Sleep_2=0;
        if(GetAsyncKeyState(VK_UP)&0x8000) Turnx=1,an=1;
        else if(GetAsyncKeyState(VK_DOWN)&0x8000) Turnx=2,an=1;
        else Turnx=0;
        if(GetAsyncKeyState(VK_RIGHT)&0x8000) Turny=3,an=1;
        else if(GetAsyncKeyState(VK_LEFT)&0x8000) Turny=4,an=1;
        else Turny=0;
        if(an==1) An++;if(an==0&&An>0) An=0,Turnx=Turny=0,an=1;

    if(people==1) {   if(GetAsyncKeyState(67)&0x8000) {if(Anc==0) Anc=1;Anc=min(9.9,Anc+0.05);}else{if(Anc<0) Anc+=0.02;if(Anc>-0.5&&Anc<0.5) Anc=0,Setpos(X-2,Y/2-2),printf("   ");if(Anc>0) {int cy=Turny;if(Turnx==0&&Turny==0) cy=3;put_Bullet(X,Y,D[0][Turnx]*(Anc+2),D[1][cy]*(Anc+2),-2);Anc=cMin;}}
        if(GetAsyncKeyState(86)&0x8000) {if(Anv==0) Anv=1;Anv=min(9.9,Anv+0.05);}else{if(Anv<0) Anv+=0.02;if(Anv>-0.5&&Anv<0.5) Anv=0,Setpos(X-2,Y/2),printf("     ");if(Anv>0) {Put_Round_Bullet(1,(int)(20+Anv));Anv=vMin;}}
        if(GetAsyncKeyState(66)&0x8000) {if(Anb==0) Anb=1;Anb=min(9.9,Anb+0.05);}else{if(Anb<0) Anb+=0.02;if(Anb>-0.5&&Anb<0.5) Anb=0,Setpos(X-2,Y/2+2),printf("     ");if(Anb>0) {unkillT=5;int nb=(int)(Anb*3);Circle_bomb(X,Y,(nb+3),rand()%(nb+3),Anc*0.1+2,0,-2);Anb=bMin;}}
    }
    if(people==2) {if(GetAsyncKeyState(87)&0x8000) Stx=-1;else if(GetAsyncKeyState(83)&0x8000) Stx=1;else Stx=0;if(GetAsyncKeyState(68)&0x8000) Sty=1;else if(GetAsyncKeyState(65)&0x8000) Sty=-1;else Sty=0;
        if((GetAsyncKeyState(90)&0x8000)||(GetAsyncKeyState(88)&0x8000)) Sr=min(Sr+1,Srmax);//转速 X
        Scissor();
    }
    if(people==3) {
        if(GetAsyncKeyState(86)&0x8000) {if(Anv==0) Anv=1;Anv=min(9.9,Anv+0.05);}else{if(Anv<0) Anv+=0.02;if(Anv>-0.5&&Anv<0.5) Anv=0,Setpos(X-2,Y/2),printf("     ");if(Anv>0) {BeanBoo=8;Anv=vMin;}}
        if(GetAsyncKeyState(66)&0x8000) {if(Anb==0) Anb=1;Anb=min(9.9,Anb+0.05);}else{if(Anb<0) Anb+=0.02;if(Anb>-0.5&&Anb<0.5) Anb=0,Setpos(X-2,Y/2+2),printf("     ");if(Anb>0) {BeanBoom=30;Anb=bMin;}}
    if(BeanBoom>0) Put_brouce_Bullet(3,0,0,0,0,0),BeanBoom--;
    if(BeanBoo>0) BeanBoo--;if(BeanBoo%6==1) Put_brouce_Bullet(2,0,0,0,0,0);
    if(Bean>0) Bean--;if(Bean<=0) Put_brouce_Bullet(1,0,0,0,0,0),Bean=20;
    }
    if(people==4) {Sleep_3=0;
        if((GetAsyncKeyState(67)&0x8000)||(GetAsyncKeyState(86)&0x8000)){if(Anc==0) Anc=1;Anc=min(9.9,Anc+0.05);
        if(Anc>0&&Sleep_3<=2) {Sleep_3++;put_Bullet(X,Y,-3+rand()%60/10,-4-rand()%10/20,-4);Anc=0;if(TimeStop==0) Anc=cMin;}}else{if(Anc<0) Anc+=0.02;if(Anc>-0.5&&Anc<0.5) Anc=0,Setpos(X-2,Y/2-2),printf("   ");}
        if(GetAsyncKeyState(66)&0x8000) {if(Anb==0) Anb=1;Anb=min(9.9,Anb+0.05);}else{if(Anb<0) Anb+=0.02;if(Anb>-0.5&&Anb<0.5) Anb=0,Setpos(X-2,Y/2+2),printf("     ");
        if(Anb>0) {TimeStop=50;unkillT=50;Anb=bMin;}}if(TimeStop>0) TimeStop--;
    }
    if(people==5) {   if(GetAsyncKeyState(67)&0x8000) {if(Anc==0) Anc=1;Anc=min(9.9,Anc+0.05);}else{if(Anc<0) Anc+=0.02;if(Anc>-0.5&&Anc<0.5) Anc=0,Setpos(X-2,Y/2-2),printf("   ");
    if(Anc>0) {int cy=Turny;if(Turnx==0&&Turny==0) cy=4;T**der_step(X,Y,3*Anc+4,-D[0][Turnx],-D[1][cy]);Anc=cMin;}}
        if(GetAsyncKeyState(86)&0x8000) {if(Anv==0) Anv=1;Anv=min(9.9,Anv+0.05);}else{if(Anv<0) Anv+=0.02;if(Anv>-0.5&&Anv<0.5) Anv=0,Setpos(X-2,Y/2),printf("     ");if(Anv>0) {T**der=6;Anv=vMin;}}
        if(GetAsyncKeyState(66)&0x8000) {if(Anb==0) Anb=1;Anb=min(9.9,Anb+0.05);}else{if(Anb<0) Anb+=0.02;if(Anb>-0.5&&Anb<0.5) Anb=0,Setpos(X-2,Y/2+2),printf("     ");if(Anb>0) {T**derTime=30;Anb=bMin;}}
    if(T**derTime>0) T**derTime--;if(an==0) T**derTurn=0;
    }
    if(people==6) {   if(GetAsyncKeyState(67)&0x8000) {if(Anc==0) Anc=1;Anc=min(9.9,Anc+0.05);}else{if(Anc<0) Anc+=0.02;if(Anc>-0.5&&Anc<0.5) Anc=0,Setpos(X-2,Y/2-2),printf("   ");
    if(Anc>0) {Crab_Attack(X,Y,1),Anc=cMin;}}
        if(GetAsyncKeyState(86)&0x8000) {if(Anv==0) Anv=1;Anv=min(9.9,Anv+0.05);}else{if(Anv<0) Anv+=0.02;if(Anv>-0.5&&Anv<0.5) Anv=0,Setpos(X-2,Y/2),printf("     ");if(Anv>0) {Crab_Attack(1,rand()%59+10,2);Anv=vMin;}}
        if(GetAsyncKeyState(66)&0x8000) {if(Anb==0) Anb=1;Anb=min(9.9,Anb+0.05);}else{if(Anb<0) Anb+=0.02;if(Anb>-0.5&&Anb<0.5) Anb=0,Setpos(X-2,Y/2+2),printf("     ");if(Anb>0) {Crab_Attack(X,Y,3);Anb=bMin;}}
    Crab=0;}
    //操作
    if(TimeStop==0) Level_Bullet();
    if(TimeStop==0&&Tempty>0) Tempty--;
        else if(Tempty==0) Tempty=500,system("cls"),memset(B,0,sizeof(B)),memset(m,0,sizeof(m)),memset(n,0,sizeof(n)),memset(s,0,sizeof(s)),bl=br=0,Hurt(20,40,2);
//    //放子弹
    Move_bullet();
    if(Crab==2) system("cls"),Map(1); 
    if(an==1||kill==1||T<=2){
    if(T**der!=0||T**derTime!=0){T**der_step(X,Y,5,-D[0][Turnx],-D[1][Turny]);}
    for(register float i=X-3;i<=X+1;i++) for(register float j=Y-8;j<=Y+8;j++) C(i,j);
    if(Turnx==1) X--;if(Turnx==2) X++;if(Turny==3) Y+=2;if(Turny==4) Y-=2;
            X=fmax(fmin(X,39),1),Y=fmax(fmin(Y,80),1);//你的位置更新 
if(TimeStop>0) Color(1+rand()%5);else if(unkillT>0) Color(8);else Color(1);
        if(Turnx==1||(Turnx==0&&Turny==0)) {Setpos(X-1,Y/2.0),printf("o"),Setpos(X,Y/2.0-0.5),printf("/+\\"),Setpos(X+1,Y/2.0);if(An%2==0) printf("A");else printf("H");}
        else if(Turnx==2) {Setpos(X-1,Y/2.0),printf("o"),Setpos(X,Y/2.0-0.5),printf("\\+/"),Setpos(X+1,Y/2.0);if(An%2==0) printf("A");else printf("H");}
        else if(Turny==3) {Setpos(X-1,Y/2.0+0.5),printf("o"),Setpos(X,Y/2.0-0.5),printf("-+"),Setpos(X+1,Y/2.0-0.5);if(An%2==0) printf("/>");else printf("v|");}
        else if(Turny==4) {Setpos(X-1,Y/2.0-0.5),printf("o"),Setpos(X,Y/2.0),printf("+-"),Setpos(X+1,Y/2.0);if(An%2==0) printf("<\\");else printf("|v");}
    }
    if(skillC==1&&Anc!=0&&Crab==0) Color(1),Setpos(X-2,Y/2-2),printf("C%0.1f   ",Anc);
    if(T**derTime>0) Color(1+rand()%2*4),Setpos(X-2,Y/2),printf("%d  ",T**derTime);
    else if(T**der>0) Color(1+rand()%2*4),Setpos(X-2,Y/2),printf("%d  ",T**der);
    else if(skillV==1&&Anv!=0&&Y<=76&&Crab==0) Color(2),Setpos(X-2,Y/2),printf("V%0.1f   ",Anv);
    if(TimeStop>0) Color(1+rand()%5),Setpos(X-2,Y/2+2),printf("%d  ",TimeStop);
    else if(skillB==1&&Anb!=0&&Y<=73&&Crab==0) Color(5),Setpos(X-2,Y/2+2),printf("B%0.1f   ",Anb);

    if(T%15==0) Blood=min(Blood+1,Bloodmax);
    if(unkillT<=0) for(register int i=0;i<=4;i++) if(n[(int)X+D[0][i]][(int)Y+D[1][i]]>=1) {Blood-=Attack,kill=1;Hurt(X,Y,1);unkillT=unkillTmax;}
    if(unkillT>0) unkillT--;
    if(EXP>EXPmax) Lev++,EXP=0,Blood*=1.4,Bloodmax*=1.1,EXPmax*=1.5,speed*=0.95,Attack*=1.1;
    Setpos(-1,1),Color(0),printf("T: %d ",T);
    Setpos(-1,5),printf("Level: %d ",Lev);
    Setpos(-1,10),printf("Blood: %d (/%d) ",(int)Blood,(int)Bloodmax);
    Setpos(-1,20),printf("EXP: %d (/%d) ",(int)EXP,(int)EXPmax);
    Setpos(-1,28),printf("距离清场时间还有 %d  ",Tempty);
    if(Blood<1) Life=0;
//判定**亡
        Map(1);
        Sleep(speed);
    }
    if(Lev>=10) system("color 6E"),Sleep(1000),Win();
    else system("color 7F"),Sleep(1000),Die();
}
void Interface(){
    system("cls"); Color(5);
    Setpos(0,9),printf("EASY ** 2.0",5);
    Setpos(1,3),printf("■■■■    作者:胎神大大        ■■■");
    Setpos(2,3),printf("■                               ■");
    Setpos(3,3),printf("■■■■   ■     ■■ ■ ■     ■  ■■  ■     ■  ■    ■■");
    Setpos(4,3),printf("■        ■■    ■    ■       ■    ■ ■■   ■ ■ ■  ■ ■");
    Setpos(5,3),printf("■■■■ ■  ■ ■■    ■        ■■■ ■  ■ ■  ■  ■  ■■■2.0");
    Color(0),Setpos(7,3),printf("这是胎神大大连夜赶做出来敷衍你们的极简寒酸主界面......",10);
    Color(1),Setpos(11,3),Slow("按 C 修改角色/查看规则,",5);Color(2),Slow(" V 调整速度,",5);Color(-5),Slow(" Y",5);Color(5),Slow(" 开始游戏",5);
    Color(3),Setpos(13,3),Slow("注:因为此游戏运行程序较繁琐,容易卡,建议先调整速度!",5);
    Color(0),Setpos(28,1),printf("  -----------------------作者:胎神大大的啰嗦 P 话-----------------------\n\n     其实这个游戏的发展空间是很大的,但是无奈胎神大大时间(实力)有限只能几下赶完放出来了,唉其实超级不甘心的……这个程序创造很多实用的,用 C++ 写动画的基**函数,让普通的 C++ 程序也能做出炫酷(大雾)的效果(是我不会用(懒得编)啊啊啊),我会不定期来改 BUG 的,甚至没事干时过来多出几个人物!(像 PVP 啊, BOSS 啊我都超想编的 emm ~) \n    总之好好玩吧,    更  新  不  定   ,  敬  请  期  待    !");
}
void Time_check(){
    system("cls");
    Setpos(-1,1);Slow("  现在开始速度调整,按 C 加速, V 减速, B 退出",50);
    while(1)
    {if(kbhit()){char g=_getch();if(g=='c') speed*=0.95;else if(g=='v') speed*=1.05;else if(g=='b') break;}
        T++;if(T%2==0) Rand_put_Bullet(); 
    Setpos(-1,0),Color(0),printf("Speed: %0.3f   ",speed);Map(1);Move_bullet();Sleep(speed);} 
    Interface();
}
void Rules(){
    system("cls"); 
    Setpos(1,1),Slow("选择你的角色! ",10);
    Setpos(3,1),Slow("输入:1.小胎  2.伍六七  3.豌豆  4.DIO  5.善逸  6.Crab_Dave",10);
    while(1){
    if(kbhit()){char a=_getch();
    if(a=='1'){system("cls");
    Setpos(1,1),Slow("↑↓←→操作躲避子弹,活下去。",10);
    Setpos(3,1),Slow("角色名称:小胎",10);
    Setpos(5,1),Slow("角色编号:1",10);people=1;
    Setpos(7,1),Slow("技能:",10);
    Color(1),Setpos(9,1),Slow("C :遁之子弹(走路时反向发射,冷却时间:快) ",10);skillC=1;cMin=-1;
    Color(2),Setpos(11,1),Slow("V :护体神盾(有几率反弹子弹!冷却时间:中)",10);skillV=1;vMin=-5;
    Color(5),Setpos(13,1),Slow("B :元气烟花(无敌升级清场神器!冷却时间:慢)",10);skillB=1;bMin=-9;
    Setpos(15,1),Slow("所有技能,按的时间越久,威力越强!",10);break;}
    else if(a=='2'){system("cls");
    Setpos(1,1),Slow("↑↓←→操作躲避子弹,活下去。",10);
    Setpos(3,1),Slow("角色名称:伍六七",10);
    Setpos(5,1),Slow("角色编号:2",10);people=2;
    Setpos(7,1),Slow("技能:",10);
    Color(1),Setpos(9,1),Slow("AWSD (左手)操作剪刀!",10);skillC=0;
    Color(2),Setpos(11,1),Slow("Z或X :提升转速,加大范围!",10);skillV=0;
    Color(5),Setpos(13,1),Slow("速度越快,最大范围越大!",10);skillB=0;break;}
    else if(a=='3'){system("cls");
    Setpos(1,1),Slow("↑↓←→操作躲避子弹,活下去。",10);
    Setpos(3,1),Slow("角色名称:豌豆",10);
    Setpos(5,1),Slow("角色编号:3",10);people=3;
    Setpos(7,1),Slow("技能:",10);
    Color(1),Setpos(9,1),Slow("被动 :发射无穿透**的豌豆",10);skillC=0;
    Color(2),Setpos(11,1),Slow("V :自动发球机(连续八方向发射豌豆!冷却时间:中)",10);skillV=1;vMin=-4;
    Color(5),Setpos(13,1),Slow("B :能量豆(你懂得,无敌升级清场神器!冷却时间:慢)",10);skillB=1;bMin=-6;break;}
    else if(a=='4'){system("cls");
    Setpos(1,1),Slow("↑↓←→操作躲避子弹,活下去。",10);
    Setpos(3,1),Slow("角色名称:DIO",10);
    Setpos(5,1),Slow("角色编号:4",10);people=4;
    Setpos(7,1),Slow("技能:",10);
    Color(1),Setpos(9,1),Slow("C或V :木大直拳(冷却时间:快,时停中极快)",10);skillC=1;cMin=-0.6;
    Color(5),Setpos(13,1),Slow("B :砸瓦鲁多(你懂得!冷却时间:慢)",10);skillB=1;bMin=-8;break;}
    else if(a=='5'){system("cls");
    Setpos(1,1),Slow("↑↓←→操作躲避子弹,活下去。",10);
    Setpos(3,1),Slow("角色名称:善逸",10);
    Setpos(5,1),Slow("角色编号:5",10);people=5;
    Setpos(7,1),Slow("技能:",10);
    Color(1),Setpos(9,1),Slow("C :雷霆一步(按得越久冲的越远!冷却时间:快)",10);skillC=1;cMin=-1;
    Color(2),Setpos(11,1),Slow("V :六连(获得六次瞬移机会!冷却时间:中)",10);skillV=1;vMin=-4;
    Color(5),Setpos(13,1),Slow("B :化雷(短时获得无限瞬移机会!冷却时间:慢)",10);skillB=1;bMin=-6;break;}
    else if(a=='6'){system("cls");
    Setpos(1,1),Slow("↑↓←→操作躲避子弹,活下去。",10);
    Setpos(3,1),Slow("角色名称:Crab_Dave",10);
    Setpos(5,1),Slow("角色编号:6",10);people=6;
    Setpos(7,1),Slow("技能:",10);
    Color(1),Setpos(9,1),Slow("C :概率波(用后就知道了hhh~!冷却时间:中)",10);skillC=1;cMin=-3;
    Color(2),Setpos(11,1),Slow("V :瞬闪柱(贯穿全场的攻击!冷却时间:中)",10);skillV=1;vMin=-5;
    Color(5),Setpos(13,1),Slow("B :波函动(化为波,短时获得无限瞬移机会!冷却时间:慢)",10);skillB=1;bMin=-8;
    Setpos(15,1),Slow("一直想编一个攻击全看脸的角色呢hhh~",10);break;}
    }}
    Color(5),Setpos(17,1),Slow("所有技能,击中后会增加 EXP ,EXP 满后可以升级!",10);
    Setpos(19,1),Slow("到达 10 级 即可通关!(好没创意啊,你的 EXP 可以保留至下一局)",10);
    Setpos(21,1),system("pause");
}
int main()
{
    system("mode con cols=82 lines=44");
    CONSOLE_CURSOR_INFO cursor_info={1,0};
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
    srand((unsigned)time(NULL));Color(0); 
Rules();
    sxs: Interface();
    while(1) if(kbhit()){
        char g=_getch();
        if(g=='c') {Rules();Interface();}
        else if(g=='v') {Time_check();Interface();}
        else if(g=='y') {
        Lev=1;Blood=Bloodmax=100;EXPmax=30,EXP=0;Start_level();
        goto sxs;
        }
    }
    return 0;
}

 

0
被禁言 汪声旭
汪声旭
高级守护
高级守护
#include<iostream>
using namespace std;
int main() {
    int shengming=30,gongji=10,jinbi=10,smsx=30,duobi1=3;
    int a=0,b=0,c=0;
    cout<<"国难当道,你被选为了战士保护人民。因此您拥有以下技能:";
    for(int i=0; i<1; i--) {
        cout<<endl<<"1.购买装备和恢复生命。"<<endl;
        cout<<"2.打怪专区。"<<endl;
        cout<<"3.个人信息。"<<endl<<"输入:";
        cin>>a;
        if(a==1) {
            while(1) {
                cout<<endl<<"你的信息:(生命"<<shengming<<"),(攻击"<<gongji<<"),(金币"<<jinbi<<")"<<endl;
                cout<<"1.武器           金币>=10"<<endl;
                cout<<"2.生命           10金币+满。"<<endl;
                cout<<"3.生命上线       金币>=40"<<endl;
                cout<<"4.躲避次数+1     15金币"<<endl;
                cout<<"按0退出。"<<endl<<"输入:";
                cin>>b;
                if(b==1&&jinbi>=10) {
                    while(1) {
                        cout<<endl<<"1.石剑——10金币+5"<<endl;
                        cout<<"2.铁剑——50金币+25"<<endl;
                        cout<<"3.钻石剑——200金币+100"<<endl;
                        cout<<"4.神灵剑——1000金币+500"<<endl;
                        cout<<"0退出。"<<endl<<"输入:";
                        cin>>c;
                        if(c==1&&jinbi>=10) {
                            gongji+=5;
                            jinbi-=10;
                            cout<<"攻击:"<<gongji-5<<"+5="<<gongji<<endl;
                        } else if(c==2&&jinbi>=50) {
                            gongji+=25;
                            jinbi-=50;
                            cout<<"攻击:"<<gongji-25<<"+25="<<gongji<<endl;
                        } else if(c==3&&jinbi>=200) {
                            gongji+=100;
                            jinbi-=200;
                            cout<<"攻击:"<<gongji-100<<"+100="<<gongji<<endl;
                        } else if(c==4&&jinbi>=1000) {
                            gongji+=500;
                            jinbi-=1000;
                            cout<<"攻击:"<<gongji-500<<"+500="<<gongji<<endl;
                        } else if(c==0) {
                            break;
                        } else if(c>3) {
                            cout<<"没有这个按键。"<<endl;
                        } else {
                            cout<<"金币不够。"<<endl<<endl;
                        }
                    }
                } else if(b==2&&jinbi>=10) {
                    shengming=smsx;
                    jinbi-=10;
                    cout<<"生命="<<smsx<<endl;
                } else if(b==3&&jinbi>=40) {
                    while(1) {
                        cout<<endl<<"1.生命上线四等——40金币+10"<<endl;
                        cout<<"2.生命上线三等——100金币+25"<<endl;
                        cout<<"3.生命上线二等——400金币+100"<<endl;
                        cout<<"4.生命上线一等——2000金币+500"<<endl;
                        cout<<"0退出。"<<endl<<"输入:";
                        cin>>c;
                        if(c==1) {
                            smsx+=10;
                            shengming+=10;
                            jinbi-=40;
                            cout<<"生命上线:"<<smsx-10<<"+10="<<smsx<<endl;
                        } else if(c==2&&jinbi>=100) {
                            smsx+=25;
                            shengming+=25;
                            jinbi-=100;
                            cout<<"生命上线:"<<smsx-25<<"+25="<<smsx<<endl;
                        } else if(c==3&&jinbi>=400) {
                            smsx+=100;
                            shengming+=100;
                            jinbi-=400;
                            cout<<"生命上线:"<<smsx-100<<"+100="<<smsx<<endl;
                        } else if(c==4&&jinbi>=2000) {
                            smsx+=500;
                            shengming+=500;
                            jinbi-=2000;
                            cout<<"生命上线:"<<smsx-500<<"+500="<<smsx<<endl;
                        } else if(c==0) {
                            break;
                        } else {
                            cout<<"金币不够。"<<endl<<endl;
                        }
                    }
                } else if(b==4&&jinbi>=20) {
                    duobi1+=1;
                    jinbi-=15;
                    cout<<"躲避次数+1="<<duobi1<<endl;
                } else if(b==0) {
                    break;
                } else {
                    cout<<"金币不够。"<<endl;
                }
            }
        } else if(a==2) {
            while(1) {
                cout<<endl<<"1.地方小怪——生命20,攻击10,可获得金币10"<<endl;
                cout<<"2.地方大怪——生命100,攻击25,可获得金币25"<<endl;
                cout<<"3.小怪——生命400,攻击100,可获得金币100"<<endl;
                cout<<"4.大怪——生命1000,攻击500,可获得金币500"<<endl;
                cout<<"0退出。"<<endl<<"输入:";
                cin>>b;
                if(b==1) {
                    int sm=20,gj=10;
                    int duobi=duobi1;
                    cout<<endl<<"地方小怪——生命20,攻击10,可获得金币10"<<endl<<"你的攻击力:"<<gongji<<"  "<<"生命力:"<<shengming<<endl<<endl<<"开始  你VS怪物"<<endl;
                    while(sm>0) {
                        cout<<endl<<"1.攻击 2.躲避("<<duobi<<")可让怪物生命-5"<<endl<<"输入:";
                        cin>>c;
                        if(c==1) {
                            shengming-=gj;
                            sm-=gongji;
                            cout<<endl<<"我的生命:"<<shengming<<endl;
                            cout<<"敌方生命:"<<sm<<endl;
                        } else if(duobi>0) {
                            cout<<"躲避成功。"<<endl;
                            duobi--;
                            sm-=5;
                            cout<<"敌人生命:"<<sm+5<<"-5="<<sm<<endl;
                        }
                        if(shengming<=0) {
                            cout<<"你**了。"<<endl;
                            return 0;
                        }
                    }
                    jinbi+=10;
                    cout<<"恭喜您获得金币10"<<endl;
                } else if(b==2) {
                    cout<<endl<<"地方大怪——生命100,攻击25,可获得金币25"<<endl<<"你的攻击力:"<<gongji<<"  "<<"生命力:"<<shengming<<endl<<endl<<"开始  你VS怪物"<<endl;
                    int sm=100,gj=25;
                    int duobi=duobi1;
                    while(sm>0) {
                        cout<<endl<<"1.攻击 2.躲避("<<duobi<<")"<<endl<<"输入:";
                        cin>>c;
                        if(c==1) {
                            shengming-=gj;
                            sm-=gongji;
                            cout<<endl<<"我的生命:"<<shengming<<endl;
                            cout<<"敌方生命:"<<sm<<endl;
                        } else if(duobi>0) {
                            cout<<"躲避成功。"<<endl;
                            duobi--;
                            sm-=5;
                            cout<<"敌人生命:"<<sm+5<<"-5="<<sm<<endl;
                        }
                        if(shengming<=0) {
                            cout<<"你**了。"<<endl;
                            return 0;
                        }
                    }
                    jinbi+=25;
                    cout<<"恭喜您获得金币25"<<endl;
                } else if(b==3) {
                    cout<<endl<<"小怪——生命400,攻击100,可获得金币100"<<endl<<"你的攻击力:"<<gongji<<"  "<<"生命力:"<<shengming<<endl<<endl<<"开始  你VS怪物"<<endl;
                    int sm=400,gj=100;
                    int duobi=duobi1;
                    while(sm>0) {
                        cout<<endl<<"1.攻击 2.躲避("<<duobi<<")"<<endl<<"输入:";
                        cin>>c;
                        if(c==1) {
                            shengming-=gj;
                            sm-=gongji;
                            cout<<endl<<"我的生命:"<<shengming<<endl;
                            cout<<"敌方生命:"<<sm<<endl;
                        } else if(duobi>0) {
                            cout<<"躲避成功。"<<endl;
                            duobi--;
                            sm-=5;
                            cout<<"敌人生命:"<<sm+5<<"-5="<<sm<<endl;
                        }
                        if(shengming<=0) {
                            cout<<"你**了。"<<endl;
                            return 0;
                        }
                    }
                    jinbi+=100;
                    cout<<"恭喜您获得金币100"<<endl;
                } else if(b==4) {
                    cout<<endl<<"大怪——生命1000,攻击500,可获得金币500"<<endl<<"你的攻击力:"<<gongji<<"  "<<"生命力:"<<shengming<<endl<<endl<<"开始  你VS怪物"<<endl;
                    int sm=1000,gj=500;
                    int duobi=duobi1;
                    while(sm>0) {
                        cout<<endl<<"1.攻击 2.躲避("<<duobi<<")"<<endl<<"输入:";
                        cin>>c;
                        if(c==1) {
                            shengming-=gj;
                            sm-=gongji;
                            cout<<endl<<"我的生命:"<<shengming<<endl;
                            cout<<"敌方生命:"<<sm<<endl;
                        } else if(duobi>0) {
                            cout<<"躲避成功。"<<endl;
                            duobi--;
                            sm-=5;
                            cout<<"敌人生命:"<<sm+5<<"-5="<<sm<<endl;
                        }
                        if(shengming<=0) {
                            cout<<"你**了。"<<endl;
                            return 0;
                        }
                    }
                    jinbi+=100;
                    cout<<"恭喜您获得金币500"<<endl;
                } else if(b==0) {
                    break;
                }
            }
        } else if(a==3) {
            cout<<endl<<"你的生命:"<<shengming<<endl;
            cout<<"你的攻击:"<<gongji<<endl;
            cout<<"你的金币:"<<jinbi<<endl;
            cout<<"防御次数:"<<duobi1<<endl;
            cout<<"生命上限:"<<smsx<<endl;
        } else {
            cout<<"没有这个按键。"<<endl;
        }
    }
    return 0;
}

 

0
被禁言 汪声旭
汪声旭
高级守护
高级守护
#include <easyx.h>
#include <time.h>
#include <conio.h>

class Bullet;
class Tank;
class E_Bullet;
class Boss;
bool dead = false;
bool wined = false;
struct pos//坐标类
{
 int a;
 int b;
};
class E_Bullet//敌人打出的子弹
{
public:
 clock_t d;
 int x;
 int y;
 bool on = false;
 pos show()//画出新的位置
 {
 setfillcolor(RGB(255, 180, 20));
 fillrectangle(x - 5, y - 5, x + 5, y + 5);
 return pos{ x,y };
 }
 pos del()//覆盖原来的位置
 {
 setfillcolor(0);
 setlinecolor(0);
 fillrectangle(x - 5, y - 5, x + 5, y + 5);
 rectangle(x - 5, y - 5, x + 5, y + 5);
 return pos{ x,y };
 }
 pos move()//左移
 {
 x -= 3;
 return pos{ x,y };
 }
};
class Bullet//玩家打出的子弹,同上
{
public:
 clock_t d;
 int x;
 int y;
 bool on = false;
 pos show()
 {
 setfillcolor(RGB(150, 180, 210));
 fillrectangle(x - 5, y - 5, x + 5, y + 5);
 return pos{ x,y };
 }
 pos del()
 {
 setfillcolor(0);
 setlinecolor(0);
 fillrectangle(x - 5, y - 5, x + 5, y + 5);
 rectangle(x - 5, y - 5, x + 5, y + 5);
 return pos{ x,y };
 }
 pos move()//右移
 {
 x += 3;
 return pos{ x,y };
 }
};
class Boss//敌人
{
public:
 bool hurting = false;
 clock_t d_hurt;
 COLORREF clr = RGB(0, 130, 125);
 int x;
 int y;
 int hp = 100;//生命
 clock_t d;//判断举例上一次执行某一函数过了多久
 clock_t att_d;
 bool angle = false;//方向
 pos show()
 {
 setfillcolor(clr);
 fillrectangle(x - 20, y - 40, x + 20, y + 40);
 return pos{ x,y };
 }
 pos del()
 {
 setfillcolor(0);
 setlinecolor(0);
 rectangle(x - 20, y - 40, x + 20, y + 40);
 fillrectangle(x - 20, y - 40, x + 20, y + 40);
 return pos{ x,y };
 }
 void fire(E_Bullet& but)//攻击
 {
 but.on = true;//放置一个子弹
 but.x = x - 20;
 but.y = y;
 but.d = clock();
 }
 void move()//上上下下得移动
 {
 if (angle == true)
 y -= 5;
 if (angle == false)
 y += 5;
 if (y >= 440)
 angle = true;
 if (y <= 40)
 angle = false;
 }
 void hurt()//**
 {
 hp -= 4;
 d_hurt = clock();
 setfillcolor(0);
 setlinecolor(WHITE);
 fillrectangle(160, 485, 560, 510);//更新血条
 rectangle(160, 485, 160 + hp * 4, 510);
 setfillcolor(RGB(230, 0, 1));
 setlinecolor(RGB(255, 255, 255));
 fillrectangle(160, 485, 160 + hp * 4, 510);
 rectangle(160, 485, 160 + hp * 4, 510);
 hurting = true;
 if (hp <= 0)//**亡
 {
 wined = true;
 }
 }
};
class Tank//玩家类,同上
{
public:
 bool hurting = false;
 int hp = 100;
 int x;
 COLORREF clr = RGB(150, 180, 210);
 int y;
 clock_t d_hurt;
 Tank() {}
 Tank(int _x, int _y) { x = _x; y = _y; }
 Tank operator=(pos p) { x = p.a; y = p.a; }
 pos show()
 {
 setfillcolor(clr);
 fillrectangle(x - 25, y - 25, x + 25, y + 25);
 setfillcolor(RGB(100, 200, 180));
 fillrectangle(x, y + 5, x + 40, y - 5);
 return pos{ x,y };
 }
 pos del()
 {
 setfillcolor(0);
 setlinecolor(0);
 fillrectangle(x - 25, y - 25, x + 25, y + 25);
 rectangle(x - 25, y - 25, x + 25, y + 25);
 fillrectangle(x, y + 5, x + 40, y - 5);
 rectangle(x, y + 5, x + 40, y - 5);
 return pos{ x,y };
 }
 void fire(Bullet& but)
 {
 but.on = true;
 but.x = x + 45;
 but.y = y;
 but.d = clock();
 but.show();
 }
 void hurt()
 {
 hp -= 2;
 d_hurt = clock();
 setfillcolor(0);
 setlinecolor(WHITE);
 fillrectangle(160, 515, 560, 540);
 rectangle(160, 515, 560, 540);
 rectangle(160, 515, 160 + hp * 4, 540);
 setfillcolor(RGB(0, 255, 1));
 setlinecolor(RGB(255, 255, 255));
 fillrectangle(160, 515, 160 + hp * 4, 540);
 rectangle(160, 515, 160 + hp * 4, 540);
 hurting = true;
 if (hp <= 0)
 dead = true;
 }
};
#define BT_MAX 8
int main()
{
 initgraph(640, 550, 4);//初始化屏幕
 settextcolor(RGB(0, 254, 0));
 settextstyle(35, 0, _T("黑体"));
 outtextxy(150, 200, _T("W,S移动,K攻击"));
 Sleep(3000);
 setlinecolor(0);
 setfillcolor(0);
 rectangle(0, 0, 640, 550);
 fillrectangle(0, 0, 640, 550);
 setlinecolor(RGB(255, 255, 255));
 setfillcolor(RGB(255, 255, 255));
 clock_t delay = clock();//玩家移动的延时
 clock_t d_f = clock();//玩家开火的延时
 line(0, 481, 640, 481);//分割画面与血条
 Bullet bt[BT_MAX];//玩家的子弹
 Tank tk(30, 30);//玩家
 Boss bo;//敌人
 bo.x = 580;
 bo.y = 240;
 E_Bullet ebt[BT_MAX];//敌人的子弹
 bo.d = clock();//初始化延时
 bo.att_d = clock();
 tk.show();
 settextstyle(20, 0, _T("黑体"));
 outtextxy(10, 485, _T("BOSS的生命值:"));
 setfillcolor(RGB(230, 0, 1));
 fillrectangle(160, 485, 560, 510);//敌人血条
 outtextxy(10, 520, _T("玩家的生命值:"));
 setfillcolor(RGB(0, 255, 1));
 fillrectangle(160, 515, 560, 540);//玩家血条
 while (1)//主循环
 {
 if (wined || dead)//玩家**了或者敌人**了
 break;
 if (GetAsyncKeyState('W') & 0x8000)//玩家移动
 {
 if (tk.y > 28 && (clock() - delay) >= 40)
 {
 tk.del(); tk.y -= 3; tk.show(); delay = clock();
 }
 }
 if (GetAsyncKeyState('w') & 0x8000)//玩家移动
 {
 if (tk.y > 28 && (clock() - delay) >= 40)
 {
 tk.del(); tk.y -= 3; tk.show(); delay = clock();
 }
 }
 if (GetAsyncKeyState('k') & 0x8000)//玩家开火
 {
 for (int i = 0; i < BT_MAX; i++)
 {
 if (bt[i].on == false && (clock() - d_f) > 800)
 {
  bt[i].on = true;
  tk.fire(bt[i]);
  d_f = clock();
  break;
 }
 }
 }
 if (GetAsyncKeyState('K') & 0x8000)//玩家开火
 {
 for (int i = 0; i < BT_MAX; i++)
 {
 if (bt[i].on == false && (clock() - d_f) > 800)
 {
  tk.fire(bt[i]);
  d_f = clock();
  break;
 }
 }
 }
 if (GetAsyncKeyState('S') & 0x8000)//玩家移动
 {
 if (tk.y < 452 && (clock() - delay) >= 40)
 {
 tk.del(); tk.y += 3; tk.show(); delay = clock();
 }
 }
 if (GetAsyncKeyState('s') & 0x8000)//玩家移动
 if (tk.y < 452 && (clock() - delay) >= 40)
 {
 tk.del(); tk.y += 3; tk.show(); delay = clock();
 }
 for (int i = 0; i < BT_MAX; i++)//遍历子弹,使子弹刷新
 {
 if (bt[i].on == true && (clock() - bt[i].d) > 20)
 {
 bt[i].del();
 bt[i].move();
 bt[i].show();
 bt[i].d = clock();
 if (bt[i].x >= 635)
  bt[i].on = false, bt[i].del();//到达了屏幕最右端
 if ((bt[i].x + 5 >= bo.x - 20 && bt[i].x - 5 <= bo.x + 20) && (bt[i].y - 5 < bo.y + 40 && bt[i].y + 5 > bo.y - 40))
  //击中敌人
  bt[i].on = false, bo.hurt(), bt[i].del();
 }
 }
 if (clock() - bo.att_d > 700)//敌人自动开火
 {
 for (int i = 0; i < BT_MAX; i++)
 {
 if (ebt[i].on == false)
 {
  bo.fire(ebt[i]); break;
 }
 }
 bo.att_d = clock();
 }
 for (int i = 0; i < BT_MAX; i++)//敌人子弹刷新,同上
 {
 if (ebt[i].on == true && (clock() - ebt[i].d > 20))
 {
 ebt[i].del();
 ebt[i].move();
 ebt[i].show();
 ebt[i].d = clock();
 if (ebt[i].x < 5)
  ebt[i].del(), ebt[i].on = false;
 if (ebt[i].x - 5 < tk.x + 25 && ebt[i].x + 5 > tk.x - 25 && ebt[i].y - 5 < tk.y + 25 && ebt[i].y + 5 > tk.y - 25)
 {
  ebt[i].on = false, tk.hurt(), ebt[i].del();
 }
 }
 }
 if (tk.hurting == true)//玩家**闪烁0.1秒
 if (clock() - tk.d_hurt > 100)
 {
 tk.clr = RGB(150, 180, 210), tk.show(), tk.hurting = false;
 }
 else
 tk.clr = RGB(255, 0, 0), tk.show();
 if (bo.hurting == true)//敌人**闪烁0.1秒
 if (clock() - bo.d_hurt > 100)
 {
 bo.clr = RGB(0, 130, 125), bo.show(), bo.hurting = false;
 }
 else
 bo.clr = RGB(0, 255, 0), bo.show();
 if (clock() - bo.d > 50)//敌人移动延时;
 bo.del(), bo.move(), bo.show(), bo.d = clock();
 }
 if (wined)//胜负已分
 {
 settextcolor(RGB(0, 254, 0));
 settextstyle(35, 0, _T("黑体"));
 outtextxy(150, 200, _T("你打败了boss!你赢了!!"));
 }
 else
 {
 settextcolor(RGB(254, 0, 0));
 settextstyle(35, 0, _T("黑体"));
 outtextxy(140, 200, _T("你被boss打败了!"));
 }
 Sleep(5000);
 closegraph();
 return 0;
}

 

0
被禁言 汪声旭
汪声旭
高级守护
高级守护
#include<stdio.h>
#include<math.h>
#include<graphics.h>//easyx 包含头文件,可以使用提供的接口,函数
#define WIN_WIDTH 1080
#define WIN_HEIGHT 640
#define MAX_IMAGE 11  //最大图片数量
#define MAX_MINE 10   //最大物品数量
#define MAX_ANGLE 80 //最大角度
#define PI 3.1415926535898
//int a,char b
enum MINE //枚举图片数组下标
{
    i_gold=1,
    i_money=3,
    i_soledown=5,
    i_soleup=7,
    i_stone=9,
    i_bk = MAX_IMAGE-1,
};
enum MINE_TYPE //物品类型枚举
{
    GOLD,
    MONEY,
    STONE,
    //方向
    LEFT,
    RIGHT,
    //状态,正常,伸长,缩短
    M_NOMAL,
    M_LONG,
    M_SHORT,
};
struct Sole //角色信息
{
    int x;//贴图位置
    int y;
    int width;//图片宽高
    int height;
    int coin;//金币
}sole;
struct Mine //物品
{
    int x;
    int y;
    int szie; //边界判断
    bool flag;//是否存在
    int type;//物品类型,石头,金块,钱袋
    int gold;//物品价值
}mine[MAX_MINE];
struct Hook //钩子
{
    int x;
    int y;
    int endx;
    int endy;
    int len;//长度
    int angle;//角度
    int dir;//摆动方向
    int vx;//速度分量
    int vy;
    int state;
    int index;//记录抓到的物品下标
}hook;
IMAGE img[MAX_IMAGE];
int distance(Hook hook);
//初始化数据
void GameInit()
{
    //创建窗口 init 初始化  graphics图形界面
    initgraph(WIN_WIDTH, WIN_HEIGHT,SHOWCONSOLE);
    //设置随机数种子
    srand(GetTickCount());
    //加载图片
    for (int i = 0; i < MAX_IMAGE-1; i++)
    {
        char temp[25]="";
        sprintf(temp, "./images/%d.jpg", i);
        if (i <= 1)
        {
            loadimage(&img[i], temp,73,62);//注意:字符集问题
        }
        else
        {
            loadimage(&img[i], temp);//注意:字符集问题
        }

    }
    loadimage(&img[i_bk], "./images/bk.jpg", WIN_WIDTH, WIN_HEIGHT-120);
    //初始化角色信息
    sole.width = 140;
    sole.height = 120;
    sole.x = WIN_WIDTH/2-sole.width/2;//x轴居中
    sole.y = 0;
    sole.coin = 0;

    //初始化物品信息
    for (int i = 0; i < MAX_MINE; i++)
    {
        mine[i].flag = true;
        mine[i].gold = rand() % 200+1;
        mine[i].szie = 60;
        mine[i].type = rand()%3;
        mine[i].x = rand() % (WIN_WIDTH - 60);
        mine[i].y = rand() % (WIN_HEIGHT - 150) + 150;
    }
    //初始化钩子
    hook.x = sole.x + 40;
    hook.y = sole.y + 100;
    hook.len = 50;
    hook.endx = hook.x;
    hook.endy = hook.y + hook.len;
    hook.angle = 0;
    hook.dir = RIGHT;
    hook.vx = 0;
    hook.vy = 0;
    hook.state = M_NOMAL;
    hook.index = -1;
}
//游戏绘制
void GameDraw()
{
    //绘制背景
    putimage(0, 120, &img[i_bk]);
    //绘制角色背景颜色
    setfillcolor(RGB(255, 208, 52));
    solidrectangle(0, 0, WIN_WIDTH, 120);
    //绘制角色
    putimage(sole.x, sole.y, &img[i_soledown-1],SRCAND);//知道为啥减1不?
    putimage(sole.x, sole.y, &img[i_soledown],SRCPAINT);
    //绘制物品
    for (int i = 0; i < MAX_MINE; i++)
    {
        if (mine[i].flag == true)
        {
            switch (mine[i].type)
            {
            case GOLD:
                putimage(mine[i].x, mine[i].y, &img[i_gold-1],SRCAND);
                putimage(mine[i].x, mine[i].y, &img[i_gold],SRCPAINT);
                break;
            case MONEY:
                putimage(mine[i].x, mine[i].y, &img[i_money - 1], SRCAND);
                putimage(mine[i].x, mine[i].y, &img[i_money], SRCPAINT);
                break;
            case STONE:
                putimage(mine[i].x, mine[i].y, &img[i_stone - 1], SRCAND);
                putimage(mine[i].x, mine[i].y, &img[i_stone], SRCPAINT);
                break;
            }
        }
    }
    //绘制钩子
    setlinecolor(BROWN);
    setlinestyle(PS_SOLID, 5);
    line(hook.x, hook.y, hook.endx, hook.endy);

    //绘制分数
    char score[30] = "";
    sprintf(score, "分数:%d", sole.coin);
    settextcolor(WHITE);
    setbkmode(TRANSPARENT);
    settextstyle(50, 0, "楷体");
    outtextxy(20, 20, score);
}
//钩子摆动
void HookRock()
{
    if (hook.state == M_NOMAL)
    {
        if (hook.dir == RIGHT)
        {
            hook.angle++;
        }
        else
        {
            hook.angle--;
        }
        if (hook.angle > MAX_ANGLE)
        {
            hook.dir = LEFT;
        }
        else if (hook.angle<-MAX_ANGLE)
        {
            hook.dir = RIGHT;
        }
        //角度转弧度  360 2pai  180  PI  
        hook.endx = hook.x + sin(PI / 180 * hook.angle)*hook.len;
        hook.endy = hook.y + cos(PI / 180 * hook.angle)*hook.len;
    }

}

//游戏控制
void GameControl(int speed)
{
    if (GetAsyncKeyState(VK_SPACE) && hook.state==M_NOMAL)
    {
        //按键,求出速度分量
        hook.vx = sin(PI / 180 * hook.angle)*speed;
        hook.vy = cos(PI / 180 * hook.angle)*speed;
        hook.state = M_LONG;
    }
    //碰到边界返回
    if (hook.endx<0 || hook.endx>WIN_WIDTH || hook.endy > WIN_HEIGHT)
    {
        hook.state = M_SHORT;
    }
    if (hook.state == M_LONG)
    {
        hook.endx += hook.vx;
        hook.endy += hook.vy;
    }
    else if (hook.state==M_SHORT)
    {
        hook.endx -= hook.vx;
        hook.endy -= hook.vy;
        //缩短完成
        if (distance(hook))
        {
            hook.state = M_NOMAL;
        }
    }
    //接下来就是让hook.endx 加上hook.vx
    printf("%d %d\n", hook.vx, hook.vy);
}
void JudgeGrap()
{
    //判断抓到那个物品
    for (int i = 0; i < MAX_MINE; i++)
    {
        if (mine[i].flag == true &&
            hook.endx>mine[i].x && hook.endx<mine[i].x+mine[i].szie &&
            hook.endy>mine[i].y && hook.endy<mine[i].y+mine[i].szie)
        {
            hook.index = i;
            break;
        }
    }
    //如果抓到了
    if (hook.index != -1)
    {
        hook.state = M_SHORT;
        mine[hook.index].x = hook.endx;
        mine[hook.index].y = hook.endy;
        //缩短完成
        if (distance(hook))
        {
            mine[hook.index].flag = false;
            hook.index = -1;
            hook.state = M_NOMAL;
        }
    }
}
//void main 
int main()
{
    GameInit();
    DWORD t1 , t2;
    t1 = t2 = GetTickCount();
    BeginBatchDraw();
    while (1)
    {
        if (t2 - t1 > 15)
        {
            HookRock();
            t1 = t2;
        }
        t2 = GetTickCount();
        GameDraw();
        FlushBatchDraw();
        GameControl(10);
        JudgeGrap();
        //防止闪退
    }
    return 0;
}
int distance(Hook hook)
{
    int dis = sqrt((float)(hook.x - hook.endx)*(hook.x - hook.endx) + (hook.y - hook.endy)*(hook.y - hook.endy));
    return dis <= hook.len;
}

 

0
被禁言 汪声旭
汪声旭
高级守护
高级守护
#include "Menu.h"
#include <windows.h>
#include "Game.h"
//显示欢迎界面
void Menu::Show_Welcome()
{
    Map::Colors(白色);
    Map::WriteChar(2,8,"I -         2600              HI -             20000");
    Map::Colors(紫色);
    Map::WriteChar(5, 10,   "▓▓▓▓▓        ▓       ▓▓▓▓▓  ▓▓▓▓▓  ▓        ▓▓▓▓▓");
    Sleep(100);
    Map::WriteChar(6, 10,   "▓       ▓     ▓  ▓         ▓          ▓      ▓        ▓        ");
    Sleep(100);
    Map::WriteChar(7, 10,   "▓       ▓    ▓    ▓        ▓          ▓      ▓        ▓        ");
    Sleep(100);
    Map::WriteChar(8, 10,   "▓▓▓▓▓    ▓      ▓       ▓          ▓      ▓        ▓▓▓▓▓");
    Sleep(100);
    Map::WriteChar(9, 10,   "▓       ▓  ▓▓▓▓▓▓      ▓          ▓      ▓        ▓        ");
    Sleep(100);
    Map::WriteChar(10, 10,  "▓       ▓  ▓        ▓      ▓          ▓      ▓        ▓        ");
    Sleep(100);
    Map::WriteChar(11, 10,  "▓▓▓▓▓   ▓        ▓      ▓          ▓      ▓▓▓▓  ▓▓▓▓▓");
    Sleep(100);
    Map::WriteChar(13, 14,  "    ▓▓▓▓       ▓▓▓▓▓   ▓▓▓▓▓    ▓      ▓ ");
    Sleep(100);
    Map::WriteChar(14, 14,  "  ▓▓      ▓         ▓           ▓        ▓      ▓ ");
    Sleep(100);
    Map::WriteChar(15, 14,  " ▓▓                  ▓           ▓         ▓    ▓  ");
    Sleep(100);
    Map::WriteChar(16, 14,  "▓                     ▓           ▓          ▓▓▓   ");
    Sleep(100);
    Map::WriteChar(17, 14,  " ▓▓                  ▓           ▓            ▓     ");
    Sleep(100);
    Map::WriteChar(18, 14,  "  ▓▓      ▓         ▓           ▓            ▓     ");
    Sleep(100);
    Map::WriteChar(19, 14,  "    ▓▓▓▓       ▓▓▓▓▓       ▓            ▓     ");
    Sleep(200);
}
//静态菜单信息
void Menu::Show_Menu()
{
    Map::Colors(白色);    
    Map::WriteChar(38,22, "@  1990  1980  NAMCO  LTD.");
    Map::WriteChar(39,24, "ALL RIGHTS  RESERVED");
}
//自定义地图赋值及打印
int tool::Init_Map[41][41];
void tool::Init_Info()
{
    int i,j;
    for (i = 0; i < HIGHT; i++)
    {
        for (j = 0; j < WIDTH; j++)
        {
            Init_Map[41][41];


            //初始化边框
            if (Init_Map[i][j] == 边框)
            {
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN
                    | FOREGROUND_RED | FOREGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE);
                Map::WriteChar(i, j, "■");
            }

            if (Init_Map[i][j] == 黄土墙)//被击中变成红土墙
            {
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_RED);
                Map::WriteChar(i, j, "▓");
            }
            if (Init_Map[i][j] == 红土墙)
            {
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_RED);
                Map::WriteChar(i, j, "▓");
            }
            if (Init_Map[i][j] == 水流)
            {
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | BACKGROUND_BLUE | FOREGROUND_BLUE | FOREGROUND_GREEN);
                Map::WriteChar(i, j, "~");
            }
            if (Init_Map[i][j] == 钢墙)
            {
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN| FOREGROUND_RED | FOREGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE);
                Map::WriteChar(i, j, "■");
            }
            if (Init_Map[i][j] == 老家)
            {
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN);
                Map::Map::WriteChar(37, 19, "◣★◢");
                Map::WriteChar(38, 19, "███");
                Map::WriteChar(39, 19, "◢█◣");

            }
            Map::Colors(黑色);
        }
    }
}
void tool::menu()
{
    COORD Coord[3];
    const char mu[3][16] =
    {
        "               ",
         "1  PLAYER",
         "2  PLAYERS",
    };
    for (int i = 0; i < 3; i++)
    {
        Coord[i].Y = 24;
    }
    Coord[0].X = 23;
    Coord[1].X = 25;
    Coord[2].X = 27;

    for (int i = 0; i < 3; i++)
    {
        Map::WriteChar(Coord[i].X, Coord[i].Y, mu[i]);
    }
    Map::Colors(绿色);
    Map::WriteChar(Coord[1].X, Coord[1].Y, mu[1]);
    int Select = 1;
    while (1)
    {
        if (GetAsyncKeyState('W') & 0x8001)
        {
            Map::Colors(白色);
            Map::WriteChar(Coord[Select].X, Coord[Select].Y, mu[Select]);
            if (Select == 1)
                Select = 2;
            else
                Select--;
            Map::Colors(绿色);
            Map::WriteChar(Coord[Select].X, Coord[Select].Y, mu[Select]);
        }
        else if (GetAsyncKeyState('S') & 0x8001)
        {
            Map::Colors(白色);
            Map::WriteChar(Coord[Select].X, Coord[Select].Y, mu[Select]);
            if (Select == 2)
                Select = 1;
            else
                Select++;
            Map::Colors(绿色);
            Map::WriteChar(Coord[Select].X, Coord[Select].Y, mu[Select]);
        }
        else if (GetAsyncKeyState(0xD) & 0x8001)//回车键
        {
            switch (Select)
            {
            case 1:Game::play = 1; break;
            case 2:Game::play = 2; break;
            default:
                break;
            }
            return;
        }
        Sleep(200);
    }
}

 

0
被禁言 汪声旭
汪声旭
高级守护
高级守护
//作者有点懒,每次标题界面都是以前复制的
#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h> 
using namespace std;
int main()
{
    system("title 双人抢滩登陆1.0版本");//标题 
    system("mode con cols=60 lines=37");//设置窗口大小
    string s="|                     双 人 抢 滩 登 陆                    |";
    string s1="|                        开 始 游 戏                       |";
    string s2="|                        玩 法 说 明                       |";
    string s3="|                        更 换 皮 肤                       |"; 
    cout<<"@==========================================================@"<<endl;
    cout<<"|                                                          |"<<endl;
    cout<<"|                                                          |"<<endl;
    for(int i=0;i<s.size();i++){
        cout<<s[i];
        Sleep(10);//Sleep函数延长时间 
    }
    cout<<endl;
    cout<<"|                                                          |"<<endl;
    for(int i=0;i<s1.size();i++){
        cout<<s1[i];
        Sleep(10);
    }
    cout<<endl;
    cout<<"|                                                          |"<<endl;
    for(int i=0;i<s2.size();i++){
        cout<<s2[i];
        Sleep(10);
    }
    cout<<endl;
    cout<<"|                                                          |"<<endl;
    for(int i=0;i<s3.size();i++){
        cout<<s3[i];
        Sleep(10);
    }
    cout<<endl;
    cout<<"|                                                          |"<<endl;
    cout<<"|                                                          |"<<endl;
    cout<<"|                                                          |"<<endl;
    cout<<"|(按‘k’开始游戏,按‘b’看玩法说明,按‘d’换皮肤)                 |"<<endl;
    cout<<"@==========================================================@"<<endl;
    return 0;
}

 

0
被禁言 汪声旭
汪声旭
高级守护
高级守护
#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h> 
using namespace std;
string a[210]={
    "############################################################",
    "#           #       #                  #       #           #",
    "#           @#      #         #        #      #&           #",
    "#                   #         #        #                   #",
    "#           @       #                  #       &           #",
    "#                   #### #      #      ###                 #",
    "#           @            #      #      #       &           #",
    "#0                  #    #           ###                  1#",
    "#0    *     @       #    #   #                 &     $    1#",
    "#0                           #                            1#",
    "#           @       ######           ###       &           #",
    "#                   #           #      #                   #",
    "#           @       #           #      #       &           #",
    "#                   #        #                             #",
    "#           @            #   #      ####       &           #",
    "#                   #    #          #                      #",
    "#           @       #    #      #   #          &           #",
    "#                        #      #   #                      #",
    "#           @#        ####          #         #&           #",
    "#           #                                  #           #",
    "############################################################",
    "wasd,ijkl上下左右移动,x,n攻击,o退出",
    "1号玩家:XXX",
    "2号玩家:XXX", 
    "1号基地水晶:XXXXXXXXXX", 
    "2号基地水晶:XXXXXXXXXX",
};
string a1[4]={
    "1号玩家:XXX",
    "1号玩家:XX",
    "1号玩家:X",
    "1号玩家:阵亡",
};
string a2[4]={
    "2号玩家:XXX",
    "2号玩家:XX",
    "2号玩家:X",
    "2号玩家:阵亡",
};
string b2[11]={
    "2号基地水晶:XXXXXXXXXX",
    "2号基地水晶:XXXXXXXXX",
    "2号基地水晶:XXXXXXXX",
    "2号基地水晶:XXXXXXX",
    "2号基地水晶:XXXXXX",
    "2号基地水晶:XXXXX",
    "2号基地水晶:XXXX",
    "2号基地水晶:XXX",
    "2号基地水晶:XX",
    "2号基地水晶:X",
    "2号基地水晶:阵亡",
};
string b1[11]={
    "1号基地水晶:XXXXXXXXXX",
    "1号基地水晶:XXXXXXXXX",
    "1号基地水晶:XXXXXXXX",
    "1号基地水晶:XXXXXXX",
    "1号基地水晶:XXXXXX",
    "1号基地水晶:XXXXX",
    "1号基地水晶:XXXX",
    "1号基地水晶:XXX",
    "1号基地水晶:XX",
    "1号基地水晶:X",
    "1号基地水晶:阵亡",
};
int main()
{
    //system("color F8");
    system("title 双人抢滩登陆1.0版本");//标题 
    system("mode con cols=60 lines=37");//设置窗口大小
    string s="|                     双 人 抢 滩 登 陆                    |";
    string s1="|                        开 始 游 戏                       |";
    string s2="|                        玩 法 说 明                       |";
    string s3="|                        更 换 皮 肤                       |"; 
    cout<<"@==========================================================@"<<endl;
    cout<<"|                                                          |"<<endl;
    cout<<"|                                                          |"<<endl;
    for(int i=0;i<s.size();i++){
        cout<<s[i];
        Sleep(10);//Sleep函数延长时间 
    }
    cout<<endl;
    cout<<"|                                                          |"<<endl;
    for(int i=0;i<s1.size();i++){
        cout<<s1[i];
        Sleep(10);
    }
    cout<<endl;
    cout<<"|                                                          |"<<endl;
    for(int i=0;i<s2.size();i++){
        cout<<s2[i];
        Sleep(10);
    }
    cout<<endl;
    cout<<"|                                                          |"<<endl;
    for(int i=0;i<s3.size();i++){
        cout<<s3[i];
        Sleep(10);
    }
    cout<<endl;
    cout<<"|                                                          |"<<endl;
    cout<<"|                                                          |"<<endl;
    cout<<"|                                                          |"<<endl;
    cout<<"|(按‘k’开始游戏,按‘b’看玩法说明,按‘d’换皮肤)        |"<<endl;
    cout<<"@==========================================================@"<<endl;
    char ch;
    ch=getch();//提取键盘指令 
    if(ch=='b'){
        system("cls");
        string c="使用wasd控制‘*’(玩家1)移动,ijkl控制‘$’(玩家2)移动,‘#’为边界,‘x’玩家一攻击,‘n’玩家二攻击,‘0,1’水晶";
        string c1="玩家目标是通过战斗对方,击碎对方水晶,即可胜利。";
        string c2="说明:此为抢滩登陆1.0版本。";
        string c3="更新:增加了换肤功能。";
        cout<<"版本:1.0"<<endl;
        cout<<"按1直接显示所有内容,否则按2。"<<endl;
        int q;
        q=getch();
        if(q=='1'){
            cout<<c3<<endl<<c<<endl<<c1<<endl<<c2<<endl;
        } 
        if(q=='2'){
            for(int i=0;i<c3.size();i++){
                cout<<c3[i];
                Sleep(100);//延时 
            } 
            cout<<endl;
            for(int i=0;i<c.size();i++){
                cout<<c[i];
                Sleep(100);
            } 
            cout<<endl;
            for(int i=0;i<c1.size();i++){
                cout<<c1[i];
                Sleep(100);
            } 
            cout<<endl;
            for(int i=0;i<c2.size();i++){
                cout<<c2[i];
                Sleep(100);
            } 
            cout<<endl;
        }
        cout<<"按y开始游戏。按e换皮肤。"; 
        ch=getch();
    }
    if(ch=='d'||ch=='e'){
        system("cls");
        cout<<"请选择皮肤:"<<endl;
        cout<<"1.【日间色】"<<endl<<"2.【夜间色】"<<endl<<"3.【黑客】"<<endl<<"4.【科幻】"<<endl<<"5.【紫水晶】"<<endl;
        cout<<"开始游戏请按q,换肤请输入序号。";
        char sh;
        while(1){
            sh=getch();
            if(sh-'0'==1)
                    system("color f0");
            else if(sh-'0'==2)
                    system("color 0f");
            else if(sh-'0'==3)
                    system("color 0a");
            else if(sh-'0'==4)
                    system("color 09");
            else if(sh-'0'==5)
                    system("color 01");
            else if(sh=='q'){
                ch='q';
                break;
            }
        }
    }
    if(ch=='k'||ch=='y'||ch=='q'){
        system("cls");//清屏 
        cout<<"加载代码中";
        Sleep(2000);
        system("cls");
        cout<<"加载代码中 ◎         20%";
        Sleep(2000);
        system("cls");
        cout<<"加载地图中 ◎◎       40%";
        Sleep(2000);
        system("cls");
        cout<<"加载地图中 ◎◎◎     60%";
        Sleep(2000);
        system("cls");
        cout<<"生成地图中 ◎◎◎◎   80%";
        Sleep(2000);
        system("cls");
        cout<<"生成地图中 ◎◎◎◎◎ 100%";
        Sleep(2000);
        system("cls");
        cout<<"完成!!!";
        Sleep(2000);
        system("cls");
        for(int i=0;i<=25;i++){
            cout<<a[i]<<endl;//将地图一行一行输出 
        }
        char b;
        int x=8,y=6,ex=8,ey=53,blooda=3,bloodb=3,blood1=10,blood0=10;//玩家初始坐标 
        //wasd移动 
        while(1){//重复运动 
            b=getch();
            if(b=='a'){ 
                if(a[x][y-1]!='#'&&a[x][y-1]!='@'&&a[x][y-1]!='&'&&a[x][y-1]!='$'&&a[x][y-1]!='0'&&a[x][y-1]!='1'){
                    a[x][y]=' ';
                    y--;
                    a[x][y]='*'; 
                }
            }
            else if(b=='s'){
                if(a[x+1][y]!='#'&&a[x+1][y]!='@'&&a[x+1][y]!='&'&&a[x+1][y]!='$'&&a[x+1][y]!='0'&&a[x+1][y]!='1'){
                    a[x][y]=' ';
                    x++;
                    a[x][y]='*';
                }
            }
            else if(b=='d'){
                if(a[x][y+1]!='#'&&a[x][y+1]!='@'&&a[x][y+1]!='&'&&a[x][y+1]!='$'&&a[x][y+1]!='0'&&a[x][y+1]!='1'){
                    a[x][y]=' ';
                    y++;
                    a[x][y]='*';
                }
            }
            else if(b=='w'){
                if(a[x-1][y]!='#'&&a[x-1][y]!='@'&&a[x-1][y]!='&'&&a[x-1][y]!='$'&&a[x-1][y]!='0'&&a[x-1][y]!='1'){
                    a[x][y]=' ';
                    x--;
                    a[x][y]='*';
                }
            }
            else if(b=='j'){ 
                if(a[ex][ey-1]!='#'&&a[ex][ey-1]!='@'&&a[ex][ey-1]!='&'&&a[ex][ey-1]!='*'&&a[ex][ey-1]!='0'&&a[ex][ey-1]!='1'){
                    a[ex][ey]=' ';
                    ey--;
                    a[ex][ey]='$'; 
                }
            }
            else if(b=='k'){
                if(a[ex+1][ey]!='#'&&a[ex+1][ey]!='@'&&a[ex+1][ey]!='&'&&a[ex+1][ey]!='*'&&a[ex+1][ey]!='0'&&a[ex+1][ey]!='1'){
                    a[ex][ey]=' ';
                    ex++;
                    a[ex][ey]='$';
                }
            }
            else if(b=='l'){
                if(a[ex][ey+1]!='#'&&a[ex][ey+1]!='@'&&a[ex][ey+1]!='&'&&a[ex][ey+1]!='*'&&a[ex][ey+1]!='0'&&a[ex][ey+1]!='1'){
                    a[ex][ey]=' ';
                    ey++;
                    a[ex][ey]='$';
                }
            }
            else if(b=='i'){
                if(a[ex-1][ey]!='#'&&a[ex-1][ey]!='@'&&a[ex-1][ey]!='&'&&a[ex-1][ey]!='*'&&a[ex-1][ey]!='0'&&a[ex-1][ey]!='1'){
                    a[ex][ey]=' ';
                    ex--;
                    a[ex][ey]='$';
                }
            }
            else if(b=='x'){
                if(a[x-1][y]=='$'||a[x][y-1]=='$'||a[x][y+1]=='$'){
                    bloodb--;
                    a[23]=a2[3-bloodb];
                    if(bloodb==0){
                        a[ex][ey]=' ';
                        ex=8;
                        ey=53;
                        a[ex][ey]='$';
                        bloodb=3;
                        a[23]=a2[0];
                    }
                }
                else if(a[x-1][y]=='1'||a[x][y-1]=='1'||a[x][y+1]=='1'){
                    blood1--;
                    a[25]=b2[10-blood1];
                    if(blood1==0){
                        system("cls");
                        cout<<"1号玩家抢占了2号玩家基地,1号玩家胜利!";
                        return 0;
                    }
                }
            }
            else if(b=='n'){
                if(a[ex-1][ey]=='*'||a[ex][ey-1]=='*'||a[ex][ey+1]=='*'){
                    blooda--;
                    a[22]=a1[3-blooda];
                    if(blooda==0){
                        a[x][y]=' ';
                        x=8;
                        y=6;
                        a[x][y]='*';
                        blooda=3;
                        a[22]=a1[0];
                    }
                }
                else if(a[ex-1][ey]=='0'||a[ex][ey-1]=='0'||a[ex][ey+1]=='0'){
                    blood0--;
                    a[24]=b1[10-blood0];
                    if(blood0==0){
                        system("cls");
                        cout<<"2号玩家抢占了1号玩家基地,2号玩家胜利!";
                        return 0;
                    }
                }
            }
            if(b=='o'){//退出 
                return 0;
            }
            system("cls");
            for(int i=0;i<=25;i++){
                cout<<a[i]<<endl;
            }
        }
    }
    return 0;
}

 

0
被禁言 汪声旭
汪声旭
高级守护
高级守护
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
int toint(double a){return ((int)(a*10+5))/10;}
int rand(int a){return rand()%a;}
void SlowDisplay(int x,char *p){while(1){if(*p!=0) printf("%c",*p++);else break;Sleep(x);}}
void Setpos(double x,double y){COORD pos;pos.X=toint(y*2),pos.Y=toint(x);SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
void Color(int a){
    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_RED|FOREGROUND_GREEN);
    if(a==-3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);

    if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED);
    if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED);
    if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN);
    if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);

    if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED|BACKGROUND_BLUE);
    if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_BLUE);
}   
struct node{int what;double x,y,vx,vy,r,m;bool life;int gun,master=-1;}Sun[1000001];
int b,T,m[41][41],n[41][41],m2[41][41],n2[41][41],dif[11],Speed=10,Ba,Hotguntime,Hotguntimemax=10,Blood,Score;
double Speedmax,Speedless,Speedmore=1,Balljump=-0.7,Fire=0.08;
void Push(int a,int b){
    if(Sun[a].master==b||Sun[b].master==a) return;
    if(Sun[a].life==0||Sun[b].life==0) return;
    if(Sun[a].what==3||Sun[b].what==3) return;
    if(Sun[a].what==4||Sun[b].what==4) return;
    double Ax=Sun[a].x-Sun[b].x,Ay=Sun[a].y-Sun[b].y,Dis=sqrt(Ax*Ax+Ay*Ay)*1.0,fDis=sqrt((Sun[a].vx-Sun[b].vx)*(Sun[a].vx-Sun[b].vx)+(Sun[a].vy-Sun[b].vy)*(Sun[a].vy-Sun[b].vy));
    if(Dis==0) return;if(abs(Ay)<=0.0001) Ay=0.0001;
    if(Sun[a].what==2||Sun[b].what==2) int c;
    else if(Dis<=Sun[a].r+Sun[b].r+fDis){
        double Vx=(Sun[a].vx+Sun[b].vx)/2.0,Vy=(Sun[a].vy+Sun[b].vy)/2.0,aX=(Sun[a].x+Sun[b].x+Sun[a].vx+Sun[b].vx)/2.0,aY=(Sun[a].y+Sun[b].y+Sun[a].vy+Sun[b].vy)/2.0;
        Sun[a].vx=Sun[b].vx=Vx,Sun[a].vy=Sun[b].vy=Vy;Sun[a].x=aX-(Ax/Dis)/2.0,Sun[b].x=aX+(Ax/Dis)/2.0;Sun[a].y=aY-(Ay/Dis)/2.0,Sun[b].y=aY+(Ay/Dis)/2.0;
        return;
    }
    double ac=Sun[a].m*Sun[b].m/(Dis*Dis)*1.0,afx=0,afy=0,d=abs(Ax/Ay*1.0);
    afy=sqrt(ac/(1+d*d))*1.0,afx=sqrt(ac/(1+d*d))*d*1.0;
    if(Ax>0) afx*=-1;if(Ay>0) afy*=-1;
#define A Sun[a].vx+=afx/Sun[a].m*Speedless,Sun[a].vx=max(-Speedmax,min(Speedmax,Sun[a].vx)),Sun[a].vy+=afy/Sun[a].m*Speedless,Sun[a].vy=max(-Speedmax,min(Speedmax,Sun[a].vy))
#define B Sun[b].vx-=afx/Sun[b].m*Speedless,Sun[b].vx=max(-Speedmax,min(Speedmax,Sun[b].vx)),Sun[b].vy-=afy/Sun[b].m*Speedless,Sun[b].vy=max(-Speedmax,min(Speedmax,Sun[b].vy))
    Speedmax=0.1,Speedless=0.01; 
    if(Sun[a].what==2&&Sun[b].what==2) Speedmax=3.0;
    if(Sun[a].what==0) {Speedless=0.008;Speedmax=1.0; A;}
    else if(Sun[a].what==1) {A; if(Sun[b].what==1) B;}
    else if(Sun[a].what==2) {Speedless=0.8;B;if(Sun[b].what==2) A;}
    else {A;B;}
}
int Painting[41][41]={{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,9,9,9,9,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,1,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0},{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,1,0,1,0,0,0,0,0,0},{0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0},{0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,0,1,0,0,0,0,0},{0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,2,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,3,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,4,9,9,9,9,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},};
void Paint(int a);
void Move(int a){
    Blood=10000000;
    memset(m,0,sizeof(m));
    memset(m2,0,sizeof(m2));
    #define ix toint(Sun[i].x/1.0)
    #define iy toint(Sun[i].y/1.0)
    #define jx toint(Sun[j].x/1.0)
    #define jy toint(Sun[j].y/1.0)
    if(Sun[0].life==1){
    Sun[0].x+=Sun[0].vx/Speedmore;Sun[0].y+=Sun[0].vy/Speedmore;
    if(Sun[0].x>40) Sun[0].x=40,Sun[0].vx=0;if(Sun[0].x<0) Sun[0].x=0,Sun[0].vx=0;if(Sun[0].y>40) Sun[0].y=40,Sun[0].vy=0;if(Sun[0].y<0) Sun[0].y=0,Sun[0].vy=0;}

    for(int i=0;i<=b;i++) for(int j=i+1;j<=b;j++) Push(i,j);
    for(int i=0;i<=b;i++) for(int j=0;j<=b;j++)
    {
        if(i==j||Sun[i].life==0||Sun[j].life==0) continue;
    if(Sun[i].what==4&&(Sun[j].what>=100&&Sun[j].what<200)) {if(abs(ix-jx)<1&&abs(iy-jy)<1) Ba--,Sun[i].life=Sun[j].life=0,Score+=10;}

        if(Sun[i].what==203&&Sun[i].master!=j&&Sun[j].what<200) if(abs(ix-jx)<2&&abs(iy-jy)<2) Sun[j].vx-=Sun[i].vx/10.0,Sun[j].vy-=Sun[i].vy/10.0,Sun[i].life=0;
        if(Sun[i].what==204&&Sun[i].master!=j&&Sun[j].what<200) if(abs(ix-jx)<2&&abs(iy-jy)<2) Sun[j].vx+=Sun[i].vx/10.0,Sun[j].vy+=Sun[i].vy/10.0,Sun[i].life=0;

    }
    int i=0;
    if(m[ix][iy]>0&&m[ix][iy]<100)
    {
        if(m[ix][iy]<=1) Blood-=1;
        else if(m[ix][iy]<=4) Blood-=2;
        else if(m[ix][iy]<=10) Blood-=3;
        else if(m[ix][iy]>10&&m[ix][iy]<100) Blood-=4;
    }
    for(int i=1;i<=b;i++){
        if(Sun[i].life==0) continue;
        Sun[i].x+=Sun[i].vx/Speedmore;Sun[i].y+=Sun[i].vy/Speedmore;
        Balljump=-0.7;
        if(Sun[i].what==3) Balljump=-1;
        if(Sun[i].what==4) Balljump=-1;
        if(Sun[i].x>40) Sun[i].x=40,Sun[i].vx*=Balljump;
        if(Sun[i].x<0) Sun[i].x=0,Sun[i].vx*=Balljump;if(Sun[i].y>40) Sun[i].y=40,Sun[i].vy*=Balljump;if(Sun[i].y<0) Sun[i].y=0,Sun[i].vy*=Balljump;
        if(Sun[i].what==1) {m[ix][iy]+=2;int R;R=rand(3);if(R==0&&ix<40) m[ix+1][iy]++;R=rand(3);if(R==0&&ix>0) m[ix-1][iy]++;R=rand(3);if(R==0&&iy<40) m[ix][iy+1]++;R=rand(3);if(R==0&&iy>0) m[ix][iy-1]++;}
        if(Sun[i].what==2) {m[ix][iy]+=2;if(ix<40) m[ix+1][iy]+=10;if(ix>0) m[ix-1][iy]+=10;if(iy<40) m[ix][iy+1]+=10;if(iy>0) m[ix][iy-1]+=10;if(ix<40&&iy<40) m[ix+1][iy+1]+=4;if(ix<40&&iy>0) m[ix+1][iy-1]+=4;if(ix>0&&iy<40) m[ix-1][iy+1]+=4;if(ix>0&&iy>0) m[ix-1][iy-1]+=4;m[ix][iy]=10086;} 
        if(Sun[i].what==3) {if(abs(ix-Sun[0].x)<1&&abs(iy-Sun[0].y)<1) Ba--,Sun[i].life=0;else m2[ix][iy]=2;}
        if(Sun[i].what==4) {m2[ix][iy]=2;}
        if(Sun[i].what>=100&&Sun[i].what<300)
        {
            if(Sun[i].x==0||Sun[i].y==0||Sun[i].x==40||Sun[i].y==40||(abs(Sun[i].vx)<=0.5&&abs(Sun[i].vy)<=0.5)) Sun[i].life=0;
            if(Sun[i].what==203||Sun[i].what==204) {m[ix][iy]=Sun[i].what;if(ix<40) m[ix+1][iy]=Sun[i].what;if(ix>0) m[ix-1][iy]=Sun[i].what;if(iy<40) m[ix][iy+1]=Sun[i].what;if(iy>0) m[ix][iy-1]=Sun[i].what;}
            else m2[ix][iy]=Sun[i].what;
        } 
    }
    if(Sun[0].life==1) m2[toint(Sun[0].x/1.0)][toint(Sun[0].y/1.0)]=1;
    Paint(a);
}
void Paint(int a){
for(int i=0;i<=40;i++) for(int j=0;j<=40;j++){
    if(a==0&&Painting[i][j]!=0) continue;

    if(m2[i][j]!=n2[i][j]){n2[i][j]=m2[i][j];n[i][j]=0;Setpos(i,j);
    if(m2[i][j]==0) Color(0),cout<<"  ";
    else if(m2[i][j]==1) Color(-1),cout<<"●";
    else if(m2[i][j]==2) Color(-3),cout<<"◎";
    else if(m2[i][j]==101) Color(-1),cout<<"☉";
    else if(m2[i][j]==102) Color(3),cout<<"  ";
    continue;}
    if(m[i][j]!=n[i][j]){n[i][j]=m[i][j];n2[i][j]=0;Setpos(i,j);
    if(m[i][j]>=10086) Color(4),cout<<"●";
    else if(m[i][j]==203) Color(5),cout<<"  ";
    else if(m[i][j]==204) Color(6),cout<<"  ";
    else if(m[i][j]==0) Color(0),cout<<"  ";else if(m[i][j]<=1) Color(1),cout<<"  ";else if(m[i][j]<=4) Color(2),cout<<"  ";else if(m[i][j]<=10) Color(3),cout<<"  ";else if(m[i][j]>10&&m[i][j]<100) Color(4),cout<<"  ";
    else Color(0),cout<<"?!";}Color(0);
    }
}
void RandStart(int a) {for(int i=1;i<=a;i++) {b++;Sun[b].x=rand(41),Sun[b].y=rand(41);Sun[b].vx=(rand(41)-20)/10.0,Sun[b].vy=(rand(41)-20)/10.0,Sun[b].m=1,Sun[b].r=1,Sun[b].life=1,Sun[b].what=1;}}
void CornerStart(int a) {for(int i=1;i<=a;i++) {b++;int k=rand(4);if(k==0||k==2) Sun[b].x=rand(41);else Sun[b].y=rand(41);if(k==0) Sun[b].y=0;if(k==1) Sun[b].x=0;if(k==2) Sun[b].y=40;if(k==3) Sun[b].x=40;Sun[b].vx=(rand(41)-20)/10.0,Sun[b].vy=(rand(41)-20)/10.0,Sun[b].m=1,Sun[b].r=1,Sun[b].life=1,Sun[b].what=1;}}
void SunStart(int x,int y,int r,int vx,int vy) {
b++;Sun[b].x=x,Sun[b].y=y;Sun[b].vx=vx,Sun[b].vy=vy,Sun[b].m=1000,Sun[b].r=1,Sun[b].life=1,Sun[b].what=2;
for(int i=x-r;i<=x+r;i++) for(int j=y-r;j<=y+r;j++){b++;Sun[b].x=i,Sun[b].y=j;Sun[b].vx=(rand(41)-20)/100.0+vx,Sun[b].vy=(rand(41)-20)/100.0+vy,Sun[b].m=1,Sun[b].r=1,Sun[b].life=1,Sun[b].what=1;}
for(float i=(int)(x-r/2)-0.5;i<=(int)(x+r/2)+0.5;i++) for(float j=(int)(y-r/2)-0.5;j<=(int)(y+r/2)+0.5;j++){b++;Sun[b].x=i,Sun[b].y=j;Sun[b].vx=(rand(41)-20)/100.0+vx,Sun[b].vy=(rand(41)-20)/100.0+vy,Sun[b].m=1,Sun[b].r=1,Sun[b].life=1,Sun[b].what=1;}
}
void Shoot(int a,bool q)
{
    double Sunavx=Sun[a].vx,Sunavy=Sun[a].vy;
    if(Sun[a].vx==0&&Sun[a].vy==0) Sunavx=-1;if(Sun[a].vy==0) Sunavy=0.001;
    if(Sun[a].gun>=1&&Sun[a].gun<=4)
    {
        b++;Sun[b].x=Sun[a].x,Sun[b].y=Sun[a].y;double ac;
        if(Sun[a].gun==1) ac=3.0; 
        if(Sun[a].gun>=2&&Sun[a].gun<=4) ac=7.0;
        double d=abs(Sunavx/Sunavy*1.0);Sun[b].vy=sqrt(ac/(1+d*d))*1.0,Sun[b].vx=sqrt(ac/(1+d*d))*d*1.0;
        if(Sunavx>0) Sun[b].vx*=-1;if(Sunavy>0) Sun[b].vy*=-1;if(q==1) Sun[b].vx*=-1,Sun[b].vy*=-1;Sun[b].life=1;
        Sun[b].master=a;
        int bb=b;
        if(Sun[a].gun==1||Sun[a].gun==2) Sun[b].what=100+Sun[a].gun,Sun[b].m=1;
        if(Sun[a].gun==3||Sun[a].gun==4) Sun[b].what=200+Sun[a].gun,Sun[b].m=1;
        if(Sun[a].gun>=2&&Sun[a].gun<=4){
    double kx=Sun[bb].x,ky=Sun[bb].y;
    for(int j=1;j<=7;j++)
    {
    kx-=Sun[bb].vx/3.5,ky-=Sun[bb].vy/3.5;
    if(kx<0||ky<0||kx>40||ky>40) continue;
    b++,Sun[b].x=kx,Sun[b].y=ky,Sun[b].vx=Sun[bb].vx,Sun[b].vy=Sun[bb].vy,Sun[b].what=Sun[bb].what,Sun[b].master=a,Sun[b].life=1;
    }
        }
    }
}
void Start(){
    for(int i=0;i<=40;i++) for(int j=0;j<=40;j++){if(Painting[i][j]==1) Setpos(i,j),Color(-2),cout<<"■";if(Painting[i][j]==2) Setpos(i,j),Color(-2),cout<<"作者:蒟蒻一枚";if(Painting[i][j]==3) Setpos(i,j),Color(-2),cout<<"按 y 开始游戏!";if(Painting[i][j]==4) Setpos(i,j),Color(-2),cout<<"不要搞错成拼音输入法!";if(Painting[i][j]==5) Setpos(i,j),Color(-2),cout<<"Three-Body STAR WARs!";}
    for(int i=1;i<=3;i++) SunStart(rand(31)+5,rand(31)+5,5,(rand(101)-50)/10.0,(rand(101)-50)/10.0);
    T=0;
    while(1){
        T++;
        if(T%50==0) CornerStart(1);
        if(kbhit()){char g=_getch();if(g=='y') break; }
        Move(0);
        Sleep(Speed);
    }
    Color(0);system("cls");
    Setpos(10,10);SlowDisplay(30,"你想要教程吗?(y/n)");
    char g=_getch();if(g!='y') return;Setpos(10,10);SlowDisplay(30,"那我们开始。。。   ");Sleep(500);
    system("cls");
    Setpos(30,10);system("cls");

    memset(Sun,0,sizeof(Sun));memset(m,0,sizeof(m));memset(m2,0,sizeof(m2));
    Sun[0].x=Sun[0].y=20;Sun[0].life=1;Sun[0].m=10;
    T=0;
    int step=0;
    while(1){
        T++;
        if(T==2)
        {
        Setpos(10,10),SlowDisplay(30,"这是你的飞船,你可以用↑↓←→键来操纵它。");Sleep(500);
        Setpos(12,10),SlowDisplay(30,"在宇宙航行没有阻力,也就是说你的惯**会主导一切。");Sleep(500);
        Setpos(14,10),SlowDisplay(30,"当你撞到边界时,你的速度会减为零。");Sleep(1000); 
        Setpos(16,10),SlowDisplay(30,"试试看。");
        }
        if(T==200)
        {
        Setpos(10,10),SlowDisplay(30,"在宇宙航行时有两个小技巧:                ");
        Setpos(12,10),SlowDisplay(30,"1、不要太快。                                   ");
        Setpos(14,10),SlowDisplay(30,"2、有时转向比调头更有用。         ");Sleep(1000);
        Setpos(16,10),SlowDisplay(30,"接下来我们稍稍提高点难度!请到达所有靶位点!");Sleep(500);
        b++;Sun[b].x=rand(40),Sun[b].y=rand(40);Sun[b].vx=(rand(101)-50)/30.0,Sun[b].vy=(rand(101)-50)/30.0,Sun[b].life=1,Sun[b].what=3;Ba++;
        Move(1);Sleep(1000); 
        }
        if(Ba>0) Setpos(1,1),cout<<"剩余靶位点:"<<Ba<<' ';
        if(step>=1) Setpos(5,1),cout<<"Cooling time: "<<Hotguntime<<"    ";
        if(T>200&&Ba==0&&step==0) T=201,step=1,Setpos(1,1),cout<<"           ";
        if(T>300&&Ba==0&&step==1) T=201,step=2,Setpos(1,1),cout<<"           ";
        if(T==202&&step==1)
        {
        Setpos(10,10),SlowDisplay(30,"做的好!看来是时候给你装备初始武器了。");
        Setpos(12,10),SlowDisplay(50,"。。。 星际电磁轨道炮 已装备。");
        Setpos(14,10),SlowDisplay(30,"按下w/s发射子弹!                         ");
        Sun[0].gun=1;Hotguntime=0;
        }
        if(T==300&&step==1)
        {
        Setpos(16,10),SlowDisplay(30,"来吧!请击毁所有靶位点!");Sleep(500);
        b++;Sun[b].x=rand(40),Sun[b].y=rand(40);Sun[b].vx=(rand(101)-50)/30.0,Sun[b].vy=(rand(101)-50)/30.0,Sun[b].life=1,Sun[b].what=4;Ba++;
        Move(1);Sleep(1000); Ba=1;
        }
        if(T==202&&step==2)
        {
        Setpos(10,10),SlowDisplay(30,"太阳什么的你也看到过了。               ");
        Setpos(12,10),SlowDisplay(30,"其旁缠绕着的火会扣你的血。      ");
        Setpos(14,10),SlowDisplay(30,"打靶位点可以积10分,发射子弹-1分,分数达到20通关,简单吧!");Sleep(1000); 
        Setpos(16,10),SlowDisplay(60,"让 我 们  开 始  吧!!!");Sleep(1000); 
        system("cls");return; 
        }
        double v=sqrt(Sun[0].vx*Sun[0].vx+Sun[0].vy*Sun[0].vy);
        if(GetAsyncKeyState(VK_UP)&0x8000) {if(Sun[0].vx>=0) Sun[0].vx-=2*Fire;else if(v<4) Sun[0].vx-=Fire;}
        else if(GetAsyncKeyState(VK_DOWN)&0x8000) {if(Sun[0].vx<=0) Sun[0].vx+=2*Fire;else if(v<4) Sun[0].vx+=Fire;}
        if(GetAsyncKeyState(VK_LEFT)&0x8000) {if(Sun[0].vy>=0) Sun[0].vy-=2*Fire;else if(v<4) Sun[0].vy-=Fire;}
        else if(GetAsyncKeyState(VK_RIGHT)&0x8000) {if(Sun[0].vy<=0) Sun[0].vy+=2*Fire;else if(v<4) Sun[0].vy+=Fire;}

        if(Hotguntime>0) Hotguntime--;
        if(kbhit()){
        char g=_getch();
        if(Hotguntime==0&&g=='s')
        {
            if(abs(Sun[0].vx)>=0.01) Sun[0].vx*=0.7;
            if(abs(Sun[0].vy)>=0.01) Sun[0].vy*=0.7;
            Shoot(0,0);
            Hotguntime=Hotguntimemax;
        }
        if(Hotguntime==0&&g=='w')
        {
            if(abs(Sun[0].vx)<=2) Sun[0].vx*=1.2;
            if(abs(Sun[0].vy)<=2) Sun[0].vy*=1.2;
            Shoot(0,1);
            Hotguntime=Hotguntimemax;
        }
        }
        Move(1);
        Sleep(Speed);
    }
}
int main()
{
    system("mode con cols=82 lines=43");
    CONSOLE_CURSOR_INFO cursor_info={1,0};
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
    srand((unsigned)time(NULL));
    Y:
    Start();
    memset(Sun,0,sizeof(Sun));memset(m,0,sizeof(m));memset(m2,0,sizeof(m2));
    YY:system("cls");
    Setpos(10,10),SlowDisplay(30,"选难度吧,几个太阳?(0~10,回车确定)");
    int i=10;while(dif[i]!=1&&i>=0){i--;}
    Setpos(12,10);
    if(i==-1) printf("推荐难度:0个太阳。");
    else if(i<10) printf("加油,推荐难度:%d个太阳。",i+1);
    else if(i==10) printf("你通关了!随便选吧!",i);

    Setpos(15,10);
    int p;cin>>p;
    if(p<0||p>10) {SlowDisplay(150,"输入错误!"),Sleep(1000);goto YY;}
    for(int i=1;i<=p;i++) SunStart(rand(31)+5,rand(31)+5,5,(rand(101)-50)/10.0,(rand(101)-50)/10.0);
    Sun[0].x=Sun[0].y=5;Sun[0].vx=0.1;Sun[0].life=1;Sun[0].m=10;
    T=0;
    Sun[0].gun=1;
    Blood=100;
    Score=0;Ba=0;
    for(int i=1;i<=10;i++) {b++;Sun[b].x=rand(40),Sun[b].y=rand(40);Sun[b].vx=(rand(101)-50)/30.0,Sun[b].vy=(rand(101)-50)/30.0,Sun[b].life=1,Sun[b].what=4;Ba++;}
    while(Blood>0&&Score<100){
        Setpos(1,1),cout<<"Blood: "<<Blood<<"    ";
        Setpos(3,1),cout<<"Score: "<<Score<<"    ";
        Setpos(5,1),cout<<"Cooling time: "<<Hotguntime<<"    ";
        T++;
        if(T==1) Sleep(1000);
        if(T%50==0) CornerStart(1);
        if(T%30==0&&Ba<5) {b++;Sun[b].x=rand(40),Sun[b].y=rand(40);Sun[b].vx=(rand(101)-50)/30.0,Sun[b].vy=(rand(101)-50)/30.0,Sun[b].life=1,Sun[b].what=4;Ba++;}
        if(T%40==0&&Blood<100) Blood++;

        double v=sqrt(Sun[0].vx*Sun[0].vx+Sun[0].vy*Sun[0].vy);
        if(GetAsyncKeyState(VK_UP)&0x8000) {if(Sun[0].vx>=0) Sun[0].vx-=2*Fire;else if(v<4) Sun[0].vx-=Fire;}
        else if(GetAsyncKeyState(VK_DOWN)&0x8000) {if(Sun[0].vx<=0) Sun[0].vx+=2*Fire;else if(v<4) Sun[0].vx+=Fire;}
        if(GetAsyncKeyState(VK_LEFT)&0x8000) {if(Sun[0].vy>=0) Sun[0].vy-=2*Fire;else if(v<4) Sun[0].vy-=Fire;}
        else if(GetAsyncKeyState(VK_RIGHT)&0x8000) {if(Sun[0].vy<=0) Sun[0].vy+=2*Fire;else if(v<4) Sun[0].vy+=Fire;}

        if(Hotguntime>0) Hotguntime--;
        if(kbhit()){
        char g=_getch();
        if(Hotguntime==0&&g=='s')
        {
            if(abs(Sun[0].vx)>=0.01) Sun[0].vx*=0.7;
            if(abs(Sun[0].vy)>=0.01) Sun[0].vy*=0.7;
            Shoot(0,0);
            Score=max(Score-1,0);
            Hotguntime=Hotguntimemax;
        }
        if(Hotguntime==0&&g=='w')
        {
            if(abs(Sun[0].vx)<=2) Sun[0].vx*=1.2;
            if(abs(Sun[0].vy)<=2) Sun[0].vy*=1.2;
            Shoot(0,1);
            Score=max(Score-1,0);
            Hotguntime=Hotguntimemax;
        }
        }Move(1);
        Sleep(Speed);
    }
    system("cls");
    if(Score<20) Setpos(10,10),SlowDisplay(150,"Sorry,你**了。"); 
    else Setpos(10,10),SlowDisplay(10,"赢了!快去**下一个难度吧!"),dif[p]=1; 
    Sleep(1000); 
    goto Y;
    return 0;
}

 

我要回答