PDA

View Full Version : DirectX DrawPrimitive sprite move



lordzero
16-09-2007, 11:30 PM
Hello

I'm trying move a sprite using custom vertex using D3DFVF_XYZRHW.

my code work to move sprite only when i set the position in OnCreate of my window...

dont have a way to move it in runtime?

this code dont work to change the position x ate runtime:



if key=VK_RIGHT then
begin
PosX := PosX + 1;
end;

if key=VK_LEFT then
begin
PosX := PosX - 1;
end;

{ if FAILED(
pVB.Lock(0, SizeOf(Vertices), pVertices, 0)) then
Exit;

CopyMemory(pVertices, @Vertices, SizeOf(Vertices));
pVB.Unlock;


my complete code is here:

http://www.lordzero.co.nr/tmp/DrawPrimitive.zip

suggestions are welcome.

Greets

Mirage
17-09-2007, 04:10 AM
You just need to move the array filling code:

Vertices[0].X := -Scale + PosX;
...

to FormKeyDown.

lordzero
17-09-2007, 02:49 PM
You just need to move the array filling code:

Vertices[0].X := -Scale + PosX;
...

to FormKeyDown.


yes guy.. thanks :) its working...

but after the code to move i put this code to work:


if FAILED(
pVB.Lock(0, SizeOf(Vertices), pVertices, 0)) then
Exit;

CopyMemory(pVertices, @Vertices, SizeOf(Vertices));
pVB.Unlock;