收藏 分销(赏)

池塘夜降彩色雨代码数据结构专业课程设计.doc

上传人:w****g 文档编号:2533705 上传时间:2024-05-31 格式:DOC 页数:21 大小:40.54KB
下载 相关 举报
池塘夜降彩色雨代码数据结构专业课程设计.doc_第1页
第1页 / 共21页
池塘夜降彩色雨代码数据结构专业课程设计.doc_第2页
第2页 / 共21页
池塘夜降彩色雨代码数据结构专业课程设计.doc_第3页
第3页 / 共21页
池塘夜降彩色雨代码数据结构专业课程设计.doc_第4页
第4页 / 共21页
池塘夜降彩色雨代码数据结构专业课程设计.doc_第5页
第5页 / 共21页
点击查看更多>>
资源描述

1、/*包涵到头文献*/#include #include #include #include #include #include #include /*宏定义*/*键盘控制 键盘扫描码*/#define LEFT 0x4b00#define RIGHT 0x4d00#define DOWN 0x5000#define UP 0x4800#define ESC 0x011b#define L_SHEFT 0x01#define SPACE 0x3920#define LOWERF 0x2166#define UPPERF 0x2146#define LOWERA 0x1e61#define UPP

2、ERA 0x1e41#define LOWERQ 0x1071#define UPPERQ 0x1051#define ENTER 0x1c0d#define ONE 0x4f31#define TWO 0x5032#define THREE 0x5133#define FOUR 0x4b34#define FIVE 0x4c35#define SIX 0x4d36#define SEVEN 0x4737#define EIGHT 0x4838#define NINE 0x4939#define O 0x5230#define PLUS 0x4e2b#define JIAN 0x4a2d /*

3、全局变量*/int rain_Num;int rain_v;int rain_wind;int rain_len;int key;int big;int m;int curx;int cury;int thunder62=10,20,-10,0,10,20,-25,-25,15,0,0,-15;/*定义构造*/struct rainDrop *head;/*雨滴 雨圈 雷电数据 构造体链表*/struct rainDrop int startX,curX,startY,curY; int flag; int endX; int endY; int rainColor; int status;

4、int flagR; int curR; int thunderX1,thunderX2,thunderY1,thunderY2; int a,b; struct rainDrop *next;/*初始化画布*/*参数void*/*return无*/void initgraphics(void) int gmode,gdriver; gdriver=DETECT; initgraph(&gdriver,&gmode,);/*创立初始化头结点*/*返回指针p*/struct rainDrop *creatDrop(void) struct rainDrop *p; p=(struct rainD

5、rop *)malloc(sizeof(struct rainDrop); p-startX=random(640); p-startY=random(430); p-flag=430+rand()%50; p-curX=p-startX-(rain_wind*5); p-curY=p-startY+rain_len; p-rainColor=random(15); p-status=0; p-flagR=random(10); p-curR=random(2); p-thunderX1=random(300); p-thunderY1=random(20); p-next=NULL; ret

6、urn(p);/*重新生成链表数据*/void recreatDrop(struct rainDrop *p) p-startX=random(640); p-startY=random(430); p-flag=430+rand()%50; p-curX=p-startX-(rain_wind*5); p-curY=p-startY+rain_len; p-rainColor=random(15); p-status=0; p-flagR=random(10); p-curR=random(3);/*创立整个链表*/void creatRain(void) struct rainDrop *

7、p1,*p2;/*定义两个指针*/ int i; p1=p2=creatDrop(); head=p1;/*赋值头指针*/ for(i=0;inext=p2; p1=p2; /*生成下一种雨滴 坐标位置*/void updateRainLineData(struct rainDrop *p)if(big=2)/*加速为2个雨滴距离下落*/ p-startX=p-curX; p-startY=p-curY; p-curX=p-startX-(rain_wind*5); p-curY=p-startY+rain_len; p-startX=p-curX; p-startY=p-curY; p-cu

8、rX=p-startX-(rain_wind*5); p-curY=p-startY+rain_len; p-startX=p-curX; p-startY=p-curY;if(big=1)/*加速为一种雨滴距离下落*/ p-startX=p-curX; p-startY=p-curY; p-curX=p-startX-(rain_wind*5); p-curY=p-startY+rain_len; p-startX=p-curX; p-startY=p-curY;else /*正常速度下落*/p-startX=p-curX; p-startY=p-curY;p-curX=p-startX-(

9、rain_wind*5); p-curY=p-startY+rain_len;/*雨雪选取函数*/selectWinter() m=1;selectSumm() m=6;/*分屏函数*/splitScreen(struct rainDrop *p)curx=p-curX/200;cury=p-curY/110;switch(curx) case 0: switch(cury) case 0: case 1:selectSumm();break; case 2:selectWinter();break; case 3:selectSumm();break; break; case 1: swit

10、ch(cury) case 0: case 1:selectWinter();break; case 2:selectSumm();break; case 3:selectWinter();break; break; case 2: switch(cury) case 0: case 1:selectSumm();break; case 2:selectWinter();break; case 3:selectSumm();break; break; case 3: switch(cury) case 0: case 1:selectWinter();break; case 2:selectS

11、umm();break; case 3:selectWinter();break; break;/*画出彩色雨滴*/void drawRainLine(struct rainDrop *p,int m) setcolor(p-rainColor);/*将雨滴赋予颜色*/ if (m=3&mstartX,p-startY,p-curX,p-curY);/*画雨滴*/ else /*雪*/ setcolor(WHITE); setfillpattern(2,WHITE); sector(p-curX,p-curY,0,360,5,4); /*清除上一滴雨滴*/void clearRainLine(

12、struct rainDrop *p,int m) setcolor(BLACK);/*将雨滴赋予黑色*/ if (m=3&mstartX,p-startY,p-curX,p-curY); else setfillpattern(2,BLACK); sector(p-curX,p-curY,0,360,5,4); /*雨滴入数声音*/getsound()int freq;for(freq=300;freq5000;freq+=50)sound (freq);delay(400);nosound();/*雷电声音*/thunderesound()int freq;for(freq=1000;fr

13、eqcurY=p-flag) clearRainLine(p,m); p-status=1; getsound(); else clearRainLine(p,m); updateRainLineData(p); drawRainLine(p,m); /*雨圈生长变大*/void updateRainCircleData(struct rainDrop *p)p-curR+=1;/*画出雨圈*/void drawRainCircle(struct rainDrop *p)setcolor(p-rainColor);ellipse(p-curX,p-curY,0,360,10+p-curR*3,

14、p-curR);/*清理雨圈*/void clearRainCircle(struct rainDrop *p)setcolor(BLACK);setfillpattern(2,BLUE);sector(p-curX,p-curY,0,360,10+p-curR*3,p-curR);/*入水 水圈生成结束重新刷新雨点*/void fallToWater(struct rainDrop *p)if(p-curR=p-flagR) clearRainCircle(p); recreatDrop(p); else clearRainCircle(p); updateRainCircleData(p)

15、; drawRainCircle(p); /*画出雷电 */int drawthurder(struct rainDrop *p) int i,j,k,x,y; setbkcolor(BLACK);p-thunderX1=random(300); p-thunderY1=random(20); setcolor(WHITE); for(k=0;kthunderX1+=x; p-thunderY1+=y; p-a=p-thunderX1; p-b=p-thunderY1; for(i=0;i6;i+) for(j=0;jthunderX2=p-thunderX1-thunderij; j+; p

16、-thunderY2=p-thunderY1+thunderij; line(p-thunderX1,p-thunderY1,p-thunderX2,p-thunderY2); p-thunderX1=p-thunderX2;p-thunderY1=p-thunderY2; floodfill(p-a-3,p-b+12,WHITE); setfillpattern(0,0); bar(p-a-20,p-b-10,p-a+40,p-b+40); /* 函数实现释放链表收起画布 */void rainfree(void) char mark;struct rainDrop *p,*q;p=head

17、;while(p!=NULL)q=p; p=p-next; free(q); closegraph();/*键盘控制*/keyboardCon(struct rainDrop *p)key=bioskey(0); if(key=LEFT) rain_wind+=1;if(key=TWO) m=1; if(key=RIGHT) rain_wind-=1; if(key=DOWN) rain_len-=1; if(key=UP) rain_len+=1; if(key=SPACE) rainfree(); exit(0); if(key=PLUS&bigstatus=0) rainDropDown

18、(p,m); else fallToWater(p); delay(rain_v); output(); if(key=ENTER) drawthurder(p); drawthurder(p); thunderesound(); key=NULL; p=p-next; /*软件开始简介*/void Introduction()printf(*n); printf(*n); printf(Pond night rain fall color!n);printf(tclass:09060641n); printf(*n); printf(*n);/*过滤函数*/filter()int i;i=0

19、;while(i=6)if(rain_Num50)printf(errornNote Please enter less than fifty greater than zeronrain_num:); scanf(%d,&rain_Num);elsei+=1;if(rain_v10)printf(errornNote Please enter less than fifty greater than zeronrain_v:); scanf(%d,&rain_v);elsei+=1;if(rain_len50)printf(errornNote Please enter less than

20、ten greater than zeronrain_len:); scanf(%d,&rain_len);elsei+=1;if(rain_wind10)printf(errornNote Please enter less than ten greater than zeronrain_wind:); scanf(%d,&rain_wind);elsei+=1;if(m10)printf(errornNote Please enter less than 12 greater than zeronmonth:); scanf(%d,&m);elsei+=1;/*全局变量输入及其鉴定*/vo

21、id input() printf(rain_num:nNote Please enter less than fifty greater than zero); scanf(%d,&rain_Num); printf(rain_v:nNote Please enter less than fifty greater than zero); scanf(%d,&rain_v); printf(rain_wind:nNote Please enter less than ten greater than zero); scanf(%d,&rain_wind); printf(rain_length:nNote Please enter less than fifty greater than zero); scanf(%d,&rain_len); printf(the month of the year:nNote Please enter less than 12 greater than 1); scanf(%d,&m); filter(); big=1;/*程序入口 主函数*/main() Introduction(); input(); initgraphics(); creatRain(); river(); rain(m);

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 学术论文 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服