home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!well!moon!cyberden!phbill
- From: phbill@cyberden.sf.ca.us
- Newsgroups: comp.sys.atari.8bit
- Subject: POLYB.C
- Message-ID: <cmiyXB10w165w@cyberden.sf.ca.us>
- Date: Mon, 25 Jan 93 15:47:47 PST
- Reply-To: phbill@cyberden.sf.ca.us
- Organization: Indescribable Creations
- Lines: 154
-
-
- The "C" version of PolyBounce... compilable on an IBM:
-
- main(Argc, Argv)
- int Argc;
- char *Argv[];
- {
- int dimensiona=320, dimensionb=192, screenmode=1;
- char speedch[5], buffer[25], clearch[5];
- int j=0, color=1, speed=75, i, compare=1, echo=1, clear=500;
- int e=1, f=1, a=dimensiona-1, b=1, x=dimensiona-1, y=dimensionb-1,
- h=1, k=dimensionb-1;
- int incrementa=2, incrementb=4, incrementc=6, incrementd=8;
- int ea=2, fa=2, ab=-3, bb=-3, xc=5, yc=5, hd=-7, kd=-7;
- for(i=0; i<Argc; i++)
- {
- strupr(Argv[i]);
- if(strncmp(Argv[i], "/I=", 3)==0)
- {
- strncpy(speedch, Argv[i]+3, 3);
- speed=atoi(speedch);
-
- if(strncmp(Argv[i], "/?", 2)==0)compare=0;
- if(strncmp(Argv[i], "/E", 2)==0)echo=0;
- if(strncmp(Argv[i], "/M=EGA", 6)==0)screenmode=2;
- if(strncmp(Argv[i], "/M=CGA", 6)==0)screenmode=3;
- if(strncmp(Argv[i], "/C=", 3)==0)
- {
- strncpy(clearch, Argv[i]+3, 4);
- clear=atoi(clearch);
-
-
- if(compare==0)
- {
- printf("\nPolyBounce Version 1.0 by Scott LaValley");
- printf("\nThe International House of
- Leeches\n415-897-8190");
- printf("\n\n/E turns echo on.\n/M=EGA turns EGA videomode
- on.\n/M=CGA turns CGA videomode on.");
- printf("\n/C=[#] 1-9999 sets the number of echos before it
- clears the screen.");
- printf("\n/I=[#] 1-500 higher the number slower the
- speed.\n\nEXAMPLE polyb /I=150\n\n");
-
-
- if(compare!=0)
- {
- if(screenmode==1)_setvideomode(_VRES16COLOR);
- if(screenmode==2)
- {
- _setvideomode(_ERESCOLOR);
- dimensionb=350;
- /* y=dimensionb-1;
- k=dimensionb-1;*/
-
- if(screenmode==3)
- {
- _setvideomode(_MRES4COLOR);
- dimensiona=320;
- dimensionb=200;
- /* x=dimensiona-1;
- y=dimensionb-1;
- a=dimensiona-1;
- k=dimensionb-1;*/
-
- _setcolor(1);
- time(<ime);
- e=ltime%50;
- f=ltime%20;
- a=ltime%175;
- b=ltime%200;
- x=ltime%22;
- y=ltime%97;
- h=ltime%3;
- k=ltime%125;
-
- while(!kbhit() && strncmp(Argv[i], "/?", 2)!=0)
- {
- j=j+1;
- if(j%100==0)color=color+1;
- if(color==16 && screenmode==1)color=1;
- if(color==16 && screenmode==2)color=1;
- if(color==4 && screenmode==3)color=1;
- if(e<=1)ea=+incrementa;
- if(f<=1)fa=+incrementa;
- if(e>=dimensiona-1)ea=-incrementa;
- if(f>=dimensionb-1)fa=-incrementa;
- e=e+ea;
- f=f+fa;
- if(a<=1)ab=+incrementb;
- if(b<=1)bb=+incrementb;
- if(a>=dimensiona-1)ab=-incrementb;
- if(b>=dimensionb-1)bb=-incrementb;
- a=a+ab;
- b=b+bb;
- if(x<=1)xc=+incrementc;
- if(y<=1)yc=+incrementc;
- if(x>=dimensiona-1)xc=-incrementc;
- if(y>=dimensionb-1)yc=-incrementc;
- x=x+xc;
- y=y+yc;
- if(h<=1)hd=+incrementd;
- if(k<=1)kd=+incrementd;
- if(h>=dimensiona-1)hd=-incrementd;
- if(k>=dimensionb-1)kd=-incrementd;
- h=h+hd;
- k=k+kd;
- _moveto(e, f);
- _lineto(a, b);
- _lineto(x, y);
- _lineto(h, k);
- _lineto(e, f);
- Pause(speed);
- if(echo!=0)
- {
- _setcolor(0);
- _lineto(a, b);
- _lineto(x, y);
- _lineto(h, k);
- _lineto(e, f);
-
- if(j%clear==0 && echo==0 &&
- screenmode==1)_setvideomode(_VRES16COLOR);
- if(j%clear==0 && echo==0 &&
- screenmode==2)_setvideomode(_ERESCOLOR);
- if(j%clear==0 && echo==0 &&
- screenmode==3)_setvideomode(_MRES4COLOR);
- _setcolor(color);
-
- _setvideomode(_DEFAULTMODE);
-
-
-
-
-
- Pause(MsPause)
- unsigned MsPause;
- {
- struct timeb timebuffer;
- long FutureTime = 0;
- int FutureMs = 0;
- ftime(&timebuffer);
- FutureMs = (timebuffer.millitm + MsPause)%1000;
- FutureTime = ((timebuffer.millitm + MsPause)/1000) +
- timebuffer.time;
- while(1)
- {
- ftime(&timebuffer);
- if ((timebuffer.time > FutureTime) || ((timebuffer.time ==
- FutureTime) && (timebuffer.millitm > FutureMs)))break;
-
-
-
- The sig.. PhBill@Cyberden.UUCP or PhBill@Cyberden.SF.CA.US
-