i edit your code:
Code:
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
//You are drawing before check DXDraw1.CanDraw
DXDraw1.Surface.Fill(0);
DXSpriteEngine1.Draw;
DXImageList1.Items.Find('Earth').Draw(DXDraw1.Surface, Earthx, Earthy,0);
DXImageList1.Items.Find('Explode1').Draw(DXDraw1.Surface, Explode1x, Explode1y,0);
DXImageList1.Items.Find('Explode2').Draw(DXDraw1.Surface, Explode2x, Explode2y,0);
DXImageList1.Items.Find('Planet').Draw(DXDraw1.Surface, Planetx, planety,0);
if not DXDraw1.CanDraw then Exit;
DXInput1.Update;
DXSpriteEngine1.Move(1);
DXSpriteEngine1.Dead;
DXSpriteEngine1.Draw;
if (player.Deaded) then begin
if (Player_No <= 2) then
NewPlayer
else
GameEnd;
//here you disable dx timer...you will be unable to print anything on video by doing this!!!!
//by disabling DX timer you "freeze" the game because the procedure TForm1.DXTimer1Timer is NEVER called.
end;
with DXDraw1.Surface.Canvas do
begin
Brush.Style := bsClear;
Font.Size := 12;
Font.Color := clTeal;
Textout(0,60, 'FPS: '+inttostr(DXTimer1.FrameRate));
TextOut(0,0,'Time: ' + IntToStr(Seconds) + ', Enemy Ships left: ' + IntToStr(enimies));
TextOut(0,40, 'Lives left: ' + IntToStr(Lives));
If (Enimies = 0) Then
begin
DXTimer1.Enabled := False;
Timer1.Enabled := False;
DXWaveList1.Items.Find('Tada').Play(False);
Font.Size := 26;
Font.Color := clYellow;
TextOut(290,220,'Game Over, your time: ' + IntToStr(Seconds) + ' seconds');
end;
Release;
end;
DXDraw1.Flip;
end;
hope it help!
i suggest you to do not use Dx timer except of inizialize, finalize and print on video.
Bookmarks