DelphiX Sprite Engine Tutorial?

Started by
7 comments, last by Flare 21 years, 11 months ago
Does anyone know where to find a good tutorial on the DelphiX Sprite Engine and/or the usage of sprites? I''ve searched quite a lot, but I haven''t yet found what I''m looking for. Any help would be appreciated!
Advertisement
I'm not too familiar with DelphiX, but one easy way of writing a sprite engine is this...

TMySprite = record
__X, Y: Integer;
__Health: Byte;
__{ Add more here }
end;

TSpriteArray = array of TMySprite;

...

var
__MySprites: TSpriteArray;
__I: Integer;

...

SetLength(MySprites, 5);

for I := 0 to 4 do
begin
__MySprites.X := Random(640);
__MySprites.Y := Random(480);<br>__MySprites.Health := 100;<br>end;<br><br>…<br><br>Use another "for I :=…" to draw the sprites on your screen. You can do that with the normal DelphiX drawing routines…<br>Add a "Frame: Integer" to your TMySprite record and increment it and change your drawing routine accordingly to animate your sprites. Might be faster than the DelphiX sprite engine, but then again I'm not too familiar with it… </i> <br><br><SPAN CLASS=editedby>[edited by - Harry Hunt on May 8, 2002 6:57:27 AM]</SPAN>
The forum script somehow changed

MySprites .X := Random(640); into<br>MySprites.X := Random(640);<br><br><br>dunno why… <br><br><br>ONE THING: This example uses dynamic arrays which from what I know are not supported by any Delphi version prior to 4<br><br><SPAN CLASS=editedby>[edited by - Harry Hunt on May 8, 2002 7:00:30 AM]</SPAN>
quote:Original post by Harry Hunt
The forum script somehow changed

MySprites .X := Random(640); into<br>MySprites.X := Random(640);<br><br>dunno why… <hr height=1 noshade></SPAN></BLOCKQUOTE> <br>It''s ''cos the forum interprets the ''I'' tag as italics.<br><br>I don''t think he''s asking how to write his own sprite engine, he wants to know how to use the DXSpriteEngine that comes with DelphiX.
[ PGD - The Home of Pascal Game Development! ] [ Help GameDev.net fight cancer ]
thanks for the info about the italics thing...

I know that he asked about the DelphiX sprite engine...but I don''t know much about it (I don''t have DelphiX installed).
However, writing a simple sprite engine is so easy that I don''t quite get the point in using a 3rd party one.
Also, your own sprite engine would be a lot more customizable, prolly faster and it would be "your own" engine.
quote:Original post by Harry Hunt
thanks for the info about the italics thing...
My pleasure.
quote:I know that he asked about the DelphiX sprite engine...but I don''t know much about it (I don''t have DelphiX installed).
Are you mad?? Get it!
quote:However, writing a simple sprite engine is so easy that I don''t quite get the point in using a 3rd party one.
Also, your own sprite engine would be a lot more customizable, prolly faster and it would be "your own" engine.
Or you could just use the DelphiX SpriteEngine and alter the code to suit your needs.

[ PGD - The Home of Pascal Game Development! ] [ Help GameDev.net fight cancer ]
I use my own DirectX wrappers (XCESS game development kit - will be published soon) and my own sprite engine.
It''s a lot faster than DelphiX, uses the well-commented Jedi-Headers and works quite well.
I hate the DelphiX SpriteEngine, but only because I don''t know it. It makes things easier, once you get the hang of it. Personally, however, I would rather write my own code and use it, only because a) it''s mine, and b) I know everything about it. The only thing I want the SpriteEngine for is for collision detection, because thats a difficult topic for me.
Part of my sprite engine with bounding-box collision detection.


    TDXCustomSprite = class(TObject)  private    FY: Integer;    FTag: Integer;    FImageIndex: Integer;    FX: Integer;    FFrame: Integer;    FName: String;    FBoundingBox: TRect;  public    function TestCollision(Sprite: TDXCustomSprite): Boolean;    property X: Integer read FX write FX;    property Y: Integer read FY write FY;    property BoundingBox: TRect read FBoundingBox write FBoundingBox;    property Frame: Integer read FFrame write FFrame;    property Name: String read FName write FName;    property ImageIndex: Integer read FImageIndex write FImageIndex;    property Tag: Integer read FTag write FTag;  end;implementation{ TDXCustomSprite }function TDXCustomSprite.TestCollision(Sprite: TDXCustomSprite): Boolean;var  RX, RY: Integer;  SPRX, SPRY: Integer;  CRX, CRY: Integer;  SPCRX, SPCRY: Integer;  DeltaX, DeltaY: Integer;begin     RX:= (Self.BoundingBox.Right - Self.BoundingBox.Left) div 2;     RY:= (Self.BoundingBox.Bottom - Self.BoundingBox.Top) div 2;     SPRX:= (Sprite.BoundingBox.Right - Sprite.BoundingBox.Left) div 2;     SPRY:= (Sprite.BoundingBox.Bottom - Sprite.BoundingBox.Top) div 2;     CRX:= Self.X + RX;     CRY:= Self.Y + RY;     SPCRX:= Sprite.X + SPRX;     SPCRY:= Sprite.Y + SPRY;     DeltaX:= Abs(SPCRX - CRX);     DeltaY:= Abs(SPCRY - CRY);     If (DeltaX < RX + SPRX) and (DeltaY < RY + SPRY) then        Result:= true     else        Result:= false;end;  


[edited by - Harry Hunt on May 10, 2002 11:56:15 AM]

This topic is closed to new replies.

Advertisement