Доброго времени суток!
Прошу помощи. Не могу понять почему не двигаеться мой спрайт. Он прорисовывается, но не двигается.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, ComCtrls, OpenGL, ToolWin, ImgList,
DXDraws, DXSprite, DXClass, DIB, DXInput;
type
TForm1 = class(TDXForm)
MainMenu1: TMainMenu;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
Status: TStatusBar;
N4: TMenuItem;
N5: TMenuItem;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
DXImageList1: TDXImageList;
DXDraw1: TDXDraw;
N6: TMenuItem;
DXSpriteEngine1: TDXSpriteEngine;
DXInput1: TDXInput;
DXTimer1: TDXTimer;
procedure FormActivate(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure DXDraw1Initialize(Sender: TObject);
procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
private
public
end;
var
Form1: TForm1;
nx,ny,kk: integer;
Lab: textfile;
cLabHeight, cLabWidth, nLabWidth, nLabHeight: integer;
cLab,nLab: array[1..10,1..10]of integer;
mode: integer;
implementation
type TRobot = Class(TImageSprite)
protected
procedure DoMove(MoveCount: integer); override;
public
constructor Create(AParent: TSprite); overload;
destructor Destroy; override;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
DXDraw1.Flip;
nx:=10;
ny:=10;
TRobot.Create(DXSpriteEngine1.Engine);
DXSpriteEngine1.Draw;
DXDraw1.Flip;
DXSpriteEngine1.Move(1000 div 60);
end;
procedure TForm1.N2Click(Sender: TObject);
var ii,jj,x,y: integer;
begin
DXDraw1.Initialize;
for ii:=0 to cLabHeight do
for jj:=0 to cLabWidth do
if cLab[ii,jj]=1 then
begin
x:=ii*DXImageList1.Items[0].Width-DXImageList1.Items[0].Width;
y:=jj*DXImageList1.Items[0].Height-DXImageList1.Items[0].Height;
DXImageList1.Items[0].Draw(DXDraw1.Surface,y,x,0);
end;
DXDraw1.Flip;
nx:=10;
ny:=10;
TRobot.Create(DXSpriteEngine1.Engine);
DXSpriteEngine1.Draw;
DXDraw1.Flip;
DXSpriteEngine1.Move(1000 div 60);
end;
procedure TForm1.DXDraw1Initialize(Sender: TObject);
begin
DXDraw1.Height:=cLabHeight*DXImageList1.Items[0].Height;
DXDraw1.Width:=cLabWidth*DXImageList1.Items[0].Width;
DXDraw1.Surface.Fill(clWhite);
DXDraw1.Flip;
DXDraw1.Visible:=True;
end;
constructor TRobot.Create(AParent: TSprite);
begin
inherited Create(AParent);
Image:=Form1.DXImageList1.Items.Find('robot');
Width:=Image.Width;
Height:=Image.Height;
X:=nx;
Y:=ny;
Z:=2;
end;
destructor TRobot.Destroy;
begin
inherited Destroy;
end;
procedure TRobot.DoMove(MoveCount: integer);
begin
inherited DoMove(MoveCount);
Form1.DXInput1.Update;
if isLeft in Form1.DXInput1.States then Engine.X:=X-5;
if isRight in Form1.DXInput1.States then X:=X+5;
if isUp in Form1.DXInput1.States then X:=X+5;
if isDown in Form1.DXInput1.States then Y:=Y-5;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
DXInput1.Update;
DXDraw1.Flip;
end;
end.
Лишнее убрал. Заранее спасибо.