/*paisajes 1993*/ /*Fernando Galindo Soria*/ #include #include #include #include #include #include #include #include void dibuja(int,int,int,int,int); void dibuja1(int,int,double,int,int); void estrella(int,int,int,int,int); void mensaje(void); void rota(void); void rota1(void); int w0,w1,w2,color1,direcc=0,direccion=1,basearb,ibasearb; color[][16]={{2,3,15,2,3,2,3,3,2,10,2,10,2,2,4,4}, {15,15,15,15,15,14,10,2,2,2,2,2,2,4,4,4}, {7,8,-1,-1,-1,2,10,7,7,8,7,8,6,8,-1,-1}, {15,15,6,15,8,10,7,10,2,8,8,7,8,8,6}, {3,6,15,6,15,4,15,7,15,7,15,7,15,-1,-1,-1}, {-1,-1,-1,-1,-1,2,10,15,15,15,-1,-1,-1,-1-1,-1}, {10,14,10,2,2,10,2,6,15,15,15,15,15,15,15,15}}, lran,cran,co; double l0,l1,l2; char car; void main() { int gd=DETECT,gm,i,ncolor,ti_ar,ne=0,elijeco,ine,basex,indco; double nc=0; registerbgidriver(EGAVGA_driver); registerbgifont(sansserif_font); registerbgifont(small_font); initgraph(&gd,&gm,""); randomize(); i=rand(); i=random(random(397)); i=rand(); i=rand(); mensaje(); basearb=random(30); ibasearb=-5+random(11); while (car!=27) { if((ne==0)||(random(97)==2)) { if(car!=44){sound(557); delay(200); nosound();} delay(1000); cleardevice(); ne=-random(150); nc=0; setcolor(random(16)+1); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); if(random(2)==1) /*sol*/{ color1=3; w0=random(57)+1; estrella(random(getmaxx()),random(100),1,27,47);} else { while((random(300)!=137)&&(kbhit()==0))//estrellas putpixel(random(getmaxx()),random(280+ne),15);} } else if(random(2)==1) { indco=random(3); co=random(6)+1; while((random(150)!=127)&&(kbhit()==0)) { /*piedras*/ basex=random(getmaxx()); w0=25+random(27); w1=65+random(36); w2=87+random(36); l0=1.67;l1=1.7;l2=1.67; dibuja(basex+random(30),295+random(79)+ne,random(19)+6,147,15-indco); } while((random(3)!=1)&&(kbhit()==0)) { printf("\n\n\n\n\n\n\n\n\n\n\n\n"); /*piedras*/ basex=random(getmaxx()); w0=25+random(27); w1=65+random(36); w2=87+random(36); l0=1.67;l1=1.7;l2=1.67; dibuja(basex+random(30),295+random(79)+ne,random(19)+6,147,15-indco); } } while((random(5)!=3)&&(kbhit()==0))//nube { co=4; w0=70+random(27); w1=95+random(37); w2=127+random(37); l0=1.45;l1=1.45;l2=1.45; lran=random(10); cran=random(10); dibuja(random(getmaxx()),random(99)+ne/10,random(27)+10,73,15); } elijeco=random(2); while((random(20)!=17)&&(kbhit()==0)) { co=10+random(7); l0=1.2; l1=1.55; l2=1.8; if(co==10)/*monta¤a*/{ color1=1; w0=7; w1=172; w2=1 ; if(random(2)==1) co=2; dibuja(random(getmaxx()),275+random(69)+ne,10+random(53),167,15);} if(co==11)/*monta¤a*/{ color1=1; w0=6; w1=172; w2=186; if(elijeco==0)color1=15; dibuja(random(getmaxx()),279+random(69)+ne,30+random(33),-8,15);} if(co==15)/*monta¤a*/{ color1=15; w0=6; w1=172; w2=186;if(elijeco==1) co=2; dibuja(random(getmaxx()),279+random(69)+ne,20+random(43),-8,15);} if(co==12)/*monta¤a*/{ color1=15; w0=6; w1=172; w2=1 ;w0=172; if(elijeco==1) if(random(2)==1)co=2; else color1=1; dibuja(random(getmaxx()),279+random(69)+ne,10+random(53),11,15);} if(co==13)/*monta¤a*/{ color1=15; w0=6; w1=172; w2=1 ;w0=173; if(elijeco==1) if(random(2)==1)co=2; else color1=1; dibuja(random(getmaxx()),279+random(69)+ne,20+random(43),11,15);} co=2; w0=70+random(27); w1=95+random(36); w2=127+random(36); l0=1.75;l1=1.75;l2=1.45; lran=random(10); cran=random(10); dibuja(random(getmaxx()),265+random(79)+ne,random(21)+10,127,15); dibuja(random(getmaxx()),295+random(49)+ne,random(19)+10,127,15); } ti_ar=random(2); nc=0; ine=0; if(basearb>45)ibasearb=-random(6)-1; if(basearb<10)ibasearb=random(6)+1; basearb+=ibasearb; while((random(17-basearb/7)!=5)&&(ine<35)&&(kbhit()==0)) { nc+=0.30;ine++; if((ti_ar==0)&&(basearb<35)) //arbol { co=0; w0=-10-random(23); w1=0; w2=10+random(23); l0=1.41,l1=1.39;l2=1.41; lran=random(10); cran=random(10);i=10+(int)(nc); dibuja(random(getmaxx()),265+random(79)+ne,random(i)+basearb,90,15); } else { co=1; //pino w0=-random(39); w1=0; w2=-w0; l0=1.7;l1=1.2;l2=1.7; lran=random(10); cran=random(10);i=10+(int)(nc); dibuja(random(getmaxx()),265+random(79)+ne,random(i)+basearb,90,15); } } ne+=38+random(5); if(ne>=(getmaxy()-400)){ ne=getmaxy()-400; printf("\n\n"); indco=random(3); } co=-1; if (kbhit()){ car=getch();ne=0;} } outport(0x3d4,13); outport(0x3d5,0); closegraph(); } void mensaje() { setcolor(random(15)+1); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,7); outtextxy(12,30," P A I S A J E S"); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4); setcolor(random(15)+1); outtextxy(150,100,"Dibuja Paisajes"); setcolor(random(15)+1); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); outtextxy(50,200,"by fractalstic"); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); outtextxy(70,230,"Mexican Curious Technology"); outtextxy(70,320,"oprima la tecla ',' para quitar sonido "); outtextxy(70,350,"otra tecla para continuar"); setcolor(random(15)+1); settextstyle(SMALL_FONT,HORIZ_DIR,4); outtextxy(80,400,"Fernando Galindo Soria Cd. de Mexico"); outtextxy(80,410,"Se autoriza la distribucion y uso libre de este sistema (freeware)"); delay(1000); if(kbhit())car=getch(); } void rota() { if(random(20)==5)direccion=-direccion; direcc+=direccion; if(direcc>79)direcc=0; if(direcc<0)direcc=79; outport(0x3d4,13); outport(0x3d5,direcc); } void rota1() { outport(0x3d4,12); outport(0x3d5,1); } void dibuja(int x0,int y0,int l,int an,int ind) { int x1,y1,colorin; if(!kbhit)exit(1); if (l > 1) { if(co<7) colorin=color[co][ind]; else { colorin=color1; } if(x0>getmaxx())x0=0; if(x0<0)x0=getmaxx(); x1=x0-(l*cos(an/57.29578)); y1=y0-(l*sin(an/57.29578)); if(colorin>=0) { setcolor(colorin); line(x0,y0,x1,y1); } else moveto(x1,y1); dibuja(x1,y1,l/l0,an+w0,ind-1); dibuja(x1,y1,l/l1,an+w1,ind-1); dibuja(x1,y1,l/l2,an+w2,ind-1); if(random(8000)==17)rota(); } } void dibuja1(int x0,int y0,double l,int an,int ind) { int x1,y1,colorin; if(!kbhit)exit(1); if (l < 79) { if(co<7) colorin=color[co][ind]; else { colorin=color1; } if(x0>getmaxx())x0=0; if(x0<0)x0=getmaxx(); x1=x0-(l*cos(an/57.29578)); y1=y0-(l*sin(an/57.29578)); if(colorin>=0) { setcolor(colorin); line(x0,y0,x1,y1); } else moveto(x1,y1); dibuja1(x1,y1,l*l0,an+w0,ind-1); dibuja1(x1,y1,l*l1,an+w1,ind-1); dibuja1(x1,y1,l*l2,an+w2,ind-1); if(random(8000)==17)rota(); } } void estrella(int x0,int y0,int l,int an,int ind) { int x1,y1; if (ind > 0) { x1=x0-(l*cos(an/57.29578)); y1=y0-(l*sin(an/57.29578)); line(x0,y0,x1,y1); estrella(x0,y0,l+1,an+w0,ind-1); } }