home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / MISC / MAG10.ZIP / FLYSHIP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-02-26  |  2.4 KB  |  64 lines

  1.                 Program SpritesOverBackground;
  2.  
  3.                 Uses Crt,Sprites,Mode13h;
  4.  
  5.                 Const Speed=3;
  6.  
  7.                 Type Sprite=Record
  8.                                   Img:Pointer;
  9.                                   Back:Pointer;
  10.                                   X,Y:Integer;
  11.                             End;
  12.  
  13.                 Var F:File;
  14.                     Ship:Sprite;
  15.                     C:Char;
  16.                     Dir:ShortInt;
  17.  
  18.                 Begin
  19.                      { Load sprite image }
  20.                      Assign(F,'Ship.Img');
  21.                      Reset(F,1);
  22.                      LoadImage(F,Ship.Img);
  23.                      Close(F);
  24.                      { Init graphics }
  25.                      InitGraph;
  26.                      InitVirt;
  27.                      { Load a background }
  28.                      LoadPCX('Planet.Pcx',VP[1]);
  29.                      SetPalette(PCXPal);
  30.                      { Init ship }
  31.                      Ship.X:=0;
  32.                      Ship.Y:=100;
  33.                      Dir:=Speed;
  34.                      { Move the ship }
  35.                      Repeat
  36.                            { Get a 27x10 square of the place were the ship is }
  37.                            GetImage(Ship.X,Ship.Y,Ship.X+27,Ship.Y+10,
  38.                                     Ship.Back,VP[1]);
  39.                            { Put sprite of ship, using masking }
  40.                            PutImage_T(Ship.X,Ship.Y,Ship.Img,VP[1]);
  41.                            { Copy virtual screen to VGA screen }
  42.                            CopyPage(VP[1],VGA);
  43.                            { Restore background }
  44.                            PutImage(Ship.X,Ship.Y,Ship.Back,VP[1]);
  45.                            KillImage(Ship.Back);
  46.                            { Move ship }
  47.                            Ship.X:=Ship.X+Dir;
  48.                            If Ship.X>292 Then
  49.                            Begin
  50.                                 Dir:=-Dir;
  51.                                 FlipHoriz(Ship.Img);
  52.                            End;
  53.                            If Ship.X<=0 Then
  54.                            Begin
  55.                                 Dir:=-Dir;
  56.                                 FlipHoriz(Ship.Img);
  57.                            End;
  58.                      Until KeyPressed;
  59.                      C:=ReadKey;
  60.                      KillImage(Ship.Img);
  61.                      CloseVirt;
  62.                      CloseGraph;
  63.                 End.
  64.