标题:求大神帮忙解决错误
只看楼主
谢小白
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-4-7
结帖率:100%
已结贴  问题点数:20 回复次数:1 
求大神帮忙解决错误
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define N 35
#define up 72
#define left 75
#define right 77
void run();
void yn();
void print(int [][N]);
void movebul(int [][N]);
void movepla(int [][N]);
void setting(void);
void menu(void);
int scr[22][N]={0},pl=9,width=24,speed=3,density=30,score=0,death=0;
void main()
{
    menu();
    run();
}
void print(int a[][N])
{   
    system("cls");
    int i,j;
    for(i=0;i<22;i++)
    {
        a[i][width-1]=4;
        for(j=0;j<width;j++)
        {
            if(a[i][j]==0)printf(" ");
            if(a[i][j]==1)printf("\5");
            if(a[i][j]==2)printf("^");
            if(a[i][j]==3)printf("\3");
            if(a[i][j]==4)printf("\2");
            if(i==1&&j==width-1)printf("您成功杀敌:%d架",score);
            if(i==2&&j==width-1)printf("设置:Esc");
            if(i==4&&j==width-1)printf("您已经死亡了:%d次!",death);
            if(i==9&&j=width-1)printf("  您还剩余 %d 条命!",3-death);
            if(i==18&&j==width-1)printf("  制作人:谢小白");
            if(i==19&&j==width-1)printf("班级:软件一班");
            if(i==20&&j==width-1)printf("学号  :43");
        }
        printf("\n");
    }
}
void movebul(int a[][N])
{
    int i,j;
    for(i=0;i<22;i++)
        for(j=0;j<width;j++)
        {
            if(i==0&&a[i][j]==2)
                a[i][j]=0;
            if(a[i][j]==2)
            {
                if(a[i-1][j]==3)
                {
                score+=1;
                printf("\7");
                }
                a[i][j]=0,a[i-1][j]=2;
            }
        }
}
void movepla(int a[][N])
{
    int i,j;
    for(i=21;i>=0;i--)
        for(j=0;j<width;j++)
        {
            if(i==21&&a[i][j]==3)
                a[i][j]=0;
            if(a[i][j]=3)a[i][j]=0,a[i+1][j]=3;
        }
        if(a[20][pl]==3&&a[21][pl]==1)death++;
}
void yn()
{
    system("cls");
    system("color 2e");
    printf("\n");
    printf("\n");
    printf("\t\t\t*****GAME OVER*****\n\a");
    printf("\n");
    printf("\n");
    printf("\t\t     *****游***戏***结***束*****    \n\n\n");
    printf("\t\t\t按y键继续游戏,n键退出游戏(y/n)?\n");
    printf("\t\t\t");

    switch(getch())
    {
    case 'y':
    case 'Y':death=0,score=0,run();break;
    case 'n':
    case 'N':break;
    default:exit(0);break;
    }
}
void setting(void)
{
    int sw=0,i,j;
    system("cls");
    do
    {
        sw=0;
        printf("\n 游戏界面的大小:1.大2.小>>");
        switch(getche())
        {
        case'1':width=34;break;
        case'2':width=24;break;
        default:printf("\n 错误,请重新选择...\n");
            sw=1;
        }
    }
    while(sw);
    do
    {
        sw=0;
        printf("\n 请选择敌机密度:1.大2.中3.小>>");
        switch(getche())
        {
        case'0':density=10;break;
        case'1':density=20;break;
        case'3':density=30;break;
        default:printf("\n错误,请重新选择...\n");
            sw=1;
        }
    }
    while(sw);
    do
    {
        sw=0;
        printf("\n  敌机的飞行速度: 1.快2.中3.慢");
        switch(getche())
        {
        case'1':speed=2;break;
        case'2':speed=3;break;
        case'3':speed=4;break;
        default:printf("\n 错误,请重新选择...\n");
            sw=1;
        }
    }
    while(sw);
    for(i=0;i<22;i++)
        for(j=0;j<45;j++)
            scr[i][j]=0;
        scr[21][pl=9]=1;
        printf("\n  按任意键保存...");
        getch();
}
void run()
{
    system("color 2e");
    int i=0,j=0;
    scr[21][pl]=1;
    scr[0][5]=3;
    while(death<3)
    {
        if(kbhit())
            switch(getch())
        {
            case left:
            case 'a':
            case 'A':if(pl>0)
                         scr[21][pl]=0,scr[21][--pl]=1;break;
            case right:
            case 'd':
            case 'D':if(pl<width-2)
                         scr[21][pl]=0,scr[21][++pl]=1;break;
            case up:
            case 'W':
            case 27:exit(0);break;
        }
        if(++j%ddensity==0)
        {
            j=0;
            srand(time(NULL));
            scr[0][rand()%width]=3;
        }
        if(++i%spped==0)
            movepla(scr);
        movebul(scr);
        print(scr);
    }
    yn();
}
void menu(void)
{
    system("color 2e");
    printf("说明:按 N M 控制我机左右飞行,Z 发射子弹\n 设置:Esc\n 开始游戏 :任意键 ");
    if(getch()==27)setting();
}
搜索更多相关主题的帖子: include setting system death speed 
2016-04-07 18:48
zhulei1978
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
得分:20 
找到一个错误

 for(j=0;j<width;j++)
         {
             if(a[i][j]==0)printf(" ");
             if(a[i][j]==1)printf("\5");
             if(a[i][j]==2)printf("^");
             if(a[i][j]==3)printf("\3");
             if(a[i][j]==4)printf("\2");
             if(i==1&&j==width-1)printf("您成功杀敌:%d架",score);
             if(i==2&&j==width-1)printf("设置:Esc");
             if(i==4&&j==width-1)printf("您已经死亡了:%d次!",death);
             if(i==9&&j=width-1)printf("  您还剩余 %d 条命!",3-death);        if(i==9&&j==width-1)printf("  您还剩余 %d 条命!",3-death);      
             if(i==18&&j==width-1)printf("  制作人:谢小白");
             if(i==19&&j==width-1)printf("班级:软件一班");
             if(i==20&&j==width-1)printf("学号  :43");
         }

其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2016-04-07 20:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-463381-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.131640 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved