Changeset 19 for trunk/UMainForm.pas


Ignore:
Timestamp:
Sep 27, 2011, 10:16:41 PM (13 years ago)
Author:
george
Message:
  • Added: Helping threading unit.
  • Added: Now drawing and engine handling are executed in separated thread.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMainForm.pas

    r18 r19  
    8080    Drawing := True;
    8181    StartTime := NowPrecise;
    82     Engine.Draw;
     82    //Engine.Draw;
    8383    DrawDuration := NowPrecise - StartTime;
    84     StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
    85       IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
    86       IntToStr(TPlayer(Engine.Players[0]).Direction);
    87     StatusBar1.Panels[2].Text := FloatToStr(RoundTo(DrawDuration / OneMillisecond, -2));
    88     StatusBar1.Panels[3].Text := IntToStr(TPlayer(Engine.Players[0]).Bullets.Count);
     84    try
     85      Engine.Lock.Acquire;
     86      StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
     87        IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
     88        IntToStr(TPlayer(Engine.Players[0]).Direction);
     89      StatusBar1.Panels[2].Text := FloatToStr(RoundTo(DrawDuration / OneMillisecond, -2));
     90      StatusBar1.Panels[3].Text := IntToStr(TPlayer(Engine.Players[0]).Bullets.Count);
     91    finally
     92      Engine.Lock.Release;
     93    end;
    8994  finally
    9095    Drawing := False;
     
    9499procedure TMainForm.TimerEngineTickTimer(Sender: TObject);
    95100begin
    96   Engine.Tick;
     101  //Engine.Tick;
    97102end;
    98103
     
    138143  end;
    139144  Engine.NewGame;
     145  Engine.Active := True;
    140146  Image1Resize(Self);
    141147end;
Note: See TracChangeset for help on using the changeset viewer.