nanomedo 0 Newbie Poster

I need a solution to this problem
The idea of the project is about to draw a small village where we can change the weather by using (swich) function>>
The problem is that when I Write a function to draw a rain was the raindrops scans colors that appear above
And when I put a (cleardevice()) function to solve this problem >>started a new problem flash makes the painting appear and disappear quickly
I need a solution for the problem of clear colors or to remove flashing
Please help me
If there are suggestions for improving the project, I hope that you tell me about

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<STDLIB.H>
#include<dos.h>
void main()
{

int gdriver=DETECT,gmode,errorcode;

initgraph(&gdriver,&gmode,"..\\bgi");
setbkcolor(9);
int x,y,x1,y1;
//while(kbhit()==0 ){
for(int i=0;i<=500;i++){
if (kbhit())
exit(1);
x= random(640);y=random(300) ; x1= random(640); y1=random(300) ;
//if(kbhit())
//break;

   // cleardevice();






  setcolor(15);
//home four
moveto(550,450);
lineto(600,430);
moveto(550,450);
lineto(550,400);
moveto(600,430);
lineto(600,380);
lineto(550,400);
lineto(565,350);
lineto(600,380);
moveto(550,450);
lineto(490,434);
moveto(490,434);
lineto(490,390);
lineto(550,400);
moveto(490,390);
lineto(512,346);
lineto(565,350);
moveto(600,430);
lineto(625,419);
moveto(625,419);
lineto(625,390);
lineto(600,399);
lineto(610,375);
lineto(625,390);
moveto(610,375);
lineto(587,368);
setfillstyle(5,4);
floodfill(500,390,15);
setfillstyle(1,6);
floodfill(500,420,15);
setfillstyle(2,4);
floodfill(610,390,15);
setfillstyle(1,6);
floodfill(580,390,15);
setfillstyle(1,6);
floodfill(610,420,15);
setfillstyle(2,4);
floodfill(580,370,15);

setcolor(15);
//windo one home four
moveto(566,427);
lineto(585,419);
moveto(585,419);
lineto(585,404);
moveto(585,404);
lineto(566,411);
moveto(566,411);
lineto(566,427);
setfillstyle(4,14);
floodfill(579,410,15);
moveto(575,407);
lineto(577,423);
moveto(585,411);
lineto(566,419);
setcolor(15);
//windo tow home four
moveto(510,427);
lineto(530,431);
lineto(530,415);
lineto(510,411);
lineto(510,427);
setfillstyle(4,15);
floodfill(529,430,15);
moveto(519,412);
lineto(519,428);
moveto(530,423);
lineto(510,419);



//door

moveto(560,235);
lineto(560,209);
moveto(560,208);
lineto(575,202);
moveto(575,229);
lineto(575,203);

 //sdoor
moveto(605,216);
lineto(605,195);
moveto(620,212);
lineto(620,189);
moveto(620,189);
lineto(605,195);
/************************/
//home one
setcolor(15);
moveto(30,360);
lineto(80,340);
moveto(30,360);
lineto(30,310);
moveto(80,340);
lineto(80,290);
lineto(30,310);
lineto(45,260);
lineto(80,290);
moveto(30,360);
lineto(-30,344);
moveto(-30,344);
lineto(-30,300);
lineto(30,310);
moveto(-30,300);
lineto(-8,256);
lineto(45,260);
moveto(80,340);
lineto(105,329);
moveto(105,329);
lineto(105,300);
lineto(80,309);
lineto(90,285);
lineto(105,300);
moveto(90,285);
lineto(67,278);
setfillstyle(1,5);
floodfill(59,300,15);
setfillstyle(2,4);
floodfill(40,300,15);
setfillstyle(1,5);
floodfill(0,350,15);
setfillstyle(5,4);
floodfill(0,300,15);
setfillstyle(2,4);
floodfill(95,300,15);
setfillstyle(1,5);
floodfill(95,320,15);


//windo one
setcolor(15);
moveto(-13,318);
lineto(8,320);
lineto(8,342);
lineto(-15,338);
lineto(-15,318);
moveto(8,330);
lineto(-15,328);
//windo tow

moveto(60,334);
lineto(75,326);
moveto(75,326);
lineto(75,310);
moveto(75,310);
lineto(60,318);
moveto(60,318);
lineto(60,334);
setfillstyle(4,8);
floodfill(67,320,15);
moveto(68,315);
lineto(68,330);
moveto(75,320);
lineto(60,326);
          //d
          moveto(40,354);
          lineto(40,326);
          lineto(53,321);
          lineto(53,349);
          lineto(40,354);
          setfillstyle(9,6);
floodfill(50,325,15);
          //sd
          moveto(85,338);
          lineto(85,316);
          lineto(100,310);
          lineto(100,330);
          lineto(85,338);
setfillstyle(9,6);
floodfill(89,325,15);
 setcolor(15);        /*************************/
//home three
moveto(330,480);
lineto(380,460);
moveto(330,480);
lineto(330,430);
moveto(380,460);
lineto(380,410);
lineto(330,430);
lineto(345,380);
lineto(380,410);
moveto(330,480);
lineto(270,464);
lineto(270,420);
lineto(330,430);
moveto(270,420);
lineto(292,376);
lineto(345,380);
moveto(380,460);
lineto(405,449);
lineto(405,420);
lineto(380,429);
lineto(390,405);
lineto(405,420);
moveto(390,405);
lineto(367,398);
setfillstyle(2,12);
floodfill(350,415,15);
setfillstyle(5,12);
floodfill(330,415,15);
setfillstyle(1,10);
floodfill(350,435,15);
setfillstyle(1,10);
floodfill(310,430,15);
setfillstyle(1,10);
floodfill(390,435,15);
setfillstyle(2,12);
floodfill(390,415,15);

//windo one home three

moveto(290,457);
lineto(310,461);
moveto(310,461);
lineto(310,445);
moveto(310,445);
lineto(290,441);
moveto(290,441);
lineto(290,457);
setfillstyle(4,2);
floodfill(300,455,15);
moveto(299,442);
lineto(299,458);
moveto(310,453);
lineto(290,449);

//windo tow home three
moveto(343,459);
lineto(363,451);
moveto(363,451);
lineto(363,435);
moveto(363,435);
lineto(343,443);
moveto(343,443);
lineto(343,459);
setfillstyle(4,2);
floodfill(355,445,15);
moveto(353,439);
lineto(353,454);
moveto(363,444);
lineto(343,451);

/*******************************/
//home tow
moveto(550,240);
lineto(600,220);
moveto(550,240);
lineto(550,190);
moveto(600,220);
lineto(600,170);
lineto(550,190);
lineto(565,140);
lineto(600,170);
moveto(550,240);
lineto(490,224);
moveto(490,224);
lineto(490,180);
lineto(550,190);
moveto(490,180);
lineto(512,136);
lineto(565,140);
moveto(600,220);
lineto(625,209);
moveto(625,209);
lineto(625,180);
lineto(600,189);
lineto(610,165);
lineto(625,180);
moveto(610,165);
lineto(587,158);
setfillstyle(9,14);
floodfill(585,205,15);
setfillstyle(9,14);
floodfill(530,225,15);
setfillstyle(2,13);
floodfill(570,175,15);
setfillstyle(5,13);
floodfill(530,176,15);
setfillstyle(6,2);
floodfill(570,225,15);
//windo
moveto(506,219);
lineto(525,223);
moveto(525,223);
lineto(525,204);
moveto(525,204);
lineto(506,201);
lineto(506,219);
setfillstyle(4,11);
floodfill(510,215,15);
moveto(516,204);
lineto(516,222);
moveto(525,214);
lineto(506,211);
//windo
moveto(579,216);
lineto(593,210);
moveto(593,210);
lineto(593,192);
lineto(579,198);
lineto(579,216);
setfillstyle(3,11);
floodfill(580,205,15);
moveto(586,196);
lineto(586,213);
moveto(593,201);
lineto(579,209);
        setcolor(15);
//rode
//rectangle(320,250,600,255);
line(620,242,100,360);
line(620,240,100,358);
line(60,370,0,385);
line(60,372,0,387);
line(230,380,0,445);
line(230,382,0,443);

line(60,370,100,420);

line(1,395,5,440);

line(290,370,290,315);

line(600,242,630,283);

line(285,390,260,430);

line(30,360,70,345);

line(620,242,580,233);



line(270,370,400,343);

line(270,372,400,345);
line(440,336,640,280);
line(440,338,640,282);
line(230,380,270,440);
line(230,382,270,440);
line(270,370,285,390);
line(270,372,285,390);
line(400,343,490,425);
line(400,345,490,427);
line(440,336,492,384);
line(440,338,492,386);
line(100,360,60,349);
line(100,358,60,347);
line(60,370,30,360);
line(60,372,30,362);
setfillstyle(1,7);
floodfill(270,385,15);
setfillstyle(1,7);
floodfill(500,300,15);
setfillstyle(1,7);
floodfill(65,385,15);


putpixel(x,y,15);
putpixel(x,y+1,15);
putpixel(x,y+2,15);
putpixel(x,y+3,15);

putpixel(x1,y1,15);
putpixel(x1,y1+1,15);
putpixel(x1,y1+2,15);
putpixel(x1,y1+3,15);


delay(80);
if(y<=320  ){
putpixel(x,y,0);
putpixel(x,y+1,0);
putpixel(x,y+2,0);
putpixel(x,y+3,0);   }
if(y1<=320){
putpixel(x1,y1,0);
putpixel(x1,y1+1,0);
putpixel(x1,y1+2,0);
putpixel(x1,y1+3,0);
            }  }
getch();

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.