home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / atari / 8bit / 5958 < prev    next >
Encoding:
Text File  |  1993-01-26  |  5.0 KB  |  165 lines

  1. Path: sparky!uunet!well!moon!cyberden!phbill
  2. From: phbill@cyberden.sf.ca.us
  3. Newsgroups: comp.sys.atari.8bit
  4. Subject: POLYB.C
  5. Message-ID: <cmiyXB10w165w@cyberden.sf.ca.us>
  6. Date: Mon, 25 Jan 93 15:47:47 PST
  7. Reply-To: phbill@cyberden.sf.ca.us
  8. Organization: Indescribable Creations
  9. Lines: 154
  10.  
  11.  
  12. The "C" version of PolyBounce... compilable on an IBM:
  13.  
  14. main(Argc, Argv)
  15. int Argc;
  16. char *Argv[];
  17. {
  18.      int dimensiona=320, dimensionb=192, screenmode=1;
  19.     char speedch[5], buffer[25], clearch[5];
  20.     int j=0, color=1, speed=75, i, compare=1, echo=1, clear=500;
  21.     int e=1, f=1, a=dimensiona-1, b=1, x=dimensiona-1, y=dimensionb-1, 
  22. h=1, k=dimensionb-1;
  23.     int incrementa=2, incrementb=4, incrementc=6, incrementd=8;
  24.     int ea=2, fa=2, ab=-3, bb=-3, xc=5, yc=5, hd=-7, kd=-7;
  25.      for(i=0; i<Argc; i++)
  26.      {
  27.           strupr(Argv[i]);
  28.           if(strncmp(Argv[i], "/I=", 3)==0)
  29.           {
  30.                strncpy(speedch, Argv[i]+3, 3);
  31.                speed=atoi(speedch);
  32.           
  33.           if(strncmp(Argv[i], "/?", 2)==0)compare=0;
  34.           if(strncmp(Argv[i], "/E", 2)==0)echo=0;
  35.           if(strncmp(Argv[i], "/M=EGA", 6)==0)screenmode=2;
  36.           if(strncmp(Argv[i], "/M=CGA", 6)==0)screenmode=3;
  37.           if(strncmp(Argv[i], "/C=", 3)==0)
  38.           {
  39.                strncpy(clearch, Argv[i]+3, 4);
  40.                clear=atoi(clearch);
  41.           
  42.           
  43.      if(compare==0)
  44.      {
  45.           printf("\nPolyBounce Version 1.0 by Scott LaValley");
  46.              printf("\nThe International House of 
  47. Leeches\n415-897-8190");
  48.              printf("\n\n/E turns echo on.\n/M=EGA turns EGA videomode 
  49. on.\n/M=CGA turns CGA videomode on."); 
  50.              printf("\n/C=[#] 1-9999 sets the number of echos before it 
  51. clears the screen."); 
  52.              printf("\n/I=[#] 1-500 higher the number slower the 
  53. speed.\n\nEXAMPLE polyb /I=150\n\n");
  54.         
  55.      
  56.     if(compare!=0)
  57.     {
  58.          if(screenmode==1)_setvideomode(_VRES16COLOR);
  59.           if(screenmode==2)
  60.           {
  61.                _setvideomode(_ERESCOLOR);
  62.                dimensionb=350;
  63. /*               y=dimensionb-1;
  64.                k=dimensionb-1;*/
  65.           
  66.           if(screenmode==3)
  67.           {
  68.                _setvideomode(_MRES4COLOR);
  69.                dimensiona=320;
  70.                dimensionb=200;
  71. /*               x=dimensiona-1;
  72.                y=dimensionb-1;
  73.                a=dimensiona-1;
  74.                k=dimensionb-1;*/
  75.           
  76.          _setcolor(1);
  77.           time(<ime);
  78.           e=ltime%50;
  79.           f=ltime%20;
  80.           a=ltime%175;
  81.           b=ltime%200;
  82.           x=ltime%22;
  83.           y=ltime%97;
  84.           h=ltime%3;
  85.           k=ltime%125;
  86.  
  87.          while(!kbhit() && strncmp(Argv[i], "/?", 2)!=0)
  88.          {
  89.                j=j+1;
  90.                if(j%100==0)color=color+1;
  91.                if(color==16 && screenmode==1)color=1;
  92.                if(color==16 && screenmode==2)color=1;
  93.                if(color==4 && screenmode==3)color=1;
  94.                if(e<=1)ea=+incrementa;
  95.                if(f<=1)fa=+incrementa;
  96.                if(e>=dimensiona-1)ea=-incrementa;
  97.                if(f>=dimensionb-1)fa=-incrementa;
  98.                e=e+ea;
  99.                f=f+fa;
  100.                if(a<=1)ab=+incrementb;
  101.                if(b<=1)bb=+incrementb;
  102.                if(a>=dimensiona-1)ab=-incrementb;
  103.                if(b>=dimensionb-1)bb=-incrementb;
  104.                a=a+ab;
  105.                b=b+bb;
  106.                if(x<=1)xc=+incrementc;
  107.                if(y<=1)yc=+incrementc;
  108.                if(x>=dimensiona-1)xc=-incrementc;
  109.                if(y>=dimensionb-1)yc=-incrementc;
  110.                x=x+xc;
  111.                y=y+yc;
  112.                if(h<=1)hd=+incrementd;
  113.                if(k<=1)kd=+incrementd;
  114.                if(h>=dimensiona-1)hd=-incrementd;
  115.                if(k>=dimensionb-1)kd=-incrementd;
  116.                h=h+hd;
  117.                k=k+kd;
  118.                _moveto(e, f);
  119.                _lineto(a, b);
  120.                _lineto(x, y);
  121.                _lineto(h, k);
  122.                _lineto(e, f);
  123.                Pause(speed); 
  124.                if(echo!=0)
  125.                {
  126.                     _setcolor(0);
  127.                     _lineto(a, b);
  128.                     _lineto(x, y);
  129.                     _lineto(h, k);
  130.                     _lineto(e, f);     
  131.                
  132.                if(j%clear==0 && echo==0 && 
  133. screenmode==1)_setvideomode(_VRES16COLOR);
  134.                if(j%clear==0 && echo==0 && 
  135. screenmode==2)_setvideomode(_ERESCOLOR);
  136.                if(j%clear==0 && echo==0 && 
  137. screenmode==3)_setvideomode(_MRES4COLOR);
  138.                _setcolor(color);
  139.          
  140.          _setvideomode(_DEFAULTMODE);
  141.      
  142.  
  143.  
  144.  
  145.  
  146. Pause(MsPause)
  147. unsigned MsPause;
  148. {
  149.      struct timeb timebuffer;
  150.      long FutureTime = 0;
  151.      int FutureMs = 0;
  152.      ftime(&timebuffer);
  153.      FutureMs = (timebuffer.millitm + MsPause)%1000;
  154.      FutureTime = ((timebuffer.millitm + MsPause)/1000) + 
  155. timebuffer.time;
  156.      while(1)
  157.      {
  158.           ftime(&timebuffer);
  159.           if ((timebuffer.time > FutureTime) || ((timebuffer.time == 
  160. FutureTime) && (timebuffer.millitm > FutureMs)))break;
  161.      
  162.  
  163.  
  164. The sig..       PhBill@Cyberden.UUCP or PhBill@Cyberden.SF.CA.US
  165.