⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treasure.c

📁 西工大程序设计大赛作品 拿出来与大家分享 含完整工作日记 历史备分 源代码及注释 RPG(role-playing game,角色扮演类游戏) 战斗用菜单操作:一级菜单有两项
💻 C
📖 第 1 页 / 共 4 页
字号:
}



void scenario()                                               /*剧情函数*/
{                                                             /**/
    cleardevice();                                                       /*当人物所在行列位置对应的数组元素值大于500,也就是人物在hi!处时调用该函数*/
    if (Currentmap[Row-1][Column-1]==500)                                         /*剧情由对话组成,通过数组的值来确定要进行哪一部分剧情*/
    {                                                         /**/
        outtextxy(20,20,"   ,--.");
        outtextxy(20,30,"   c   \\ ");
        outtextxy(20,40,"   /    \\ ");
        outtextxy(20,50," _/______\\_");
        outtextxy(20,60,"(__________)");
        outtextxy(20,70,"(/  @  @  \)");
        outtextxy(20,80,"(`._,()._,')");
        outtextxy(20,90,"(  `-'`-'  )");
        outtextxy(20,100," \\        /");
        outtextxy(20,110,"  \,,,,,,/");


        outtextxy(20,120,"Old man1: Hi!Young man,I know that you want to run a risk.");
        bioskey(0);
        outtextxy(20,140,"Old man1: What I can do is just to give my best wishes to you.");             /**/
        bioskey(0);
        outtextxy(20,160,"Old man1: Good luck!");
        bioskey(0);
        outtextxy(20,200,"  ,-------.");
        outtextxy(20,210," |,'-----'.|");
        outtextxy(20,220,"{_/(') (')\\_}");
        outtextxy(20,230," `.   _   .'");
        outtextxy(20,240,"  /'-___-'\\ ");
        outtextxy(20,250," /         \\ ");
        outtextxy(20,260,"(_)_______(_)");
        outtextxy(20,270,"Soff: \2Thank you.Don't worry.I'll be back with the treasure soon.");
        bioskey(0);                                           /**/
    }                                                         /**/
    if (Currentmap[Row-1][Column-1]==501)                                         /**/
    {                                                         /**/
        outtextxy(20,20,"Farmer: Brave boy,take this,it may help you.");
        bioskey(0);
        outtextxy(200,40,"HP=1000,MP=600");
        outtextxy(20,60,"Farmer: And remember that,after a fight,you'd better heal your wound.");
        bioskey(0);
        outtextxy(20,200,"Soff: Thank you.");
        bioskey(0);
    }








    if (Currentmap[Row-1][Column-1]==502)
    {
        outtextxy(20,20,"Old woman1: Oh,young man,I know that you will have a trip. ");
        outtextxy(20,30,"            Would you like help me?");
        bioskey(0);
        outtextxy(20,200,"Soff:Yes?");
        bioskey(0);
        outtextxy(20,50,"Old woman1: Here's a letter,bring it to my sister,she is in mapR 14 9.");
        bioskey(0);
        Letter=1;

    }
    if (Currentmap[Row-1][Column-1]==503)
    {
        if (Letter==1)
        {
            outtextxy(20,20,"Old woman2:The letter form my sister?");
            bioskey(0);
            outtextxy(20,40,"Old woman2:En,thank you,In order to express my appreciation,");
            outtextxy(20,50,"            remeber that,in my map,the left is always right. ");
            bioskey(0);
            outtextxy(20,220,"Soff: What?");
            bioskey(0);
        }
        else
        {
            outtextxy(20,20,"Old Woman2: Young man,I know a secret about the maze.");
            bioskey(0);
            outtextxy(20,40,"Old Woman2: But I will not tell you the secret.");
            bioskey(0);
            outtextxy(20,200,"Soff: But, why?");
            bioskey(0);
            outtextxy(20,60,"Old woman2: But why I should tell you?");
            bioskey(0);
        }



    }
    if (Currentmap[Row-1][Column-1]==504)
    {
        outtextxy(300,20,"       .  ======= ");
        outtextxy(300,30,"      / \\| O   O |");
        outtextxy(300,40,"      \\ /  \\ @ /");
        outtextxy(300,50,"       #   _| |_");
        outtextxy(300,60,"      (#) (     )");
        outtextxy(300,70,"       #\\//|   |\\     ");
        outtextxy(300,80,"       #\\/(     )/     ");
        outtextxy(300,90,"       #   =====       ");
        outtextxy(300,100,"       #   (\\ /)       ");
        outtextxy(300,110,"       #   || ||       ");
        outtextxy(300,120,"      .#---'| |----.");
        outtextxy(300,130,"       #----' -----'");
        outtextxy(20,20,"Robber: The tree,I planted it;");
        bioskey(0);
        outtextxy(20,30,"        The path,I opened it;");
        bioskey(0);
        outtextxy(20,40,"        To go through it;");
        bioskey(0);
        outtextxy(20,50,"        100$ is needed!");
        bioskey(0);
        outtextxy(20,200,"Soff: Oh,Bad luck!");
        bioskey(0);
        fight(100);

    }
    if (Currentmap[Row-1][Column-1]==505)
    {
        outtextxy(20,60,"A CAT HAS NINE LIVES,BUT YOU HAVE TEN.");
        bioskey(0);
    }
    if (Currentmap[Row-1][Column-1]==506)
    {
        outtextxy(20,200,"Soff:It seems that the treasure is already in my hands.");
        bioskey(0);
    }
    if (Currentmap[Row-1][Column-1]==507)
    {
        outtextxy(20,200,"Soff:Maybe it's the treasure.");
        bioskey(0);
    }
    if (Currentmap[Row-1][Column-1]==508)
    {
        outtextxy(20,20,"Ghost:Anyone who wants to take the treasure will be killed!");
        outtextxy(20,30,"        _________________");
        outtextxy(20,40,"   .---------..._    _..-`-._");
        outtextxy(20,50,"  ';--.  <^'o';  '.'' .'o'^> '-.    ");
        outtextxy(20,60,"    \\_/\\  `'''         ^^^^_/'/      ");
        outtextxy(20,70,"     /( '-._.-''/    \\''--' |'\\ ");
        outtextxy(20,80,"    // \\      _.-''''-.     |  |  ");
        outtextxy(20,90,"    |/ |\\   .' \\ TTTT /   _./  |");
        outtextxy(20,100,"   //. | ';\\ \\|\\Y    Y/|'| | | |");
        outtextxy(20,110,"  / // |_/  \\ |_ LLLL _|/  | | |");
        outtextxy(20,120," (_/ | |     \\  '''''' /   / / /");
        outtextxy(20,130,"   | / |      \\       /   | |_/");
        outtextxy(20,140,"   \\/| |       '''''''    | |  ");
        outtextxy(20,150,"     ( |                  | /");
        bioskey(0);
        fight(130);
        if (Loseornot==0)
        {
            cleardevice();
            outtextxy(60,60,"Soff:Oh,treasure,the treasure,I get it!! ");
            bioskey(0);
            cleardevice();
            outtextxy(290,200,"THE END");
            outtextxy(280,240,"Maker:QLSL");
            bioskey(0);

            Endornot=1;
        }
    }
    switch (Currentmap[0][20])                                /*由于剧情都只会进行一次,也就是同样的事不会发生两次*/
    {                                                         /*因此剧情发生后都要对地图数组重新赋值*/
        case 21:map1[Row-1][Column-1]=0;break;                /*此*/
        case 22:map2[Row-1][Column-1]=0;break;                /**/
        case 23:map3[Row-1][Column-1]=0;break;
        case 24:map4[Row-1][Column-1]=0;break;
        case 25:map5[Row-1][Column-1]=0;break;
     /* case 26:map6[Row-1][Column-1]=0;break;                */
        case 27:map7[Row-1][Column-1]=0;break;
        case 28:map8[Row-1][Column-1]=0;break;
        case 29:map9[Row-1][Column-1]=0;break;
        case 30:map10[Row-1][Column-1]=0;break;
        case 31:map11[Row-1][Column-1]=0;break;
        case 32:map12[Row-1][Column-1]=0;break;
    }                                                         /**/
    Currentmap[Row-1][Column-1]=0;                            /**/
    showmap();
}



void attacked(int enemyattack)                               /*被攻击函数,给人物减生命值,并产生被攻击动画*/
{                                                            /**/
    int x=100,y=180,r=30,x2=500,y2=180,r2=30;                /*每次人物攻击敌人后会自动调用该函数*/
                                                             /*x,x2为人物和敌人头部圆心横坐标;y,y2为人物和敌人头部圆心纵坐标*/
    long i;                                                  /*r,r2为人物和敌人头部圆半径*/
                                                             /**/
    HP-=(enemyattack+random(40));    /*受到攻击时,人物生命值减少由敌人攻击力(enemyattack)而定,并加一定的随机*/
    for (i=0;i<49999999;i++)         /*延时*/
    {}                                                                                                                  /**/
    setfillstyle(1,1);               /*在一定区域清屏*/
    bar(0,120,639,479);
    circle(x,y,r);                   /*画左边的人物*/
    line(x,y+r,x,y+r+120);
    line(x,y+r+120,x-100,y+r+120+60);
    line(x,y+r+120,x+50,y+r+120+30);
    line(x+50,y+r+120+30,x+25,y+r+120+60);
    line(x,y+r+20,x+100,y+r+20);
    line(x+100,y+r+15,x+100,y+r+20);
    line(x,y+r+30,x+80,y+r+30);
    line(x+80,y+r+25,x+80,y+r+30);
    circle(x2,y2,r2);                           /*画右边的人*/
    line(x2,y2+r2,x2,y2+r2+120);
    line(x2,y2+r2+120,x2+100,y2+r2+120+60);
    line(x2,y2+r2+120,x2-50,y2+r2+120+30);
    line(x2-50,y2+r2+120+30,x2-25,y2+r2+120+60);
    line(x2,y2+r2+20,x2-50,y2+r2+20);
    line(x2-20,y2+r2+15,x2-20,y2+r2+25);
    for (i=0;i<59999999;i++)                     /*延时*/
    {}
    setfillstyle(1,1);                           /*在一定区域清屏*/
    bar(0,120,639,479);
    circle(x,y,r);
    line(x,y+r,x,y+r+120);                     /* 左边的人物*/
    line(x,y+r+120,x-100,y+r+120+60);
    line(x,y+r+120,x+50,y+r+120+30);
    line(x+50,y+r+120+30,x+25,y+r+120+60);
    line(x,y+r+20,x+100,y+r+20);
    line(x+100,y+r+15,x+100,y+r+20);
    line(x,y+r+30,x+80,y+r+30);
    line(x+80,y+r+25,x+80,y+r+30);
    line(20,150,200,400);
    circle(x2,y2,r2);                           /*右边的人*/
    line(x2,y2+r2,x2,y2+r2+120);
    line(x2,y2+r2+120,x2+100,y2+r2+120+60);
    line(x2,y2+r2+120,x2-50,y2+r2+120+30);
    line(x2-50,y2+r2+120+30,x2-25,y2+r2+120+60);
    line(x2,y2+r2+20,x2-100,y2+r2+20);
    line(x2-70,y2+r2+15,x2-70,y2+r2+25);
    for (i=0;i<109999999;i++)
    {}
    setfillstyle(1,1);
    bar(0,120,639,479);
    circle(x,y,r);
    line(x,y+r,x,y+r+120);                     /*左边的人物*/
    line(x,y+r+120,x-100,y+r+120+60);
    line(x,y+r+120,x+50,y+r+120+30);
    line(x+50,y+r+120+30,x+25,y+r+120+60);
    line(x,y+r+20,x+100,y+r+20);
    line(x+100,y+r+15,x+100,y+r+20);
    line(x,y+r+30,x+80,y+r+30);
    line(x+80,y+r+25,x+80,y+r+30);
    circle(x2,y2,r2);                           /*右边的人*/
    line(x2,y2+r2,x2,y2+r2+120);
    line(x2,y2+r2+120,x2+100,y2+r2+120+60);
    line(x2,y2+r2+120,x2-50,y2+r2+120+30);
    line(x2-50,y2+r2+120+30,x2-25,y2+r2+120+60);
    line(x2,y2+r2+20,x2-100,y2+r2+20);
    line(x2-70,y2+r2+15,x2-70,y2+r2+25);
}



void attack()                                                      /*攻击函数,给敌人减生命值,并产生攻击动画*/
{
    int x=100,y=180,r=30,x2=500,y2=180,r2=30;                      /*在菜单中选择attack后会调用该函数*/
    long i;                                                        /*x,x2为人物和敌人头部圆心横坐标;y,y2为人物和敌人头部圆心纵坐标*/
    Enemyhp-=100;      /*敌人生命值减 */                           /*r,r2为人物和敌人头部圆半径*/
    setfillstyle(1,1);                                             /**/
    bar(0,120,639,479);                                            /**/
    circle(x,y,r);                                                 /**/
    line(x,y+r,x,y+r+120);                  /*左边的人物*/
    line(x,y+r+120,x-100,y+r+120+60);                             /**/
    line(x,y+r+120,x+50,y+r+120+30);                              /**/
    line(x+50,y+r+120+30,x+25,y+r+120+60);                        /**/
    line(x,y+r+20,x+50,y+r+20);                                   /**/
    line(x+50,y+r+15,x+50,y+r+20);                                /**/
    line(x,y+r+30,x+100,y+r+30);                                  /**/
    line(x+100,y+r+25,x+100,y+r+30);                              /**/
    circle(x2,y2,r2);                           /*右边的人*/
    line(x2,y2+r2,x2,y2+r2+120);
    line(x2,y2+r2+120,x2+100,y2+r2+120+60);
    line(x2,y2+r2+120,x2-50,y2+r2+120+30);
    line(x2-50,y2+r2+120+30,x2-25,y2+r2+120+60);
    line(x2,y2+r2+20,x2-100,y2+r2+20);
    line(x2-70,y2+r2+15,x2-70,y2+r2+25);
    line(400,180,600,400);
    for (i=0;i<109999999;i++)  
    {}
    setfillstyle(1,1);
    bar(0,120,639,479);
    circle(x,y,r);
    line(x,y+r,x,y+r+120);               /* 左边的人物*/
    line(x,y+r+120,x-100,y+r+120+60);
    line(x,y+r+120,x+50,y+r+120+30);
    line(x+50,y+r+120+30,x+25,y+r+120+60);
    line(x,y+r+20,x+100,y+r+20);
    line(x+100,y+r+15,x+100,y+r+20);
    line(x,y+r+30,x+80,y+r+30);
    line(x+80,y+r+25,x+80,y+r+30);
    circle(x2,y2,r2);                       /*    右边的人*/
    line(x2,y2+r2,x2,y2+r2+120);
    line(x2,y2+r2+120,x2+100,y2+r2+120+60);
    line(x2,y2+r2+120,x2-50,y2+r2+120+30);
    line(x2-50,y2+r2+120+30,x2-25,y2+r2+120+60);
    line(x2,y2+r2+20,x2-100,y2+r2+20);
    line(x2-70,y2+r2+15,x2-70,y2+r2+25);
}



void magicattack()                                  /*魔法攻击函数,会消耗人物一定魔法值,敌人生命减少较大,产生攻击动画*/
{                                                   /*当在第二级菜单中选magicattack后会调用该函数*/
    int x=100,y=180,r=30,x2=500,y2=180,r2=30;       /*x,x2为人物和敌人头部圆心横坐标;y,y2为人物和敌人头部圆心纵坐标*/
    long i;                                         /*r,r2为人物和敌人头部圆半径*/
    MP-=100;       /*魔法攻击会消耗人物一定魔法值*/
    Enemyhp-=200;  /*敌人生命值会有较大减少*/
    setfillstyle(1,1);
    bar(0,120,639,479);
    circle(x,y,r);
    line(x,y+r,x,y+r+120);                  /*左边的人物*/
    line(x,y+r+120,x-100,y+r+120+60);
    line(x,y+r+120,x+50,y+r+120+30);
    line(x+50,y+r+120+30,x+25,y+r+120+60);
    line(x,y+r+20,x+50,y+r+20);
    line(x+50,y+r+15,x+50,y+r+20);
    line(x,y+r+30,x+100,y+r+30);
    line(x+100,y+r+25,x+100,y+r+30);
    circle(x2,y2,r2);                           /*右边的人*/
    line(x2,y2+r2,x2,y2+r2+120);
    line(x2,y2+r2+120,x2+100,y2+r2+120+60);
    line(x2,y2+r2+120,x2-50,y2+r2+120+30);
    line(x2-50,y2+r2+120+30,x2-25,y2+r2+120+60);
    line(x2,y2+r2+20,x2-100,y2+r2+20);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -