H, I attach some of the code on a new game I'm working on. If the ball moves past a certain value of x then I want it to be killed/destroyed/made invisible... how do I do that? I've tried the following in the DoMove Procedure:
if x < 100 then
ball.dead
It works because the ball does not respond to my mouse action past that point but the image remains......how does one get rid of the image?
Thanks for your help :-)
Code:
procedure TBall.DoMove(MoveCount : integer);
begin
if MoveLeft then
x:= x - 50;
if MoveRight then
X:= X + 50;
end;
procedure TForm1.DXDraw1Initialize(Sender: TObject);
begin
wallpaper := TDirectDrawsurface.Create(DXDraw1.ddraw);
wallpaper.LoadFromGraphic(Form1.DXImagelist1.Items.Items[1].picture.graphic);
Ball := tball.Create(Form1.DXSpriteEngine1.Engine);
Ball.SpriteImg := TDirectDrawsurface.Create(DXDraw1.ddraw);
Ball.SpriteImg.LoadFromGraphic(Form1.DXImagelist1.items.items[0].picture.graphic);
ball.SpriteImg.TransparentColor:=clblack;
ball.x:=350;
ball.y:=200;
dxTimer1.Enabled := true;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
if not DXDraw1.CanDraw then Exit;
DXInput1.Update;
DXSpriteEngine1.Move(1);
dxdraw1.Surface.Draw(-10,-10, wallpaper.ClientRect, wallpaper,false);
dxdraw1.surface.draw(round(ball.X),round(ball.Y),
ball.SpriteImg.ClientRect, ball.SpriteImg,true);
DXDraw1.Flip;
end;
Bookmarks