| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 426 人关注过本帖
标题:池塘夜降彩色雨 出现了问题 求解决啊>.<
只看楼主 加入收藏
张小溪
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-12-13
收藏
 问题点数:0 回复次数:0 
池塘夜降彩色雨 出现了问题 求解决啊>.<
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <dos.h>
#include <graphics.h>
#define LEN sizeof(struct rainDrop)
int rainDropNumber;
int downDelay;
struct rainDrop *head;
struct rainCircle
{
       int x;
       int y;
       int r;
       int curR;
       int rainCircleStep;
};
struct rainDrop
{
       int startX;
       int startY;
       int endY;
       int curX;
       int curY;
       int rainColor;
       int rainLineStep;
       int rainLineLength;
       int status;
       struct rainCircle water;
       struct rainDrop *next;
};
void initgraphics(void)
{
       int gmode,gdriver;
       gdriver=DETECT;
       initgraph(&gdriver,&gmode,"");
}

struct rainDrop *creatDrop(void)
{
       struct rainDrop *p;
       p=(struct rainDrop *)malloc(LEN);
       p->startX=rand()%640;
       p->startY=rand()%430;
       p->endY=430+rand()%50;
       p->curX=p->startX;
       p->curY=p->startY;
       p->rainLineStep=8;
       p->rainColor=rand()%15+1;
       p->rainLineLength=rand()%10+10;
       p->status=0;
       p->water.x=p->startX;
       p->water.y=p->endY;
       p->water.r=rand()%40;
       p->water.curR=rand()%2;
       p->water.rainCircleStep=rand()%2+1;
       p->next=NULL;
       return(p);
}
void recreatDrop(struct rainDrop *p)
{
       p->startX=rand()%640;
       p->startY=rand()%430;
       p->endY=430+rand()%50;
       p->curX=p->startX;
       p->curY=p->startY;
       p->rainLineStep=8;
       p->rainColor=rand()%15+1;
       p->rainLineLength=rand()%10+10;
       p->status=0;
       p->water.x=p->startX;
       p->water.y=p->endY;
       p->water.r=rand()%40;
       p->water.curR=rand()%2;
       p->water.rainCircleStep=rand()%2+1;
}

void creatRain(void)
{
       struct rainDrop *p1,*p2;
       int i;
       p1=p2=creatDrop();
       head=p1;
       for(i=0;i<rainDropNumber;i++)
       {
               p2=creatDrop();
               p1->next=p2;
       p1=p2;
       }
}

void updateRainLineData(struct rainDrop *p)
{
       if(p->rainLineStep%5==0)
               p->rainLineStep++;
       p->curY+=p->rainLineStep;
         p->startY=p->curY-p->rainLineLength;
}
void drawRainLine(struct rainDrop *p)
{
       setcolor(p->rainColor);
       line(p->startX,p->startY,p->curX,p->curY);
}
void clearRainLine(struct rainDrop *p)
{
       setcolor(BLACK);
       line(p->startX,p->startY,p->curX,p->curY);
}

void rainDropDown(struct rainDrop *p)
{
       if(p->curY>=p->endY)
       {
               clearRainLine(p);
               p->status=1;
       }
       else
       {
               clearRainLine(p);
               updateRainLineData(p);
               drawRainLine(p);
       }
}
void updateRainCircleData(struct rainDrop *p)
{
       p->water.curR+=p->water.rainCircleStep;
}

void drawRainCircle(struct rainDrop *p)
{
       setcolor(p->rainColor);
       circle(p->water.x,p->water.y,p->water.curR);
}

void clearRainCircle(struct rainDrop *p)
{
       setcolor(BLACK);
       circle(p->water.x,p->water.y,p->water.curR);
}

void fallToWater(struct rainDrop *p)
{
       if(p->water.curR>=p->water.r)
       {
               clearRainCircle(p);
               recreatDrop(p);
       }
       else
       {
               clearRainCircle(p);
               updateRainCircleData(p);
               drawRainCircle(p);
       }
}
void rain(void)
{
       struct rainDrop *p;
       p=head;
       while(!kbhit())
       {
               if(p==NULL)
               p=head;
       else
       {
                       if(p->status==0)
                       rainDropDown(p);
       else
                       fallToWater(p);
       }
delay(downDelay);
               p=p->next;
       }
}
void clearAll(void)
{
       struct rainDrop *p,*pf;
       p=head;
       while(p!=NULL)
       {
       pf=p;
               p=p->next;
               free(pf);
       }
       closegraph();
}
main()
{
       printf("Input rainDrop Number:(<300)");
       scanf("%d",&rainDropNumber);
printf("Input down Delay:(<50)");
scanf("%d",&downDelay);
       randomize();
       initgraphics();
       creatRain();
       rain();
       clearAll();
}




总是说 DETECT那里出现了问题 哪位大神能不能帮忙修改下下了~拜托啦 谢谢
搜索更多相关主题的帖子: head include 
2012-12-15 18:59
快速回复:池塘夜降彩色雨 出现了问题 求解决啊>.<
数据加载中...
 
   



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

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