home *** CD-ROM | disk | FTP | other *** search
- Program SpritesOverBackground;
-
- Uses Crt,Sprites,Mode13h;
-
- Const Speed=3;
-
- Type Sprite=Record
- Img:Pointer;
- Back:Pointer;
- X,Y:Integer;
- End;
-
- Var F:File;
- Ship:Sprite;
- C:Char;
- Dir:ShortInt;
-
- Begin
- { Load sprite image }
- Assign(F,'Ship.Img');
- Reset(F,1);
- LoadImage(F,Ship.Img);
- Close(F);
- { Init graphics }
- InitGraph;
- InitVirt;
- { Load a background }
- LoadPCX('Planet.Pcx',VP[1]);
- SetPalette(PCXPal);
- { Init ship }
- Ship.X:=0;
- Ship.Y:=100;
- Dir:=Speed;
- { Move the ship }
- Repeat
- { Get a 27x10 square of the place were the ship is }
- GetImage(Ship.X,Ship.Y,Ship.X+27,Ship.Y+10,
- Ship.Back,VP[1]);
- { Put sprite of ship, using masking }
- PutImage_T(Ship.X,Ship.Y,Ship.Img,VP[1]);
- { Copy virtual screen to VGA screen }
- CopyPage(VP[1],VGA);
- { Restore background }
- PutImage(Ship.X,Ship.Y,Ship.Back,VP[1]);
- KillImage(Ship.Back);
- { Move ship }
- Ship.X:=Ship.X+Dir;
- If Ship.X>292 Then
- Begin
- Dir:=-Dir;
- FlipHoriz(Ship.Img);
- End;
- If Ship.X<=0 Then
- Begin
- Dir:=-Dir;
- FlipHoriz(Ship.Img);
- End;
- Until KeyPressed;
- C:=ReadKey;
- KillImage(Ship.Img);
- CloseVirt;
- CloseGraph;
- End.
-