Thursday 23 August 2007

A Test Sprite Class

To make my test sprite code a bit clearer I thought I should also show the sprite class so that you can see how the settings are used. Notice that my sprite class derives from "BaseSprite". I will soon be adding an "AnimatedSprite" class that will provide base functionality to animate an image.

The declaration

TTestSprite = class (TBaseSprite)
public
constructor Create (theSurface : PSDL_Surface ;
XPos : integer ;
YPos : integer ;
ZPos : cardinal) ;

procedure Update ; override ;
end ;

The implementation

constructor TTestSprite.Create (theSurface : PSDL_Surface ;
XPos : integer ;
YPos : integer ;
ZPos : cardinal) ;
begin
inherited Create ;
ImageSurface := theSurface ;

ImageLocationRect.x := XPos ;
ImageLocationRect.y := YPos ;

ZOrder := ZPos ;

ImageDisplayRect.w := 81 ;
ImageDisplayRect.h := 90 ;
ImageDisplayRect.x := 0 ;
ImageDisplayRect.y := 0 ;
end ;

procedure TTestSprite.Update ;
begin
end ;

No comments: