PDA

View Full Version : Pixelcheck Collision Method Does Not Work



wodzu
06-01-2006, 12:03 AM
Greetings,

Well first of all, i discovered this bug in early 2003 :lol: and still doesn't know how to solve it. I am sure that You know what I mean, but if not I try to explain.

When I setup PixelCheck:=True;
in TImageSprite its behaviour doesn't change. I mean the Collision is detected by rectangles not by Pixels like It should be.
What should I do? Is there any patches to this bug?

Regards and thank You for Your time.

Wodzu

Firlefanz
06-01-2006, 06:23 AM
Hi!

perhaps you should post your Sprite.Create method here and we have a look if we see some error. :wink:

As far as I remember (years ago), the pixelcheck worked out well...

Firle

wodzu
06-01-2006, 10:21 AM
Greetings,

And Thank You for Your reply once again Firlefranz ;) ;)

Please tak a look at the example.



unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXDraws, DXClass, DXSprite;

type
TForm1 = class(TForm)
DXDraw1: TDXDraw;
DXSpriteEngine1: TDXSpriteEngine;
DXTimer1: TDXTimer;
DXImageList1: TDXImageList;
procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

TMySmallSprite = class(TImageSprite)
public
procedure DoMove(MoveCount: Integer); override;
procedure DoCollision(Sprite: TSprite; var Done: Boolean); override;
end;

var
Form1: TForm1;
MySmallSprite: TMySmallSprite;
MyLargeSprite: TImageSprite;


implementation

{$R *.dfm}

procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
if not DXDraw1.CanDraw then Exit;
DXDraw1.Surface.Fill(0);
DXSpriteEngine1.Draw;
DXSpriteEngine1.Move(0);
with DXDraw1.Surface.Canvas do
begin
Release;
end;
DXDraw1.Flip;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
MyLargeSprite:=TImageSprite.Create(DXSpriteEngine1 .Engine);
with MyLargeSprite do
begin
Image := DXImageList1.Items.Find('1');
X:=50;
Y:=100;
Z := 1;
Width := Image.Width;
Height := Image.Height;
PixelCheck:=True;
end;

MySmallSprite:=TMySmallSprite.Create(DXSpriteEngin e1.Engine);
with MySmallSprite do
begin
Image := DXImageList1.Items.Find('2');
X:=300;
Y:=150;
Z := 1;
Width := Image.Width;
Height := Image.Height;
PixelCheck:=True;
end;
end;

procedure TMySmallSprite.DoCollision(Sprite: TSprite; var Done: Boolean);
begin
inherited;
if Sprite is TImageSprite then
X:=300;
end;

procedure TMySmallSprite.DoMove(MoveCount: Integer);
begin
inherited;
X:=X-1;
PixelCheck:=True; //in example which doesnt work also, this line was here
Collision;
end;

end.

Traveler
06-01-2006, 11:10 AM
Hmm,.. perhaps not exactly what you want to hear but I tried your sample and I have a pixel perfect collision. :think:
Code looks pretty much okay to me as well.

wodzu
06-01-2006, 11:39 AM
Thank You for Your interest.

I have pixelcheck collision working fine too. :D I changed my DelphiX version for that proposed by ijcro.
Probably the old version had a bug in DXSprite.

Regards,
Wodzu

Firlefanz
06-01-2006, 12:07 PM
Fine. So it is solved?

Firle

wodzu
06-01-2006, 12:20 PM
Yeah atleast.