home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume18 / xmpb / part07 / do_stars.c < prev    next >
C/C++ Source or Header  |  1993-07-12  |  2KB  |  81 lines

  1. /* do_stars.c - ***  */
  2.  
  3. #if !defined(lint)
  4. static char sccs_id[] = "@(#)do_stars.c 1.9 93/04/22 XMPB";
  5. #endif
  6. #include "player.h"
  7.  
  8. do_stars(w)
  9. winptr w;
  10. {
  11.     int i;
  12.  
  13.     for(i=0;i<STARSPERPLANE;i++)
  14.     {
  15.         w->stars1[i].lx = w->stars1[i].x;
  16.         w->stars1[i].ly = w->stars1[i].y;
  17.         w->stars2[i].lx = w->stars2[i].x;
  18.         w->stars2[i].ly = w->stars2[i].y;
  19.  
  20.         w->stars1[i].x -= w->xv/49152;
  21.         w->stars1[i].y += w->yv/49152;
  22.         w->stars1[i].x = (w->stars1[i].x+PLAYW)%PLAYW;
  23.         w->stars1[i].y = (w->stars1[i].y+PLAYH)%PLAYH;
  24.  
  25.         w->stars2[i].x -= w->xv/32768;
  26.         w->stars2[i].y += w->yv/32768;
  27.         w->stars2[i].x = (w->stars2[i].x+PLAYW)%PLAYW;
  28.         w->stars2[i].y = (w->stars2[i].y+PLAYH)%PLAYH;
  29.     }
  30. }
  31.  
  32. draw_stars(w)
  33. winptr w;
  34. {
  35.     int i;
  36.  
  37.     for(i=0;i<STARSPERPLANE;i++)
  38.     {
  39.         XCopyPlane(w->theDisplay,(w->stars1[i].pm->spm),w->back_buffer,w->bbgc,0,0,w->stars1[i].pm->w,w->stars1[i].pm->h,w->stars1[i].x+OFFSET,w->stars1[i].y+OFFSET,1);
  40.         XCopyPlane(w->theDisplay,(w->stars2[i].pm->spm),w->back_buffer,w->bbgc,0,0,w->stars2[i].pm->w,w->stars2[i].pm->h,w->stars2[i].x+OFFSET,w->stars2[i].y+OFFSET,1);
  41. /*
  42.         XDrawPoint(w->theDisplay,w->back_buffer,w->bbgc,w->stars1[i].x,w->stars1[i].y);
  43.         XDrawPoint(w->theDisplay,w->back_buffer,w->bbgc,w->stars2[i].x,w->stars2[i].y);
  44. */
  45.         XFlush(w->theDisplay);
  46.     }
  47. }
  48. draw_last_stars(w)
  49. winptr w;
  50. {
  51.     int i;
  52.  
  53.     for(i=0;i<STARSPERPLANE;i++)
  54.     {
  55.         XCopyPlane(w->theDisplay,(w->stars1[i].pm->spm),w->theWindow,w->theGC,0,0,w->stars1[i].pm->w,w->stars1[i].pm->h,w->stars1[i].lx,w->stars1[i].ly,1);
  56.         XCopyPlane(w->theDisplay,(w->stars2[i].pm->spm),w->theWindow,w->theGC,0,0,w->stars2[i].pm->w,w->stars2[i].pm->h,w->stars2[i].lx,w->stars2[i].ly,1);
  57.     }
  58. }
  59.  
  60.  
  61. init_stars(w)
  62. winptr w;
  63. {
  64.     int i;
  65.     int c;
  66.  
  67.     for(i=0;i<STARSPERPLANE;i++)
  68.     {
  69.         w->stars1[i].x = rand()%PLAYW;
  70.         w->stars1[i].y = rand()%PLAYH;
  71.         c = rand()%5;
  72.         c /=2;
  73.         w->stars1[i].pm = &(w->spm[c]);
  74.         w->stars2[i].x = rand()%PLAYW;
  75.         w->stars2[i].y = rand()%PLAYH;
  76.         c = rand()%5;
  77.         c /=2;
  78.         w->stars2[i].pm = &(w->spm[c]);
  79.     }
  80. }
  81.