C语言程序设计项目之大富翁

1 简介

本篇文章主要讲述如何用C语言来实现大富翁游戏功能,估计代码量1500+。
读者可以在理解的情况下来增加或删减一些功能,增加游戏的趣味性和个人的成就感。
程序所有输入都是以字符串来进行读,并转化成int来进行相应操作,容错性高。

2 main

主函数,包含游戏开始和目录,调用一些功能函数等。

#include "commands.h"
//输入2157直接结束

int main ()
{
    srand(time(NULL));
    int loop=0;
    frame_col=14;
    screen_size(146,47);
    HideCursor();
    while(++loop<1000)
    {
        clear_screen();
        frame(frame_col);
        title();
        menu();
        SetPos(37,97);
        int num=input();
        switch(num)
        {
        case 1:
        {
            clear_game();
        }
        break;
        case 2:
        {
            double_game();
        }
        break;
        case 3:
        {
            more_content();
        }
        break;
        case 4:
        {
            help();
        }
        break;
        case 5:
        {
            frame_col=change_color(frame_col);
        }
        break;
        case 6:
        {
            quit();
            return 0;
        }
        break;
        default :
        {
            SetPos(39,41);
            color(10);
            printf("            Please follow the rules!!!");
            getchar();
        }
        break;
        }
    }
    return 0;
}

3 windows.c

利用windows库函数,来实现的一切功能,和一切界面函数

#include "commands.h"
//视图类

void screen_size(int a,int b)  // 屏幕大小(a列b行)
{
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD size = {a, b};
    SetConsoleScreenBufferSize(hOut,size);
    SMALL_RECT rc = {1,1, a-2, b-2};
    SetConsoleWindowInfo(hOut,1,&rc);
}

void color(int x)
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);
}

void HideCursor()
{
    CONSOLE_CURSOR_INFO cursor;
    cursor.bVisible = FALSE;
    cursor.dwSize = sizeof(cursor);
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorInfo(handle, &cursor);
}

void RevealCursor()
{
    CONSOLE_CURSOR_INFO cursor;
    cursor.bVisible = TRUE;
    cursor.dwSize = sizeof(cursor);
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorInfo(handle, &cursor);
}

void SetPos(int y, int x)
{
    COORD point = { x, y };
    HANDLE HOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(HOutput, point);
}

void frame(int x)
{
    color(x);
    SetPos(0,0);
    int i;
    printf("************************************************************************************************************************************************\n");
    printf("************************************************************************************************************************************************\n");
    for(i=2; i<=41; i++)
    {
        SetPos(i,0);
        printf("**");
        SetPos(i,142);
        printf("**");
    }
    SetPos(42,0);
    printf("************************************************************************************************************************************************\n");
    printf("************************************************************************************************************************************************\n");
    color(15);

}

void clear_screen()
{
    color(15);
    int i,j;
    for(i=2; i<=41; i++)
    {
        SetPos(i,3);
        for(j=1; j<=139; j++)
            putchar(' ');
    }
}

void title()
{
    color(11);
    int i;
    for(i=4; i<=14; i++)
    {
        SetPos(i,25);
        switch(i)
        {
        case 4:
            printf("*           *     * * * *     *          *     * * * *     * * * * *   *           *         *");
            break;
        case 5:
            printf("* *       * *    *       *    * *        *    *       *    *        *  *            *       * ");
            break;
        case 6:
            printf("*  *     *  *   *         *   *  *       *   *         *   *        *  *             *     *  ");
            break;
        case 7:
            printf("*   *   *   *  *           *  *  *       *  *           *  *        *  *              *   *   ");
            break;
        case 8:
            printf("*   *   *   *  *           *  *   *      *  *           *  *        *  *               * *    ");
            break;
        case 9:
            printf("*    * *    *  *           *  *     *    *  *           *  * * * * *   *                *     ");
            break;
        case 10:
            printf("*     *     *  *           *  *     *    *  *           *  *           *                *     ");
            break;
        case 11:
            printf("*     *     *  *           *  *       *  *  *           *  *           *                *     ");
            break;
        case 12:
            printf("*           *   *         *   *       *  *   *         *   *           *                *     ");
            break;
        case 13:
            printf("*           *    *       *    *        * *    *       *    *           *                *     ");
            break;
        case 14:
            printf("*           *     * * * *     *          *     * * * *     *           * * * * * *      *     ");
            break;
        }
    }
    color(15);
}

void menu()
{
    color(9);
    SetPos(19,41);
    int i,j=20;
    printf("            1->  Refresh interface                             ");
    for(i=1; i<=2; i++,j++)
    {
        SetPos(j,41);
        printf("                                                               ");
    }
    j++;
    SetPos(22,41);
    printf("            2->  Double game (player  vs  player)              ");
    for(i=1; i<=2; i++,j++)
    {
        SetPos(j,41);
        printf("                                                               ");
    }
    j++;
    SetPos(25,41);
    printf("            3->  More content                                  ");
    for(i=1; i<=2; i++,j++)
    {
        SetPos(j,41);
        printf("                                                               ");
    }
    j++;
    SetPos(28,41);
    printf("            4->  Help                                          ");
    for(i=1; i<=2; i++,j++)
    {
        SetPos(j,41);
        printf("                                                               ");
    }
    j++;
    SetPos(31,41);
    printf("            5->  Switch border color                           ");
    for(i=1; i<=2; i++,j++)
    {
        SetPos(j,41);
        printf("                                                               ");
    }
    j++;
    SetPos(34,41);
    printf("            6->  Exit the game                                 ");
    for(i=1; i<=3; i++,j++)
    {
        SetPos(j,41);
        printf("                                                               ");
    }
    j++;
    SetPos(37,41);
    color(12);
    printf("            Please enter the corresponding number [ ->     <- ]"              );
    color(15);
}

void mid_screen()  //中央屏幕
{
    color(9);
    SetPos(19,41);
    putchar('+');
    int i,j;
    for(i=1; i<=58; i++) putchar('-');
    putchar('+');
    for(i=20; i<=36; i++)
    {
        SetPos(i,41);
        putchar('|');
        for(j=1; j<=58; j++) putchar(' ');
        SetPos(i,100);
        putchar('|');
    }
    SetPos(37,41);
    putchar('+');
    for(i=1; i<=58; i++) putchar('-');
    putchar('+');
    printf("     ");  //清除多余内容
    color(15);

}

void status_bar()
{
    color(11);
    SetPos(4,98);
    printf("+===================================+");
    int i;
    for(i=5; i<=38; i++)
    {
        SetPos(i,98);
        putchar('|');
        SetPos(i,134);
        putchar('|');
        if(i==8||i==12||i==16||i==30)
        {
            SetPos(i,98);
            printf("+===================================+");
        }

    }
    SetPos(39,98);
    printf("+===================================+");
    color(15);

}

void clear_midstatus()
{
    int i;
    for(i=17; i<=29; i++)
    {
        SetPos(i,99);
        printf("                                   ");
    }
}

void help()
{
    SetPos(0,0);
    frame(frame_col);
    clear_screen();
    title();
    color(10);
    SetPos(16,25);
    printf("欢迎来到Monopoly!");
    color(15);
    SetPos(18,25);
    printf("1->刷新界面。");
    SetPos(19,25);
    printf("2->双人游戏(玩家对战): 你与你的朋友一起游玩,享受乐趣!");
    SetPos(20,25);
    printf("3->更多内容: 将会持续更新,具体内容请待后续。");
    SetPos(21,25);
    printf("4->帮助: 帮助你了解游戏内容。");
    SetPos(22,25);
    printf("5->切换边框颜色: 自定义边框色彩,共有15种选择");
    SetPos(23,25);
    printf("6->退出游戏: 离开游戏,期待你的下次游玩。");

    color(10);
    SetPos(25,25);
    printf("玩法介绍: ");
    color(15);
    SetPos(27,25);
    printf("开始游戏时每个人都拥有$30000,你的任务就是使对方破产,最终游戏只剩你一人即可获胜!");
    SetPos(28,25);
    printf("初始一枚骰子,移动需要进行摇骰子,骰子的点数就是向前走的步数,当拥有交通工具时摇骰子的数量可控,最多3枚。");
    SetPos(29,25);
    printf("当你移动到不一样的格子时有不同的效果。");
    SetPos(30,25);
    color(12);
    printf("报亭");
    color(15);
    printf(":会触发随机事件,增加游戏乐趣。            ");
    color(12);
    printf("乐透");
    color(15);
    printf(":可以选择买彩票,中奖金额随游戏时间越久越大。");
    SetPos(31,25);
    color(12);
    printf("地产");
    color(15);
    printf(":到达空地时可以选择是否购买,购买后对方到达此处需要交租金,租金随地产等级变化,最高五级,");
    SetPos(32,25);
    color(12);
    printf("大地产");
    color(15);
    printf(":购买此地可以选择盖造大型建筑,会有不同效果。         ");
    color(13);
    printf("商业中心");
    color(15);
    printf(":对方到达通过投骰子来决定消费金额。");
    SetPos(33,32);
    color(13);
    printf("石油公司");
    color(15);
    printf(":当你到达时可以通过投骰子来决定收益多少。    ");
    color(13);
    printf("BR酒店");
    color(15);
    printf(":对方到达后需要交付住宿费,按酒店等级住2~5天。");
    SetPos(34,25);
    color(12);
    printf("医院");
    color(15);
    printf(":受伤后住进医院,按照情况来决定住院时间。  监狱:被捕入狱,入狱时间视情况而定。");
    SetPos(35,25);
    color(12);
    printf("黄金城");
    color(15);
    printf(":富裕城池,到达此处获得随回合数而变化的金钱。      ");
    color(12);
    printf("贫穷窟");
    color(15);
    printf(":可怜之地,到达此处视回合数来捐献金钱,不会为负。");
    SetPos(36,25);
    color(12);
    printf("银行");
    color(15);
    printf(":到达此处可以选择存款或者取款,存在银行的钱会在特定回合获得利息。");
    SetPos(37,25);
    color(12);
    printf("许愿池");
    color(15);
    printf(":下次投骰子必定是自己想的数字。");

    SetPos(39,25);
    color(10);
    printf("按任意键返回主菜单。");


    color(11);
    SetPos(41,41);
    printf("Author: Ryawq                                        v1.5");

    getchar();

    color(15);
}

void locat_help()
{
    SetPos(31,101);
    color(176);
    printf("  ");
    color(11);
    printf("  报亭        ");

    color(224);
    printf("  ");
    color(11);
    printf("  银行");

    SetPos(33,101);
    color(208);
    printf("  ");
    color(11);
    printf("  乐透        ");

    color(112);
    printf("  ");
    color(11);
    printf("  贫民窟");

    SetPos(35,101);
    color(96);
    printf("  ");
    color(11);
    printf("  黄金城      ");

    color(64);
    printf("  ");
    color(11);
    printf("  医院");

    SetPos(37,101);
    color(240);
    printf("  ");
    color(11);
    printf("  监狱        ");

    color(160);
    printf("  ");
    color(11);
    printf("  许愿池");
}

4 data.c

包含一些信息的初始化和其他一些信息功能

#include "commands.h"
//数据类

void initialize_home_house()
{
    home_cost[0]=650,home_cost[1]=1300,home_cost[2]=2600,home_cost[3]=5200,home_cost[4]=10400;
    home_money[1]=1300,home_money[2]=4500,home_money[3]=8900,home_money[4]=13500,home_money[5]=21000;
    house_cost[0]=750,house_cost[1]=1500,house_cost[2]=3000,house_cost[3]=6000,house_cost[4]=12000;
    house_money_one[1]=1000,house_money_one[2]=3000,house_money_one[3]=6000,house_money_one[4]=9000,house_money_one[5]=13500;
    house_money_two[1]=1000,house_money_two[2]=3200,house_money_two[3]=6400,house_money_two[4]=9500,house_money_two[5]=14000;
    house_money_three[1]=1000,house_money_three[2]=2600,house_money_three[3]=4900,house_money_three[4]=7600,house_money_three[5]=10000;
}

void initialize_player(Player *x)
{
    x->cash=x->fund=15000;
    x->cycle=x->car=0;
    x->flag_any=0;
    x->flag_front=0;
    x->sleep=0;
    x->lottery_num=0;
    x->flag_gameover=0;
    int i;
    for(i=1; i<=25; i++)
        x->lottery[i]=0;
}

void initialize_lottery()
{
    memset(flag_lottery,0,sizeof flag_lottery);
}

void initialize_data()
{
    lottery_money=25000;
    f_money=5000;
    bout=0;
}

void news_map_patch(Player *p)  //新闻地图人物移动前位置表示补丁
{
    p->p->empty=p->p->empty==2?-1:0;
    if(p->p->empty==0)
    {
        make_map(p->p->x,p->p->y,p->p->col);
    }
    else if(p->p->empty==-1)
    {
        swap(&p->p->figure_1,&p->p->figure_2);
        print_player(p);
    }
}

void news(Player *p)
{
    clear_midstatus();
    int num;
    num=rand()%15+1;

    SetPos(22,104);
    color(14);

    switch(num)
    {
    case 1:
    {
        printf("从天而降的钞票,获得$%d",bout*100);
        p->cash+=bout*100;
    }
    break;
    case 2:
    {
        printf("遭遇小偷,损失现金百分之二十");
        p->cash*=0.8;
    }
    break;
    case 3:
    {
        printf("熬夜太晚,下一天赖床不起");
        p->sleep++;
    }
    break;
    case 4:
    {
        printf("偶遇黄金城故人,赠予$%d",bout*100);
        p->cash+=bout*100;
    }
    break;
    case 5:
    {
        printf("扶老奶奶过马路,奖励$%d",bout*100);
        p->cash+=bout*100;
    }
    break;
    case 6:
    {
        printf("被乞丐纠缠,失去$%d",bout*100);
        p->cash-=bout*100;
        p->flag_gameover=judge_money(p);
    }
    break;
    case 7:
    {
        printf("踩到狗粑粑,加一次任意骰子");
        p->flag_any++;
    }
    break;
    case 8:
    {
        printf("乱丢垃圾,罚款$10000");
        p->cash-=10000;
        p->flag_gameover=judge_money(p);
    }
    break;
    case 9:
    {
        printf("走路掉进井盖,住院两天");
        p->sleep=2;
        news_map_patch(p);
        hospital(p);
        print_player(p);
    }
    break;
    case 10:
    {
        printf("破坏公物,入狱两天");
        p->sleep=2;
        news_map_patch(p);
        prison(p);
        print_player(p);
    }
    break;
    case 11:
    {
        printf("某某行为被抓,入狱三天");
        p->sleep=3;
        news_map_patch(p);
        prison(p);
        print_player(p);
    }
    break;
    case 12:
    {
        printf("早起的鸟儿有肉吃,获得$10000");
        p->cash+=10000;
    }
    break;
    case 13:
    {
        int num,s=5000;
        SetPos(18,101);
        color(9);
        printf("来到共享单车,是否骑五次:  >   <");
        SetPos(20,112);
        printf("花费: $%d",s);
        SetPos(22,105);
        color(14);
        printf("  1-> 是        2-> 否    ");
        SetPos(18,130);
        color(12);
        num=input();
        if(num==1)
        {
            SetPos(25,112);
            if(p->cash>=5000)
            {
                printf("成功!");
                p->cash-=5000;
                p->cycle=5;
            }
            else
            {
                printf("现金不足!");
            }
        }
        else
        {
            SetPos(24,112);
            printf("按确定键继续!");
        }
    }
    break;
    case 14:
    {
        int num,s=10000;
        SetPos(18,101);
        color(9);
        printf("来到租车公司,是否租7次:  >   <");
        SetPos(20,111);
        printf("花费: $%d",s);
        SetPos(22,105);
        color(14);
        printf("  1-> 是        2-> 否    ");
        SetPos(18,130);
        color(12);
        num=input();
        if(num==1)
        {
            SetPos(25,112);
            if(p->cash>=10000)
            {
                printf("成功!");
                p->cash-=10000;
                p->car=7;
            }
            else
            {
                printf("现金不足!");
            }
        }
        else
        {
            SetPos(24,112);
            printf("按确定键继续!");

        }
    }
    break;
    case 15:
    {
        int num,ks;
        printf("被抢劫,歹徒有刀是否反抗:  >   <");
        SetPos(22,105);
        color(13);
        printf("  1-> 是        2-> 否    ");
        SetPos(18,130);
        color(12);
        num=input();
        if(num==1)
        {
            SetPos(24,101);
            printf("没有损失钱财,但是重伤,住院四天");
            p->sleep=4;
            news_map_patch(p);
            hospital(p);
            print_player(p);
        }
        else
        {
            SetPos(24,101);
            printf("损失$%d",bout*1000);
            p->cash-=bout*1000;
            p->flag_gameover=judge_money(p);
        }
    }
    break;
    }
    color(15);
}

5 maps.c

地图类,包含了在屏幕显示地图等功能

#include "commands.h"
//地图类

void creat_map(Map_link *start)
{
    mid_screen();
    SetPos(22,59);
    color(14);
    printf("请选择你想游玩的地图编号");


    FILE *fp=NULL;
    if((fp=fopen("map_number.txt","r"))==NULL)
    {
        SetPos(26,63);
        color(12);
        printf("缺少地图编号信息");
        exit(1);
    }
    else
    {
        int i,num,map_news[10];
        fscanf(fp,"%d",&num);
        for(i=1; i<=num; i++)
            fscanf(fp,"%d",&map_news[i]);
        SetPos(27,53);

        color(11);
        for(i=1; i<=num; i++)
            printf("[%d]     ",map_news[i]);
        fclose(fp);
        fp=NULL;

        color(10);
        SetPos(31,67);
        printf("<     >");
        SetPos(31,70);
        int x=input();
        char s[]= {"map_0.txt"};
        s[4]=x+'0';
        if((fp=fopen(s,"r"))==NULL)
        {
            SetPos(34,65);
            color(12);
            printf("缺少地图信息");
            exit(1);
        }
        else
        {
            clear_screen();
            mid_screen();
            SetPos(25,56);
            color(10);
            printf("正在加载地图与相关信息,请稍后");
            Sleep(2000);
            clear_screen();

            int i,n,m,k;
            fscanf(fp,"%d%d%d%d",&n,&m,&k,&ab);

            for(i=1; i<=ab; i++)
                fscanf(fp,"%d %d ",&fa[i],&fb[i]);
            int num,x,y,col,in_col;
            Map_link *p=start;
            for(i=1; i<=k; i++)
            {
                if(i<=n)
                {
                    if(i==1)
                    {
                        fscanf(fp,"%d %d %d %d %d",&start->number,&start->x,&start->y,&start->col,&start->site);
                        start->figure_x=start->x+1,start->figure_y=start->y+2;
                        if(start->site>=9) start->lv=start->owner=0;
                    }
                    else
                    {
                        Map_link *pNew=(Map_link *)calloc(1,sizeof(Map_link));
                        pNew->previous=p;
                        fscanf(fp,"%d %d %d %d %d",&pNew->number,&pNew->x,&pNew->y,&pNew->col,&pNew->site);
                        pNew->figure_x=pNew->x+1,pNew->figure_y=pNew->y+2;
                        pNew->lv=pNew->owner=pNew->house_goto=0;
                        p->next=pNew;
                        p=pNew;
                        if(i==n)
                        {
                            p->next=start;
                            circuit_section(start,ab,fa,fb);  //回路节点构造
                        }
                    }
                    p->sum=n;
                    p->figure_1=p->figure_2=p->figure_3=p->figure_4=0;
                    if(p->site==6) hospital_dex=p->number;
                    else if(p->site==7) prison_dex=p->number;
                    make_map(p->x,p->y,p->col);
                    if(i==n) p=p->next;
                }
                else if(i<=m)
                {
                    fscanf(fp,"%d %d %d %d",&num,&x,&y,&col);
                    while(p->site!=9)
                    {
                        p=p->next;
                    }
                    p->ho_x=x,p->ho_y=y,p->ho_col=col;
                    make_home(p);
                    p=p->next;
                }
                else
                {
                    if(i==m+1) p=start;
                    fscanf(fp,"%d %d %d %d %d",&num,&x,&y,&col,&in_col);
                    while(p->site!=10)
                    {
                        p=p->next;
                    }
                    p->ho_x=x,p->ho_y=y,p->ho_col=col,p->ho_in_col=in_col;
                    p=p->next;
                    p->ho_x=x,p->ho_y=y,p->ho_col=col,p->ho_in_col=in_col;
                    make_house(p);
                    p=p->next;
                }
            }
            fclose(fp);
        }
    }
    return ;
}

void circuit_section(Map_link *start,int ab,int fa[],int fb[]) //循环节点
{
    Map_link *p=start,*a,*b;
    int i;
    for(i=1; i<=ab; i++)
    {
        a=b=p;
        int f_a=fa[i]-1,f_b=fb[i]-1;
        while(f_a--)
            a=a->next;
        while(f_b--)
            b=b->next;
        a->behind=b;
    }
}

void make_map(int x,int y,int col)
{
    color(col);
    SetPos(x++,y);
    printf("+---+");
    SetPos(x++,y);
    printf("|   |");
    SetPos(x,y);
    printf("+---+");
    color(15);
}

void make_home(Map_link *p)
{
    make_map(p->ho_x,p->ho_y,p->ho_col);
    SetPos(p->ho_x+1,p->ho_y+2);
    if(p->owner) color(p->owner);
    else color(p->ho_col);
    printf("%d",p->lv);
    color(15);
}

void make_house(Map_link *p)
{
    SetPos(p->ho_x,p->ho_y);
    color(p->ho_col);
    printf("+--------+");
    int i;
    for(i=1; i<=4; i++)
    {
        SetPos(p->ho_x+i,p->ho_y);
        printf("|        |");
    }
    SetPos(p->ho_x+i,p->ho_y);
    printf("+--------+");
    color(p->ho_in_col);
    SetPos(p->ho_x+i-1,p->ho_y+2);
    printf("+----+");
    SetPos(p->ho_x+i-2,p->ho_y+2);
    printf("|    |");
    SetPos(p->ho_x+i-3,p->ho_y+2);
    printf("+----+");
    SetPos(p->ho_x+i-4,p->ho_y+3);
    printf("+--+");
    SetPos(p->ho_x+i-2,p->ho_y+3);
    if(p->owner)
    {
        color(p->owner);
        printf("%d->%d",p->house_goto,p->lv);
    }
    else
        printf("LV.0");
    color(15);
}

void bout_num()
{
    bout_frame();
    SetPos(3,49);
    color(14);
    printf("%-4d",bout);
    color(15);
}

void bout_frame()
{
    color(11);
    SetPos(2,43);
    printf("+---------+");
    SetPos(3,43);
    putchar('|');
    SetPos(3,53);
    putchar('|');
    SetPos(4,43);
    printf("+---------+");

    SetPos(3,44);
    color(13);
    printf("bout:");
}

Map_link *random_location(Map_link *start)
{
    int i,x=rand()%start->sum+1;
    while(x--)
    {
        start=start->next;
    }
    for(i=1; i<=ab; i++)
    {
        if(start->number==fb[i]-1) start=start->previous;
    }
    return start;
}

void print_player(Player *p)
{
    if(p->p->empty==0)
    {
        p->p->figure_1=p->figure;
        p->p->empty++;
        SetPos(p->p->figure_x,p->p->figure_y);
        print_figure(p->p->figure_1);
    }
    else if(p->p->empty==1)
    {
        p->p->figure_2=p->figure;
        p->p->empty++;
        SetPos(p->p->figure_x,p->p->figure_y-1);
        print_figure(p->p->figure_1);
        color(p->p->col);
        putchar(' ');
        print_figure(p->p->figure_2);
    }
    else if(p->p->empty==-1)
    {
        p->p->figure_1=p->p->figure_2;
        p->p->figure_2=0;
        p->p->empty=1;
        SetPos(p->p->figure_x,p->p->figure_y-1);
        color(p->p->col);
        printf("   ");
        SetPos(p->p->figure_x,p->p->figure_y);
        print_figure(p->p->figure_1);
    }
}

void print_figure(int figure)
{
    color(figure);
    if(figure==10)
    {
        printf("@");
    }
    else if(figure==11)
    {
        printf("#");
    }
    else
    {
        printf("&");
    }
    color(15);
}

void print_figurestatus(Player p)
{
    int x=p.num==1?6:10;
    SetPos(x,100);
    printf("%dP:( ",p.num);
    print_figure(p.figure);
    printf(" )");
    SetPos(x-1,111);
    printf("Cash: ");
    color(9);
    printf("%-8d",p.cash);
    color(15);
    SetPos(x+1,111);
    printf("Fund: ");
    color(12);
    printf("%-8d",p.fund);
    color(15);
}

void print_vehiclestatus(Player p)
{
    int col=p.figure;
    int x=p.num==1?13:15;
    SetPos(x,100);
    printf("%dP :   ",p.num);
    color(col);
    print_vehicle(p);
    color(15);
}

void print_vehicle(Player p)
{
    if(p.cycle==0&&p.car==0)
        printf("NULL");
    if(p.car)
        printf("Car    %-2d",p.car);
    if(p.cycle)
        printf("Cycle  %-2d",p.cycle);
}

void hospital(Player *pp)
{
    while(pp->p->number!=hospital_dex)
        pp->p=pp->p->next;
    pp->flag_front=1;
}

void prison(Player *pp)
{
    while(pp->p->number!=prison_dex)
        pp->p=pp->p->next;
    pp->flag_front=1;
}

6 operations.c

一些操作的实现

#include "commands.h"
//操作类

int input()
{
    RevealCursor();
    char s[1000];
    int num;
    scanf("%s",s);
    HideCursor();
    getchar();
    if(atoi(s)==2157)
    {
        SetPos(44,0);
        exit(0);
    }
    return atoi(s);
}

void swap(int *a,int *b)
{
    int t=*a;
    *a=*b;
    *b=t;
}

void clear_game()
{
    return ;
}

void double_game()
{
    Player c_1p,c_2p;

    c_1p.num=1,c_2p.num=2;
    c_1p.figure=choose_character(1);
    if(c_1p.figure==-1) return ;
    c_2p.figure=choose_character(2);
    if(c_2p.figure==-1) return ;
    if(c_1p.figure==c_2p.figure) exit(0);

    initialize_player(&c_1p);
    initialize_player(&c_2p);
    initialize_home_house();
    initialize_lottery();
    initialize_data();

    Map_link *start;
    start=(Map_link *)calloc(1,sizeof(Map_link));
    start->previous=start->next=start->behind=NULL;

    creat_map(start);

    status_bar();
    locat_help();

    c_1p.p=random_location(start);
    sleep(1);
    c_2p.p=random_location(start);

    print_player(&c_1p);
    print_player(&c_2p);

    print_figurestatus(c_1p);
    print_figurestatus(c_2p);

    print_vehiclestatus(c_1p);
    print_vehiclestatus(c_2p);

    SetPos(22,110);
    color(9);
    printf("按确定键继续");
    getchar();

    while(++bout<=10000)
    {
        change_money=0;

        bout_num();
        frame(frame_col);

        lottery_money+=bout/25*10000;
        f_money+=bout/5*100;

        if(bout%25==0)
        {
            Lottery_award(&c_1p,&c_2p);
            print_figurestatus(c_1p);
            print_figurestatus(c_2p);
        }

        if(bout%30==0)
        {
            hand_accrual(&c_1p,&c_2p);
            print_figurestatus(c_1p);
            print_figurestatus(c_2p);
        }

        if(c_1p.sleep==0)
        {
            player_move(&c_1p,panel_dice(&c_1p));
            c_2p.cash+=change_money;
            print_figurestatus(c_1p);
            print_figurestatus(c_2p);
            print_vehiclestatus(c_1p);
            if(game_over(c_1p,c_2p)) return ;
        }
        else
        {
            SetPos(22,110);
            color(12);
            printf("1P原地停留一回合");
            c_1p.sleep--;
            getchar();
        }

        if(c_2p.sleep==0)
        {
            player_move(&c_2p,panel_dice(&c_2p));
            c_1p.cash+=change_money;
            print_figurestatus(c_2p);
            print_figurestatus(c_1p);
            print_vehiclestatus(c_2p);
            if(game_over(c_1p,c_2p)) return ;
        }
        else
        {
            SetPos(22,110);
            color(12);
            printf("2P原地停留一回合");
            c_2p.sleep--;
            getchar();
        }
    }
}

void more_content()
{
    mid_screen();
    SetPos(21,60);
    color(11);
    printf("更多内容请期待后续更新");

    SetPos(25,64);
    printf("按任意键返回!");
    getchar();

    color(15);
}

int change_color(int a)
{
    mid_screen();
    color(10);
    SetPos(21,51);
    printf("请输入数字来改变框架颜色,颜色对应如下:");

    int i,j;
    for(i=48,j=1; j<=15; i+=3,j++)
    {
        SetPos(25,i);
        color(j);
        printf("%d ",j);
        SetPos(26,i);
        putchar('*');
    }

    SetPos(30,57);
    printf("请输入你所选择的数字 [     ] ");
    SetPos(30,81);
    int x=input();
    if(x!=0)
    {
        frame(x);
        SetPos(33,56);
        color(x);
        printf("恭喜你改变成功,按任意键返回!");
        getchar();
        return x;
    }
    else
    {
        color(11);
        SetPos(33,56);
        printf("一点都不乖,自己玩吧!!(>﹏<)");
        getchar();
    }
    color(15);
    return a;
}

void quit()
{
    mid_screen();
    SetPos(25,63);
    color(12);
    printf("期待再次相遇!!!");
    SetPos(28,63);
    printf("按任意键退出!");
    getchar();
    color(15);
    SetPos(44,0);
}

void Withdrawal()
{
    exit(0);
}

int choose_character(int num)
{
    mid_screen();

    SetPos(21,51);
    color(14);
    printf("请输入 %dP 来选择你的人物,人物对应如下:",num);
    SetPos(23,62);
    printf("请勿选择相同角色!");
    color(15);

    int i,j;
    for(i=60,j=1; j<=3; i+=10,j++)
    {
        SetPos(25,i);
        color(j+9);
        printf("%d ",j);
        SetPos(26,i);
        if(j==1) printf("@");  //10
        else if(j==2) printf("#");  //11
        else printf("&");  //12
    }

    color(10);
    SetPos(30,57);
    printf("请输入你所选择的数字 [     ] ");
    SetPos(30,81);
    int x=input();

    if(x>=1&&x<=3)
    {
        SetPos(33,56);
        color(x+9);
        printf("恭喜你选择成功,按确定键继续!");
        getchar();
    }
    else
    {
        color(11);
        SetPos(33,56);
        printf("不按套路出牌,不和你玩啦!!!");
        color(15);
        getchar();
        exit(0);
    }
    color(15);
    return x+9;
}

int panel_dice(Player *p)
{
    clear_midstatus();

    int num,numm,a,i;

    color(p->figure);
    SetPos(17,115);
    if(p->figure==10) printf("-@-");
    else if(p->figure==11) printf("-#-");
    else if(p->figure==12) printf("-&-");
    color(15);

    if(p->cycle||p->car)
    {
        SetPos(18,100);
        color(9);
        printf(" 请选择你要投掷骰子的枚数  >   <");
        SetPos(20,105);
        color(14);
        printf("1          2          3");
        SetPos(18,129);
        color(12);
        numm=input();
    }

    if(numm==3&&p->car) ;
    else if(numm==2&&(p->cycle||p->car)) ;
    else numm=1;

    a=rand()%(numm*6)+numm;

    if(p->flag_any!=0)
    {
        p->flag_any--;
        SetPos(22,103);
        color(9);
        printf("请输入心中所想的数字 ->   <-");
        SetPos(24,112);
        color(14);
        printf("( %d - %d )",numm,numm*6);
        SetPos(22,127);
        color(12);
        num=input();

        color(9);
        SetPos(26,104);
        if(num>=numm&&num<=numm*6)
            printf("太幸运啦,骰子点数为: ");
        else printf("太不幸了,骰子点数为: "),num=1;
        color(12);
        printf("%d",num);
        color(15);
        return num;
    }
    else
    {
        SetPos(20,103);
        color(9);
        printf("正在为%dP摇骰子,请稍后 --- ",p->num);

        for(i=3; i>=0; i--)
        {
            SetPos(23,112);
            color(14);
            printf("[   %d   ]",i);
            Sleep(500);
        }
        SetPos(26,107);
        color(9);
        printf("为你摇到的点数为: ");
        color(12);
        printf("%d",a);
        color(15);
    }
    getchar();
    return a;
}

int game_over(Player c_1p,Player c_2p)
{
    clear_midstatus();
    if(c_1p.flag_gameover==1)
    {
        SetPos(20,108);
        color(12);
        printf("恭喜2P游戏胜利!!!");
        SetPos(23,108);
        printf("最终资产$%d",c_2p.cash+c_2p.fund);
        getchar();
        return 1;
    }
    else if(c_2p.flag_gameover==1)
    {
        SetPos(20,108);
        color(12);
        printf("恭喜1P游戏胜利!!!");
        SetPos(23,108);
        printf("最终资产$%d",c_1p.cash+c_1p.fund);
        return 1;
    }
    return 0;
}

void player_move(Player *p,int step)
{
    int i,k=step;
    do
    {
        p->p->empty=p->p->empty==2?-1:0;
        if(p->p->empty==0)
        {
            make_map(p->p->x,p->p->y,p->p->col);
        }
        else if(p->p->empty==-1)
        {
            //补丁
            if((step>=1&&k!=1||step>1)&&step<k)
            {
                swap(&p->p->figure_1,&p->p->figure_2);
            }
            print_player(p);
        }

        if(p->flag_front)
        {
            int flag=0;
            for(i=1; i<=ab; i++)
                if(p->p->number==fa[i]) flag=1;
            if(flag) p->p=p->p->behind,p->flag_front=0;
            else p->p=p->p->previous;
        }
        else
        {
            p->p=p->p->next;
        }

        for(i=1; i<=ab; i++)
        {
            if(p->p->number==fb[i]-1)
                p->flag_front=1;
        }
        print_player(p);
        Sleep(500);

        if(p->p->site==2)
            hand(p);
        else if(p->p->site==3)
            lottery(p);
    }
    while(--step);
    location_opeartions(p);
}

int judge_money(Player *p)  //判断时把负数转化为0,返还值为1表示破产
{
    if(p->cash+p->fund<=0) return 1;
    else
    {
        if(p->cash<0)
        {
            p->fund+=p->cash;
            p->cash=0;
        }
        else if(p->fund<0)
        {
            p->cash+=p->fund;
            p->fund=0;
        }
        return 0;
    }
}

void location_opeartions(Player *p)
{
    clear_midstatus();
    switch(p->p->site)
    {
    case 1:
    {
        news(p);
    }
    break;
    case 4:
    {
        SetPos(18,108);
        color(9);
        printf("欢迎您来到贫民窟");
        SetPos(20,110);
        printf("你是善良的");
        SetPos(22,110);
        printf("你捐献了");
        SetPos(24,110);
        color(12);
        printf("$%d",f_money);
        p->cash-=f_money;
        p->flag_gameover=judge_money(p);
    }
    break;
    case 5:
    {
        SetPos(18,108);
        color(12);
        printf("欢迎您来到黄金城");
        SetPos(20,110);
        printf("你是幸运的");
        SetPos(22,110);
        printf("捡到了黄金");
        SetPos(24,110);
        color(12);
        printf("$%d",f_money);
        p->cash+=f_money;
    }
    break;
    case 8:
    {
        SetPos(19,105);
        color(10);
        printf("你来到许愿池面前");
        SetPos(22,105);
        printf("看着池水,心想事成");
        SetPos(25,105);
        printf("下轮摇骰子点数为内心所想");
        p->flag_any++;
    }
    break;
    case 9:
    {
        if(p->p->owner==0)
        {
            if(p->p->lv==5) return ;
            int num;
            SetPos(18,101);
            color(9);
            printf("来到空地,是否购买此地:  >   <");
            SetPos(20,112);
            printf("花费: $%d",home_cost[p->p->lv]);
            SetPos(22,105);
            color(14);
            printf("  1-> 是        2-> 否    ");
            SetPos(18,128);
            color(12);
            num=input();

            if(num==1&&p->cash>=home_cost[p->p->lv])
            {
                color(13);
                SetPos(25,111);
                printf("恭喜购买成功");
                p->cash-=home_cost[p->p->lv];
                p->p->lv=1;
                p->p->owner=p->figure;
            }
            else if(num==1&&p->cash<home_cost[p->p->lv])
            {
                color(13);
                SetPos(25,111);
                printf("你的现金不足");
            }
            else
            {
                color(10);
                SetPos(25,115);
                printf("未购");
            }
            color(15);
            SetPos(27,111);
            printf("按确定键继续");
        }
        else if(p->p->owner==p->figure)
        {
            clear_midstatus();
            int num;
            SetPos(18,101);
            color(9);
            printf("你的地产,是否升级此地:  >   <");
            SetPos(20,112);
            printf("花费: $%d",home_cost[p->p->lv]);
            SetPos(22,105);
            color(14);
            printf("  1-> 是        2-> 否    ");
            SetPos(18,128);
            color(12);
            num=input();

            if(num==1&&p->cash>=home_cost[p->p->lv])
            {
                color(13);
                SetPos(25,111);
                printf("恭喜升级成功");
                p->cash-=home_cost[p->p->lv];
                p->p->lv++;
            }
            else if(num==1&&p->cash<home_cost[p->p->lv])
            {
                color(13);
                SetPos(25,111);
                printf("你的现金不足");
            }
            else
            {
                color(10);
                SetPos(25,115);
                printf("未升");
            }

            color(15);
            SetPos(27,111);
            printf("按确定键继续");
        }
        else
        {
            SetPos(20,106);
            color(12);
            printf("在此歇脚,需要租金$%d",home_money[p->p->lv]);
            p->cash-=home_money[p->p->lv];
            change_money=home_money[p->p->lv];
            p->flag_gameover=judge_money(p);
        }
        make_home(p->p);
    }
    break;
    case 10:
    {
        clear_midstatus();
        int num,cs,ks;
        if(p->p->owner==0)
        {
            if(p->p->lv==5) return ;
            SetPos(18,101);
            color(9);
            printf("来到大空地,是否购买此地:  >   <");
            SetPos(20,112);
            printf("花费: $%d",house_cost[p->p->lv]);
            SetPos(22,105);
            color(14);
            printf("  1-> 是        2-> 否    ");
            SetPos(18,130);
            color(12);
            num=input();

            if(num==1&&p->cash>=house_cost[p->p->lv])
            {
                color(13);
                SetPos(25,111);
                printf("恭喜购买成功");
                p->cash-=house_cost[p->p->lv];
                p->p->lv=1;
                p->p->owner=p->figure;
                if(p->p->next->site==10) p->p->next->lv=1,p->p->next->owner=p->figure;
                else p->p->previous->lv=1,p->p->previous->owner=p->figure;
            }
            else if(num==1&&p->cash<house_cost[p->p->lv])
            {
                color(13);
                SetPos(25,111);
                printf("您的现金不足");
            }
            else
            {
                color(10);
                SetPos(25,115);
                printf("未购");
            }

            color(15);
            SetPos(27,111);
            printf("按确定键继续");
        }
        else if(p->p->owner==p->figure)
        {
            clear_midstatus();
            if(p->p->lv==1)
            {
                SetPos(18,101);
                color(9);
                printf("你的地产,请选择升级方向:  >   <");
                SetPos(20,112);
                printf("花费: $%d",house_cost[p->p->lv]);
                SetPos(22,100);
                color(14);
                printf("1->石油公司 2->商业公司 3->BR酒店");
                SetPos(18,128);
                color(12);
                num=input();

                if(num>=1&&num<=3&&p->cash>=house_cost[p->p->lv])
                {
                    color(13);
                    SetPos(25,111);
                    printf("恭喜升级成功");
                    p->cash-=house_cost[p->p->lv];
                    p->p->lv++;
                    p->p->house_goto=num;
                    if(p->p->next->site==10) p->p->next->lv++,p->p->next->house_goto=num;
                    else p->p->previous->lv++,p->p->previous->house_goto=num;
                }
                else if(num>=1&&num<=3&&p->cash<house_cost[p->p->lv])
                {
                    color(13);
                    SetPos(25,111);
                    printf("您的现金不足");
                }
                else
                {
                    color(10);
                    SetPos(25,115);
                    printf("未升");
                }
                color(15);
                SetPos(27,111);
                printf("按确定键继续");
            }
            else
            {
                SetPos(18,101);
                color(9);
                printf("你的地产,是否升级此地:  >   <");
                SetPos(20,112);
                printf("花费: $%d",house_cost[p->p->lv]);
                SetPos(22,105);
                color(14);
                printf("  1-> 是        2-> 否    ");
                SetPos(18,128);
                color(12);
                num=input();
                if(num==1&&p->cash>=house_cost[p->p->lv])
                {
                    color(13);
                    SetPos(25,111);
                    printf("恭喜升级成功");
                    p->cash-=house_cost[p->p->lv];
                    p->p->lv++;
                }
                else if(num==1&&p->cash<house_cost[p->p->lv])
                {
                    color(13);
                    SetPos(25,111);
                    printf("您的现金不足");
                }
                else
                {
                    color(10);
                    SetPos(25,115);
                    printf("未升");
                }
            }
        }
        else
        {
            if(p->p->lv==1) cs=house_money_one[1];
            else if(p->p->house_goto==1) cs=house_money_two[p->p->lv];
            else if(p->p->house_goto==3) cs=house_money_three[p->p->lv];

            if(p->p->house_goto==1)
            {
                SetPos(20,106);
                color(12);
                printf("开始购物,需要金额$%d。",cs);
                p->cash-=cs;
                p->flag_gameover=judge_money(p);
            }
            else if(p->p->house_goto==3)
            {
                SetPos(20,106);
                color(12);
                printf("在此歇脚,需要租金$%d。",cs);
                SetPos(22,106);
                printf("你很疲惫,在此住了%d天.",p->p->lv);
                p->sleep=p->p->lv;
                p->cash-=cs;
                p->flag_gameover=judge_money(p);
            }
            else if(p->p->house_goto==2)
            {
                SetPos(20,106);
                color(12);
                printf("来到公司,获得收益$%d。",house_money_one[p->p->lv]);
                p->cash+=house_money_one[p->p->lv];
            }
            else if(p->p->house_goto==0)
            {
                SetPos(20,106);
                color(12);
                printf("在此歇脚,交出租金$%d。",cs);
                p->cash-=cs;
                p->flag_gameover=judge_money(p);
            }
            change_money=cs;
        }
        make_house(p->p);
    }
    break;
    }
    color(15);
    getchar();
}

void hand(Player *p)
{
    clear_midstatus();
    int num;
    SetPos(18,100);
    color(9);
    printf("   请选择你要进行的操作  >   <");
    SetPos(20,101);
    color(14);
    printf("1-> 存款    2-> 取款    3-> 无");
    SetPos(18,127);
    color(12);
    num=input();

    if(num==3)
    {
        color(12);
        SetPos(27,105);
        printf("    欢迎您下次光临    ");
    }
    else if(num==1)
    {
        SetPos(22,103);
        color(9);
        printf("请输入要存款的金额:        $");
        color(12);
        SetPos(22,122);
        num=input();
        if(p->cash>=num)
        {
            SetPos(25,111);
            color(13);
            printf("存款成功!!!");
            p->cash-=num;
            p->fund+=num;
        }
        else
        {
            SetPos(25,110);
            color(13);
            printf("你的现金不足!!!");
        }
    }
    else if(num==2)
    {
        SetPos(22,103);
        color(9);
        printf("请输入要取款的金额:        $");
        color(12);
        SetPos(22,122);
        num=input();
        if(p->fund>=num)
        {
            SetPos(25,111);
            color(13);
            printf("取款成功!!!");
            p->fund-=num;
            p->cash+=num;
        }
        else
        {
            SetPos(25,110);
            color(13);
            printf("你的余额不足!!!");
        }
    }
    else
    {
        SetPos(23,103);
        color(12);
        printf("    请规范您的输入格式    ");
        color(9);
        SetPos(25,112);
        printf("按键继续");

        color(12);
        SetPos(27,105);
        printf("    欢迎您下次光临    ");

    }

    getchar();
    color(15);
}

void hand_accrual(Player *a,Player *b)
{
    double accrual=(rand()%10)+10;
    clear_midstatus();
    SetPos(18,106);
    color(12);
    printf("正在生成利息,请稍候");
    int i;
    for(i=3; i>=0; i--)
    {
        color(11);
        SetPos(21,113);
        printf(">- ");
        color(13);
        printf("%d",i);
        color(11);
        printf(" -<");
        if(i!=0) Sleep(1000);
    }
    SetPos(24,106);
    color(9);
    printf("这轮银行利息为%.2lf%%",accrual);
    a->fund+=1.0*a->fund*accrual/100;
    b->fund+=1.0*b->fund*accrual/100;
    getchar();

}

void lottery(Player *p)
{
    clear_midstatus();
    int num,i,k=19;
    SetPos(18,100);
    color(9);
    printf("欢迎来到乐透,是否买彩票:  >   <");
    SetPos(20,112);
    printf("花费: $%d",bout/25*1500+1000);
    SetPos(22,105);
    color(14);
    printf("  1-> 是        2-> 否    ");
    SetPos(18,129);
    color(12);
    num=input();

    if(num!=1)
    {
        color(9);
        SetPos(25,112);
        printf("好的再见");
    }
    else
    {
        clear_midstatus();
        SetPos(18,103);
        color(9);
        printf("请选择你要购买的号码:  >   <");

        for(i=1; i<=25; i++)
        {
            if(i==1||i==6||i==11||i==16||i==21)
            {
                SetPos(++k,102);
            }
            color(15);
            printf("%2d:",i);
            if(flag_lottery[i]==0)
            {
                color(14);
                printf(" O ");
            }
            else
            {
                color(flag_lottery[i]);
                printf(" X ");
            }
        }
        SetPos(18,128);
        color(12);
        num=input();

        if(num>=1&&num<=25&&flag_lottery[num]==0&&p->cash>=bout/25*1500+1000)
        {
            color(12);
            SetPos(26,112);
            printf("购买成功");
            flag_lottery[num]=p->figure;
            p->lottery[num]=1;
            p->lottery_num++;
            p->cash-=bout/25*1500+1000;
        }
        else
        {
            color(12);
            SetPos(26,112);
            printf("购买失败");
        }
        color(10);
        SetPos(28,110);
        printf("按确定键继续");
    }
    getchar();
}

void Lottery_award(Player *fa,Player *fb)
{
    int n=rand()%25+1;
    int i;
    int flag_a=0,flag_b=0;

    clear_midstatus();
    SetPos(18,106);
    color(12);
    printf("乐透即将开奖,请稍候");

    for(i=5; i>=0; i--)
    {
        color(11);
        SetPos(21,113);
        printf(">- ");
        color(13);
        printf("%d",i);
        color(11);
        printf(" -<");
        if(i!=0) Sleep(1000);
    }

    color(11);
    SetPos(24,107);
    printf("中奖号码 :");
    color(12);
    SetPos(24,118);
    printf("%d",n);
    getchar();

    fa->lottery_num=fb->lottery_num=0;
    for(i=1; i<=25; i++)
    {
        flag_lottery[i]=0;
        if(fa->lottery[i]==1&&i==n) flag_a=1;
        fa->lottery[i]=0;
    }
    for(i=1; i<=25; i++)
    {
        if(fb->lottery[i]==1&&i==n) flag_b=1;
        fb->lottery[i]=0;
    }
    if(flag_a)
    {
        fa->cash+=lottery_money;
        SetPos(27,106);
        color(9);
        printf("恭喜1P获得%d$奖金",lottery_money);
    }
    else if(flag_b)
    {
        fb->cash+=lottery_money;
        SetPos(24,106);
        color(9);
        printf("恭喜2P获得%d$奖金",lottery_money);
    }
    else
    {
        SetPos(24,106);
        color(9);
        printf("本届乐透没有中奖嘉宾");
    }
    getchar();
}

7 commands.h

头函数,一些数据创建和函数总章

#ifndef COMMANDS_H_INCLUDED
#define COMMANDS_H_INCLUDED

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <windows.h>
int flag_lottery[26],lottery_money,f_money;  //彩票标记,彩票金额,穷与富地金额
int home_cost[6],home_money[6];  //小房子升级花费和赚钱金额
int house_money_one[6],house_money_two[6],house_money_three[6];  //大房子赚钱金额
int house_cost[6];  //大房子升级花费
int bout;  //回合数,租金
int frame_col; //框架颜色
int hospital_dex,prison_dex;
int ab,fa[100],fb[100];  //节点数,结点起点,结点终点
int change_money;

typedef struct map_link
{
    int sum;  //链表总长度
    int x,y;
    int figure_x,figure_y;
    int ho_x,ho_y,ho_col,ho_in_col;
    int number;
    int col;
    int site;
    int lv,owner,house_goto;
    int empty;
    int figure_1,figure_2,figure_3,figure_4;
    struct map_link *previous,*next,*behind;
} Map_link;

typedef struct player
{
    int flag_gameover;
    int sleep;
    int cash,fund;
    int flag_any;
    int cycle,car;
    int figure;
    int num;
    int flag_front;
    int lottery[26],lottery_num;
    Map_link *p;
} Player;

//map.c
void creat_map(Map_link *start);
void circuit_section(Map_link *start,int ab,int fa[],int fb[]); //循环节点
void make_map(int x,int y,int col);
void make_home(Map_link *p);
void make_house(Map_link *p);
void bout_num();
void bout_frame();
Map_link *random_location(Map_link *start);
void print_player(Player *p);
void print_figure(int figure);
void print_figurestatus(Player p);
void print_vehiclestatus(Player p);
void print_vehicle(Player p);
void hospital(Player *pp);
void prison(Player *pp);

//data.c
void initialize_home_house();
void initialize_player(Player *x);
void initialize_lottery();
void initialize_data();
void news_map_patch(Player *p);  //新闻地图人物移动前位置表示补丁
void news(Player *p);

//operations.c
int input();
void swap(int *a,int *b);
void clear_game();
void double_game();
void more_content();
int change_color(int a);
void quit();
void Withdrawal();
int choose_character(int num);
int panel_dice(Player *p);
int game_over(Player c_1p,Player c_2p);
void player_move(Player *p,int step);
int judge_money(Player *p);  //判断时把负数转化为0,返还值为1表示破产
void location_opeartions(Player *p);
void hand(Player *p);
void hand_accrual(Player *a,Player *b);
void lottery(Player *p);
void Lottery_award(Player *fa,Player *fb);

//windows.c
void screen_size(int a,int b);// 屏幕大小(a列b行)
void color(int x);
void HideCursor();
void RevealCursor();
void SetPos(int y, int x);
void frame(int x);
void clear_screen();
void title();
void menu();
void mid_screen();  //中央屏幕
void status_bar();
void clear_midstatus();
void help();
void locat_help();

#endif // COMMANDS_H_INCLUDED

8 地图文本

在与可执行的exe程序放在同一文件夹下

8.1 一号地图(命名为map_1)

56 71 74 2
17 22 41 48
1 12 46 128 0
2 12 41 128 10
3 12 36 128 10
4 12 31 96 5
5 9 31 128 0
6 6 31 128 0
7 6 26 128 9
8 6 21 128 9
9 6 16 128 9
10 6 11 128 0
11 9 11 128 9
12 12 11 128 9
13 15 11 128 9
14 18 11 160 8
15 18 16 224 2
16 21 16 128 0
17 24 16 128 0
18 27 16 128 0
19 30 16 128 0
20 33 16 128 0
21 33 11 240 7
22 24 21 128 10
23 24 26 128 10
24 24 31 128 0
25 27 31 128 0
26 30 31 128 0
27 30 36 128 0
28 30 41 128 9
29 30 46 128 9
30 33 46 128 9
31 33 51 128 9
32 33 56 128 9
33 30 56 176 1
34 30 61 128 0
35 30 66 128 10
36 30 71 128 10
37 30 76 112 4
38 27 76 128 0
39 24 76 128 0
40 21 76 128 0
41 18 76 128 0
42 18 81 208 3
43 18 86 128 0
44 15 86 128 0
45 12 86 128 0
46 9 86 128 0
47 6 86 64 6
48 18 71 128 0
49 18 66 160 8
50 15 66 224 2
51 12 66 128 9
52 9 66 128 9
53 9 61 128 9
54 9 56 128 9
55 9 51 176 1
56 12 51 128 0
57 3 26 48
58 3 21 48
59 3 16 48
60 9 6 48
61 12 6 48
62 15 6 48
63 27 41 48
64 27 46 48
65 36 46 48
66 36 51 48
67 36 56 48
68 12 71 48
69 9 71 48
70 6 61 48
71 6 56 48
72 6 36 48 240
73 18 21 48 240
74 24 66 48 240

8.2 二号地图(命名为map_2)

55 71 75 2
6 10 27 34
1 12 51 128 9
2 12 46 128 9
3 12 41 128 9
4 12 36 96 5
5 12 31 128 0
6 12 26 128 0
7 9 26 128 0
8 6 26 128 0
9 3 26 64 6
10 12 21 176 1
11 15 21 128 0
12 18 21 128 0
13 21 21 128 0
14 21 16 128 10
15 21 11 128 10
16 24 11 128 9
17 27 11 128 9
18 30 11 128 9
19 33 11 128 9
20 33 16 224 2
21 36 16 128 9
22 36 21 128 9
23 36 26 128 9
24 36 31 160 8
25 36 36 128 10
26 36 41 128 10
27 36 46 128 0
28 36 51 128 0
29 36 56 128 0
30 36 61 128 0
31 36 66 128 0
32 36 71 128 0
33 36 76 240 7
34 33 46 128 0
35 30 46 128 0
36 27 46 176 1
37 27 51 128 10
38 27 56 128 10
39 27 61 128 0
40 27 66 112 4
41 27 71 128 0
42 27 76 128 0
43 27 81 128 0
44 27 86 128 9
45 24 86 128 9
46 21 86 160 8
47 21 81 128 10
48 21 76 128 10
49 21 71 128 0
50 18 71 128 0
51 15 71 224 2
52 12 71 128 9
53 12 66 128 9
54 12 61 128 9
55 12 56 128 9
56 9 51 48
57 9 46 48
58 9 41 48
59 24 6 48
60 27 6 48
61 30 6 48
62 33 6 48
63 39 16 48
64 39 21 48
65 39 26 48
66 27 91 48
67 24 91 48
68 9 71 48
69 9 66 48
70 9 61 48
71 9 56 48
72 15 11 48 240
73 30 36 48 240
74 21 51 48 240
75 15 76 48 240

8.3 三号地图(命名为map_3)

61 75 79 6
6 10 17 21 23 30 36 40 47 51 54 61
1 9 46 128 9
2 9 51 128 9
3 9 56 96 5
4 9 61 128 9
5 9 66 128 9
6 9 71 224 2
7 9 76 128 0
8 9 81 128 10
9 9 86 128 10
10 12 71 128 0
11 15 71 128 0
12 18 71 128 0
13 21 71 128 0
14 24 71 128 0
15 27 71 128 0
16 30 71 128 0
17 33 71 176 1
18 33 76 128 0
19 33 81 128 10
20 33 86 128 10
21 33 66 128 9
22 33 61 128 9
23 33 56 128 0
24 30 56 128 0
25 27 56 208 3
26 24 56 128 0
27 21 56 128 0
28 18 56 128 0
29 15 56 64 6
30 33 51 128 9
31 33 46 128 9
32 33 41 128 9
33 33 36 112 4
34 33 31 128 9
35 33 26 128 9
36 33 21 224 2
37 33 16 128 0
38 33 11 128 10
39 33 6 128 10
40 30 21 128 0
41 27 21 128 0
42 24 21 128 0
43 21 21 128 0
44 18 21 128 0
45 15 21 128 0
46 12 21 128 0
47 9 21 176 1
48 9 16 128 0
49 9 11 128 10
50 9 6 128 10
51 9 26 128 9
52 9 26 128 9
53 9 31 128 0
54 9 36 128 0
55 12 36 128 0
56 15 36 128 0
57 18 36 128 0
58 21 36 128 0
59 24 36 128 0
60 27 36 240 7
61 9 41 128 9
62 6 46 48
63 6 51 48
64 6 61 48
65 6 66 48
66 36 66 48
67 36 61 48
68 36 51 48
69 36 46 48
70 36 41 48
71 36 31 48
72 36 26 48
73 6 26 48
74 6 31 48
75 6 41 48
76 3 81 48 240
77 27 81 48 240
78 27 6 48 240
79 3 6 48 240

8.4 地图菜单(命名为map_number)

3
1 2 3

9 部分展示

9.1 主菜单

在这里插入图片描述

9.2 地图一

在这里插入图片描述

9.3 地图二

在这里插入图片描述

9.4 地图三

在这里插入图片描述

9.5 选角色

在这里插入图片描述

9.6 状态栏

在这里插入图片描述

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冰白i

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值