您的位置 首页 硬件

用链表完成的屏幕飘雪程序

includewindowsh>includestdlibh>includetimeh>defineD1雪花下降速度COLORREFsnowcolor=0x2711EE;雪花颜色C

#include
#include
#include
#define D 1 //雪花下降速度
COLORREF snowcolor=0x2711EE; //雪花色彩
COLORREF snowcolor1=0x0000FF; //积雪色彩
int FENG; //风向风速值
int MINX; //屏幕X坐标最大值
int MINY; //屏幕Y坐标最大值
////////////////////////////////////////////////////////////////////////////////
//获取屏幕分辨率
int getXY(int *MINX,int *MINY)
{
HDC hdc=GetDC(NULL);
int t=1;
int x=600;
int y=600;
for(;t;)
{
if(GetPixel(hdc,x,100)==CLR_INVALID) t=0;
x++;
}
t=1;
for(;t;)
{
if(GetPixel(hdc,100,y)==CLR_INVALID) t=0;
y++;
}
*MINX=x;
*MINY=y;
ReleaseDC(NULL, hdc);
return 0;
}
//雪花点特点结构体
struct xue {
int x; //雪花的当时坐标点
int y;
COLORREF oldcolor; //当时雪花点的原始色彩值
int del; //是否删去该节点标志值不等于0则删去此节点
int nextx; //即将移动到的坐标点
int nexty;
int shudu; //下降速度
};
//雪花布局链表规范节点
struct xhbiao { //此结构体用于创立雪花的布局链表
struct xue xh;
struct xhbiao *next; //后继
struct xhbiao *quet; //前驱
};
//初始化单点雪花
int huaxue (struct xue *xuehua) //函数功用是初始化一个新的雪花点
{
HDC hdc=GetDC(NULL);
xuehua->y=0;
xuehua->x=(int)(rand()%MINX);
xuehua->oldcolor=GetPixel(hdc,xuehua->x,xuehua->y);
xuehua->shudu=(int)((rand()%10)*D+1);
xuehua->del=0;
ReleaseDC(NULL,hdc);
return 0;
}
//创立链表
int link(struct xhbiao **tou,struct xhbiao **wei)
{
struct xhbiao *p;
p=(struct xhbiao*)malloc(sizeof(struct xhbiao));
huaxue(&p->xh);
p->next=NULL;
p->quet=NULL;
(*tou)=p;
(*wei)=p;
return 0;
}
//刺进节点
int linkCHA(struct xhbiao **tou,struct xhbiao **wei)
{
if((*tou)!=NULL)
{
struct xhbiao *p;
p=(struct xhbiao*)malloc(sizeof(struct xhbiao));
huaxue(&p->xh);
p->next=NULL;
p->quet=(*wei);
(*wei)->next=p;
(*wei)=p;
}
return 0;
}
//删去节点
int linkDEL(struct xhbiao *del)
{
del->quet->next=del->next;
del->next->quet=del->quet;
free(del);
return 0;
}
//保护雪堆链表铲除需求删去的雪粒节点
int linkWUI(struct xhbiao **tou,struct xhbiao **wei)
{
struct xhbiao *p;
p=(*tou);
for(;p!=NULL;)
{

if(p->xh.del!=0)
{
if(p==(*tou))
{
(*tou)=p->next;
p->next->quet=NULL;
free(p);
}else if(p==(*wei))
{
(*wei)=p->quet;
p->quet->next=NULL;
free(p);
}else {
linkDEL(p);
}
}
p=p->next;
}
return 0;
}
//物理信息处理

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qianrushi/yingjian/317248.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部