home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / GFXFX2.ZIP / ROTATE2.PAS < prev    next >
Pascal/Delphi Source File  |  1995-02-14  |  2KB  |  61 lines

  1.  
  2. program _rotate; { ROTATE2.PAS }
  3. { Rotating stars in mode 13h, by Bas van Gaalen }
  4. uses u_vga,u_pal,u_3d,u_kb;
  5. const
  6.   radius:word=200; { space rectangular radius }
  7.   maxpoints=100; { maximum number of points }
  8.  
  9. var
  10.   points:array[1..maxpoints,0..2] of integer;
  11.   maxdepth:word;
  12.   colordiv:byte;
  13.  
  14. {----------------------------------------------------------------------------}
  15.  
  16. procedure initialize;
  17. var
  18.   i:word; j:byte;
  19. begin
  20.   randomize;
  21.   for i:=1 to maxpoints do
  22.     for j:=0 to 2 do
  23.       points[i,j]:=random(2*radius)-radius;
  24.   setvideo($13);
  25.   for j:=1 to 63 do setrgb(j,10+j shr 1,10+j shr 1,j);
  26.   maxdepth:=round(sqrt(3*sqr(radius)));
  27.   colordiv:=succ(2*maxdepth div 64);
  28.   dist:=succ(maxdepth div 50)*50;
  29. end;
  30.  
  31. procedure bump_n_rotate;
  32. const xst=1; yst=1; zst=-1;
  33. var
  34.   xp,yp:array[0..maxpoints] of integer;
  35.   n:word;
  36.   x,y,z:integer;
  37.   phix,phiy,phiz:byte;
  38. begin
  39.   phix:=0; phiy:=0; phiz:=0;
  40.   repeat
  41.     vretrace;
  42.     for n:=1 to maxpoints do begin
  43.       if (xp[n]>=0) and (xp[n]<=319) and (yp[n]>=0) and (yp[n]<=199) then
  44.         putpixel(xp[n],yp[n],0);
  45.       x:=points[n,0]; y:=points[n,1]; z:=points[n,2];
  46.       rotate(x,y,z,phix,phiy,phiz);
  47.       conv3dto2d(xp[n],yp[n],x,y,z);
  48.       inc(xp[n],160); inc(yp[n],100);
  49.       if (xp[n]>=0) and (xp[n]<=319) and (yp[n]>=0) and (yp[n]<=199) then
  50.         putpixel(xp[n],yp[n],(z+maxdepth) div colordiv);
  51.     end;
  52.     inc(phix,xst); inc(phiy,yst); inc(phiz,zst);
  53.   until keypressed;
  54. end;
  55.  
  56. begin
  57.   initialize;
  58.   bump_n_rotate;
  59.   setvideo(u_lm);
  60. end.
  61.