home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / graphic / sprt_tst.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-28  |  2KB  |  48 lines

  1. Uses Crt,Gif,ModeXLib,Sprites;
  2.  
  3. Const Sprite_Number=3;          {number of sprites used in the program}
  4.  
  5. Var Sprite:Array[1..Sprite_Number] of SpriteTyp;
  6.                                 {data records of sprites}
  7.     i:Word;                     {counter}
  8.  
  9. Begin
  10.   Init_ModeX;                   {enable Mode X}
  11.   LoadGif('sprites');           {load image with the three sprites}
  12.   GetSprite(62 +114*320,58,48,Sprite[1]);  {coordinates (62/114), width 58*48}
  13.   GetSprite(133+114*320,58,48,Sprite[2]); {(133/114), 58*48}
  14.   GetSprite(203+114*320,58,48,Sprite[3]); {(203/114), 58*48}
  15.                                 {load the three sprites}
  16.   LoadGif('wallpape');          {load wallpaper}
  17.   p13_2_ModeX(48000,16000);     {and copy to background page}
  18.   With Sprite[1] do Begin       {coordinates and speeds}
  19.     px:=160;py:=100;            {of all three spites to (random values)}
  20.     sx:=1;sy:=2;
  21.   End;
  22.   With Sprite[2] do Begin
  23.     px:=0;py:=0;
  24.     sx:=1;sy:=-1;
  25.   End;
  26.   With Sprite[3] do Begin
  27.     px:=250;py:=150;
  28.     sx:=-2;sy:=-1;
  29.   End;
  30.   Repeat
  31.     CopyScreen(vpage,48000);    {wallpaper to current page}
  32.     For i:=1 to Sprite_Number do{run for all 3 sprites}
  33.       With Sprite[i] do Begin
  34.         Inc(px,sx); Inc(py,sy); {movement}
  35.         If (px < -dtx div 2)    {at left or right border ? -> turn around}
  36.           or (px > 320-dtx div 2) Then sx:=-sx;
  37.         If (py < -dty div 2)    {at top or bottom border ? -> turn around}
  38.           or (py > 200-dty div 2) Then sy:=-sy;
  39.         PutSprite(vpage,px,py,Sprite[i]);
  40.                                 {draw sprite}
  41.       End;
  42.     switch;                     {switch to calculated page}
  43.     WaitRetrace;                {only after next retrace can screen}
  44.   Until KeyPressed;             {be changed again}
  45.   ReadLn;
  46.   TextMode(3);
  47. End.
  48.