home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 14 / applic / mites.c < prev    next >
Encoding:
Text File  |  1986-05-12  |  2.1 KB  |  89 lines

  1. .
  2. /* MITES.C     A Nasty Desk Accessory.  Give it to your frineds   */
  3. /* Mites was written by SEAN PUCKETT using ALCYON (developers) C  */
  4.  
  5. #include <osbind.h>
  6.  
  7. int   contrl[12],intin[128],ptsin[128],intout[128],ptsout[128];
  8. int   a1,dummy,handle,s_width,s_height,s_colors;
  9. unsigned short   fast[128];
  10. int   cx[20],cy[20],ch[20],cv[20],ptx[10];
  11. int   dirx[]={ -1,-2,-2,-1,1,2,2,1 };
  12. int   diry[]={ 2,1,-1,-2,-2,-1,1,2 };
  13.  
  14. main()
  15. {
  16.   appl_init();
  17.   handle=graf_handle(&dummy,&dummy,&dummy,&dummy);
  18.   for(a1=1; a1<10; ++a1)  intin[a1] = 1;
  19.   intin[10] = 2;
  20.   v_opnvwk(intin, &handle, intout);
  21.   s_width=intout[0];
  22.   s_height=intout[1];
  23.   s_colors=intout[13];
  24.  
  25.   program();
  26.  
  27.   v_clsvwk(handle);
  28.   appl_exit();
  29. }
  30.  
  31. program()
  32. {
  33.   int  a1,a2,rnd,butb4,mousedn,mousex,mousey,pel,cdum,dx,dy,pcolor;
  34.  
  35.   mousedn=0;
  36.   for( a1=0; a1<20; fast[a1++]=0 );
  37.   while ( 1==1 ){
  38.     evnt_timer(20,0);
  39.     for( a1=0; a1<20; a1++ ){
  40.       butb4=mousedn;
  41.       vq_mouse(handle,&mousedn,&mousex,&mousey);
  42.       dx=cx[a1];
  43.       dy=cy[a1];
  44.       if (( mousedn==1 )&&( butb4==0 )){
  45.         for( a2=0; a2<20; a2++ ){
  46.           if( fast[a2]==0 ){
  47.             cx[a2]=mousex;
  48.             cy[a2]=mousey;
  49.             rnd=Random()/2091752;
  50.             ch[a2]=dirx[rnd];
  51.             cv[a2]=diry[rnd];
  52.             fast[a2]=1;
  53.             a2=200;
  54.           }
  55.         }
  56.       }
  57.       if( fast[a1]!=0 ){
  58.         ptx[0]=dx;
  59.         ptx[1]=dy;
  60.         ptx[2]=dx;
  61.         ptx[3]=dy;
  62.         vsl_color(handle,0);
  63.         v_pline(handle,2,ptx);
  64.         dx=dx+ch[a1];
  65.         dy=dy+cv[a1];
  66.         if (( dx<0 )||( dx>s_width )||( dy<0 )||( dy>s_height)) fast[a1]=0;
  67.         if ( fast[a1]!=0 ){
  68.           v_get_pixel(handle,dx,dy,&pel,&cdum);
  69.           if( pel!=0 ){
  70.             rnd=Random()/2091752;
  71.             ch[a1]=dirx[rnd];
  72.             cv[a1]=diry[rnd];
  73.           }
  74.           ptx[0]=dx;
  75.           ptx[1]=dy;
  76.           ptx[2]=dx;
  77.           ptx[3]=dy;
  78.           vsl_color(handle,1);
  79.           v_pline(handle,2,ptx);
  80.         }
  81.         cx[a1]=dx;
  82.         cy[a1]=dy;
  83.       }    
  84.     }
  85.   }
  86. }
  87.  
  88.  
  89. doneəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə