UNIT Sprite; INTERFACE uses pcx; Type PTSprite=^TSprite; TSprite=record x,y:word; pict:PTPict; end; PTSShip=^TSShip; TSShip=record Spr:PTSprite; life:byte; def:byte; weapon:byte; Shells:array [0..1] of byte; end; PTStar=^TStar; TStar=record Spr:PTSprite; speed:byte; col:byte; end; function CreateStar(x,y:word):PTStar; procedure DestroyStar(Star:PTStar); function CreateSShip(x,y:word;fname:string):PTSShip; procedure DestroySShip(Ship:PTSShip); function CreateSprite(x,y:word;fname:string):PTSprite; IMPLEMENTATION function CreateSprite(x,y:word;fname:string):PTSprite; var Spr:PTSprite; begin new(Spr); if fname<>'' then begin Spr^.pict:=LoadPcx(fname); end; Spr^.x:=x; Spr^.y:=y; CreateSprite:=Spr; end; procedure DestroySprite(Spr:PTSprite); begin if Spr^.pict^.img<>nil then { freemem(Spr^.pict^.img,(Spr^.pict^.header.Xmax-Spr^.pict^.header.Xmin+1)*(Spr^.pict^. header.Ymax-Spr^.pict^.header.Ymin+1));} dispose(Spr); end; function CreateStar(x,y:word):PTStar; var Star:PTStar; begin new(Star); Star^.Spr:=CreateSprite(x,y,''); Star^.speed:=random(7)+1; if Star^.speed<4 then Star^.col:=12 else if Star^.speed=4 then Star^.col:=15 else Star^.col:=7; CreateStar:=Star; end; procedure DestroyStar(Star:PTStar); begin DestroySprite(Star^.Spr); dispose(Star); end; function CreateSShip(x,y:word;fname:string):PTSShip; var Ship:PTSShip; begin new(Ship); Ship^.Spr:=CreateSprite(x,y,fname); CreateSShip:=Ship; end; procedure DestroySShip(Ship:PTSShip); begin DestroySprite(Ship^.Spr); dispose(Ship); end; end.