久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

標(biāo)題: [原創(chuàng)]turbo C++編寫(xiě)模仿下雨的程序??? [打印本頁(yè)]

作者: res    時(shí)間: 2008-5-26 14:53
標(biāo)題: [原創(chuàng)]turbo C++編寫(xiě)模仿下雨的程序???
請(qǐng)教大家一個(gè)問(wèn)題 :誰(shuí)知道用turbo C++編一個(gè)模仿下雨的程序,本人急需用,謝謝大家?guī)蛶兔?
作者: a13758777532    時(shí)間: 2008-7-17 17:54
在納哪用啊
作者: yangyi153    時(shí)間: 2008-9-10 10:29
唉我們貌似也要用

作者: iamcrr2006    時(shí)間: 2008-11-16 14:30
大哥  是下雪吧
作者: iamcrr2006    時(shí)間: 2008-11-16 14:33

#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>
#include <dos.h>

#define POINT 200
#define DOWNSPEED 5
#define MOVESIZE 1
#define SHOW 1
#define HIDE 0

typedef struct
{
 int x;
 int y;
 int size;
}SNOW;

SNOW Snow[POINT];
int MaxX,MaxY;
int MaxSize=3;
int SnowColor=15;
int Delay=15000;
int CurSnow=0;
int *Map;

/********************************** Init_Graph *****************************/
void Init_Graph(){
 int gdriver=DETECT,gmode,errorcode;
 initgraph(&gdriver, &gmode, "G:\\turboc2\\");
 errorcode = graphresult();
 if (errorcode != grOk) /* an error occurred */
 {
  printf("Graphics error: %s\n", grapherrormsg(errorcode));
  printf("Press any key to halt:");
  getch();
  exit(1); /*terminate with an error code */
 }
 MaxX=getmaxx();
 MaxY=getmaxy();

 Map=(int *) malloc( sizeof(int)*MaxX );
}
/******************************** MakeSnow ********************************/
void MakeSnow()
{
 int i;
 if( CurSnow>=POINT ) return;
 for( i=0; Snow.size; i++ )
  ;
 CurSnow++;
 Snow.x=random(MaxX);
 Snow.y=random(DOWNSPEED);
 Snow.size=random(MaxSize)+1;
 
}
/******************************** Init_Data *******************************/
void Init_Data()
{
 int i;
 for( i=0; i< POINT; i++)
 {
  Snow.x=0;
  Snow.y=0;
  Snow.size=0;
 }
 for( i=0; i<MaxX; i++)
  Map=MaxY;
}
/********************************* Init **********************************/
void Init()
{
 Init_Graph();
 Init_Data();
 randomize();
 MakeSnow();
}
/******************************** GetKey ********************************/
void GetKey(int *ah,int *al){
 union REGS r;
 r.h.ah=0;
 int86(0x16,&r,&r);
 /*return r.h.al;*/
 *ah=r.h.ah;
 *al=r.h.al;
}
/********************************* SetSnow ******************************/
void ShowSnow( int x, int y, int size, int flag )
{
 int color=0;

 if ( flag ) color=15;
 switch( size )
 {
 case 1:
  putpixel( x, y, color );
  break;
 case 2:
  setcolor( color );
  line( x-1, y-1, x+1, y+1 );
  line( x-1, y+1, x+1, y-1 );
  break;
 case 3:
  setcolor( color );
  line( x-1, y-1, x+1, y+1 );
  line( x-1, y+1, x+1, y-1 );
  /*
  line( x-2, y-2, x+2, y+2 );
  line( x-2, y+2, x+2, y-2 );*/

  line( x-2, y, x+2, y );
  line( x, y-2, x, y+2 );
  break;
 }

}
/********************************* Check ********************************/
void Move( int n, int tox, int toy )
{
 int x, y, size, i, j;
 float person;

 x=Snow[n].x;
 y=Snow[n].y;
 size=Snow[n].size;
 /* check end */
 j=y;
 if( x<tox )
 {
  person=(DOWNSPEED *1.0) / ( tox-x )*1.0;
  for( i=x; i<=tox; i++ )
  {
   if( j>=Map )
   {
    tox=i-size;
    break;
   }
   j+=(int)( (i-x+1)*person );
  }
 }
 else if( x>tox )
 {
  person=(DOWNSPEED *1.0) / ( x-tox )*1.0;
  for( i=x; i>=tox; i-- )
  {
   if( j>=Map )
   {
    tox=i+size;
    break;
   }
   j+=(int)( (x-i+1)*person );
  }
 }
 
 if( y+DOWNSPEED>=Map[tox] )
 {
  switch( size )
  {
  case 1:
   Map[x]--;
   break;
  case 2:
   Map[x]-=2;
   if( x>0 && Map[x-1]>Map[x] ) Map[x-1]=Map[x];
   if( x<MaxX-1 && Map[x+1]>Map[x] ) Map[x+1]=Map[x];
   break;
  case 3:
   Map[x]-=3;
   if( x>1 && Map[x-2]>Map[x] ) Map[x-1]=Map[x];
   if( x>0 && Map[x-1]>Map[x] ) Map[x-1]=Map[x];

   if( x<MaxX-2 && Map[x+2]>Map[x] ) Map[x+1]=Map[x];
   if( x<MaxX-1 && Map[x+1]>Map[x] ) Map[x+1]=Map[x];
   break;
  }
  CurSnow--;
  y=Map[x]+size;
  Snow[n].x=x;
  Snow[n].y=y;
  Snow[n].size=0;
 }
 else /* not end */
 {
  Snow[n].x=tox;
  Snow[n].y=toy;
 }
}
/******************************** snow **********************************/
void Begin()
{
 int ah,al;
 int i,dir,

文章出處:http://www.diybl.com/course/3_program/c/c_js/2008224/100864.html






歡迎光臨 (http://www.zg4o1577.cn/bbs/) Powered by Discuz! X3.1
主站蜘蛛池模板: 久久麻豆精品 | 精品入口麻豆88视频 | 久久久久久久国产精品视频 | 日韩欧美一区二区三区免费观看 | 免费黄色大片 | 久久久久成人精品 | www.一区二区 | 国产一区三区在线 | 亚洲免费在线 | 久久国产精品99久久久大便 | 日本一区二区三区在线观看 | 在线视频国产一区 | 一区二区三区视频播放 | 久久国产精品精品国产色婷婷 | 国产精品视频一 | 亚洲成人动漫在线观看 | 精品久久久久久久久久久院品网 | 日本免费在线看 | 久久国色 | 亚洲精彩免费视频 | 性高朝久久久久久久3小时 av一区二区三区四区 | 国产精品久久久久久久久久免费 | 日韩欧美亚洲 | 韩日一区二区 | 久久精品久久精品 | 粉色午夜视频 | 久久爆操| 成人av片在线观看 | 免费视频99| 国产一区亚洲二区三区 | 户外露出一区二区三区 | 中文字幕久久精品 | 中文字幕精品一区 | 亚洲精品一区二区在线观看 | 免费久久网站 | 成人免费观看男女羞羞视频 | 国产伦一区二区三区四区 | 日韩精品一区二区三区视频播放 | 国产一区三区在线 | 一区二区三区四区五区在线视频 | 嫩草懂你的影院入口 |