home *** CD-ROM | disk | FTP | other *** search
/ Más de 2,500 Juegos / CD5.iso / zipdat / 4806 / 4806.txt next >
Text File  |  2000-12-12  |  2KB  |  87 lines

  1. Here's something seasonal for all you Palm owners.  
  2. A little something I knocked up in PocketC on my commute...
  3.  
  4. A snowflake "screensaver"!
  5.  
  6. Each flake one is a beautiful unique fractal!
  7.  
  8. You'll need the PDB file (included), 
  9. and the PocketC runtime: http://www.orbworks.com/PocketC_rt.zip
  10.  
  11. OR
  12.  
  13. The source code (below),
  14. and the PocketC compiler: http://www.orbworks.com/PocketC.zip
  15.  
  16.  
  17. Thad
  18.  
  19. Source code follows:
  20.  
  21. //snow
  22. //(c) T.Frogley Dec 2000
  23.  
  24. //bit map, keeps track of whats where
  25. int bmp[256];//16x16
  26.  
  27. //screen x,y snowflake locations
  28. int sx[5]={0,32,64,96,128};
  29. int sy[4]={32,64,96,128};
  30.  
  31. //global x,y snowflake location
  32. int gx;
  33. int gy;
  34.  
  35. #include "memset.h"
  36.  
  37. //puts down a point
  38. //4 way reflection
  39. point(int x,int y)
  40. {
  41.   bmp[x+16*y]=1;
  42.   line(1,gx+x,gy+y,gx+x,gy+y);
  43.   line(1,gx+x,gy+31-y,gx+x,gy+31-y);
  44.   line(1,gx+31-x, gy+y,gx+31-x,gy+y);
  45.   line(1,gx+31-x, gy+31-y,gx+31-x,gy+31-y);
  46. }
  47.  
  48. //shooting particle algorythm
  49. int doit(int x, int y)
  50. {
  51.   int done=0;
  52.   int dd,i,n,dx,dy;
  53.   point(x,y);
  54.   n=0;
  55.   do{
  56.     x=0;dx=1;
  57.     y=15-random(n);dy=0;
  58.     if (random(2)==1){
  59.       x=y; y=0;dy=1;dx=0;
  60.     }
  61.     i=0;
  62.     do{
  63.       x=x+dx;y=y+dy;
  64.       if (x>15) break; if (y>15) break;
  65.       if (bmp[x+16*y]==1){
  66.         point(x-dx,y-dy);
  67.         if (i==0) done = 1;
  68.         break;
  69.       }
  70.       i++;
  71.     }while(1);
  72.     if (n<15) n++;
  73.   }while(!done);
  74. }
  75.  
  76. main()
  77. {
  78.   graph_on();
  79.   title("Snow (c) Thad");
  80.   do{
  81.     gx=sx[random(5)];
  82.     gy=sy[random(4)];
  83.     memset(bmp,0,256);
  84.     rect(0,gx,gy,gx+32,gy+32,0);
  85.     doit(15,15);
  86.   }while(1);
  87. }