home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / UVE138.ZIP / EXAMPLES.ZIP / GLENZ3.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-08-30  |  1.8 KB  |  92 lines

  1. {$A+,B-,D+,E+,F-,G+,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+}
  2. {$M 16384,0,655360}
  3.  
  4. {
  5. GLENZ3.PAS
  6. Demonstrates     - sprite color mapping
  7.         - sprite transparency
  8.         - background usage
  9.         - higher level of sprite encapsulation
  10. }
  11.  
  12. uses    crt,uve32;
  13.  
  14. const    maxspheres=200;
  15.  
  16. type    spheretype=record
  17.         x,y,
  18.         forcex,forcey:longint;
  19.     end;
  20.  
  21. var    sphere:array[1..maxspheres] of spheretype;
  22.  
  23. procedure init;
  24. var    pal:palette;
  25.     i:integer;
  26. begin
  27.     ia_inituve;
  28.     ia_loadspr('sphere.uvl',1);
  29.     ia_chainsprite(1,spritesloaded,1);
  30.     ia_loadfont(8);
  31.     ia_setfontattr(8,plain,proportional,horizontal,255,true,0);
  32.     pal:=blackpal;
  33.     for i:=0 to 63 do with pal[i] do begin
  34.         red:=i;
  35.         green:=i;
  36.         blue:=i;
  37.     end;
  38.     ia_makeglenzmap(pal,1,1,1,maparray[1]);
  39.     ia_powerup;
  40.     ia_setpalette(pal);
  41.     ia_setcycletime(40);
  42.     for i:=1 to maxspheres do with sphere[i] do begin
  43.         x:=longint(160)*256;
  44.         y:=longint(200)*256;
  45.         forcex:=(longint(random(2560))-1280);
  46.         forcey:=-(longint(random(2560)));
  47.         spr[i].n:=1+random(30);
  48.         spr[i].transparent:=true;
  49.         spr[i].map:=1;
  50.     end;
  51.     ia_cls(hidden,0);
  52.     usebackground:=false;
  53. end;
  54.  
  55. procedure deinit;
  56. begin
  57.     ia_shutdown;
  58.     halt;
  59. end;
  60.  
  61.  
  62. procedure movespheres;
  63. var    i:integer;
  64. begin
  65.     for i:=1 to maxspheres do with sphere[i] do begin
  66.         inc(x,forcex);
  67.         inc(y,forcey);
  68.         if (y>200*256) and (forcey>0) then
  69.             forcey:=-forcey
  70.             else inc(forcey,64);
  71.         if (x<0) and (forcex<0) then forcex:=-forcex;
  72.         if (x>320*256) and (forcex>0) then forcex:=-forcex;
  73.         ia_center(i,x div 256,y div 256,2);
  74.     end;
  75. end;
  76.  
  77. var    ch:char;
  78. begin
  79.     init;
  80.     repeat
  81.         if keypressed then begin
  82.             while keypressed do ch:=readkey;
  83.             if ch=' ' then usebackground:=not usebackground;
  84.         end;
  85.         movespheres;
  86.         ia_doframepart1;
  87.         ia_doframepart2;
  88.         ia_printstr(hidden,-32768,30,'Press SPACE to toggle background',63);
  89.         ia_doframepart3;
  90.     until ch=#27;
  91.     deinit;
  92. end.