⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 雨滴.c

📁 C语言实现雨滴模拟
💻 C
字号:
#include "stdio.h"
#include "graphics.h"

void initgraphics()
{
    int gmode,gdriver;
    gdriver=DETECT;
    initgraph(&gdriver,&gmode,"");
}
void drawLine(int x,int y,int nx,int ny,int color){
	       setcolor(color);
		line(x,y,nx,ny);
	}
void clearLine(int x,int y,int nx,int ny){
	       setcolor(BLACK);
		line(x,y,nx,ny);
	}
void updateLine(int x,int y,int nx,int ny,int color,int step){
	        setcolor(color);
		 line(x,y+step,nx,ny+step);
	}
void clearAll()
{       
    closegraph();
}
void rainDropDown(int x,int y,int nx,int ny,int color,int step){
	            drawLine(x,y,nx,ny,color);
		     clearLine(x,y,nx,ny);
		     updateLine(x,y,nx,ny,color,step); 
			     
	}
main()
{
    int i;    
    initgraphics(); 
       while(!kbhit()){              
		    for(i=0;i<300;i++){    
			     
			    drawLine(130,i,130,50+i,RED);
                        
			    clearLine(130,i,130,50+i);
                       
			    updateLine(130,i,130,50+i,RED,1);  
			    delay(5000);
                     
                        rainDropDown(170,i,170,50+i,GREEN,1);
                        delay(5000);
			      
		    }  
		    setcolor(BLACK);
			clearLine(130,i,130,50+i);	     
			clearLine(170,i,170,50+i);
		}    
		     
	         
	        
		    
     
    getch();
    clearAll();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -