Ignore:
Timestamp:
Aug 22, 2019, 9:50:21 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Use TPaintBox for drawing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/paintbox/UEngine.pas

    r45 r49  
    219219    FBitmapLock: TCriticalSection;
    220220    FOnGameEnd: TNotifyEvent;
     221    FOnRepaint: TNotifyEvent;
    221222    FRedrawPending: Boolean;
    222223    FBitmapLower: TBitmapTColor;
     
    230231    function IsInsideHouses(Pos: TPoint): Boolean;
    231232    procedure DoDrawToBitmap;
     233    procedure DoOnRepaint;
    232234    procedure InitPlayerPool;
    233235    procedure InitPlayers;
     
    257259    property Active: Boolean read FActive write SetActive;
    258260    property OnGameEnd: TNotifyEvent read FOnGameEnd write FOnGameEnd;
     261    property OnRepaint: TNotifyEvent read FOnRepaint write FOnRepaint;
    259262  end;
    260263
     
    370373  repeat
    371374    Engine.Draw(Self);
    372     Sleep(50);
     375    //Sleep(50);
    373376  until Terminated;
    374377end;
     
    11541157begin
    11551158  FBitmap := AValue;
    1156   ResizePlayerFrames;
    11571159end;
    11581160
     
    12711273end;
    12721274
     1275procedure TEngine.DoOnRepaint;
     1276begin
     1277  if Assigned(FOnRepaint) then FOnRepaint(Self);
     1278end;
     1279
    12731280procedure TEngine.InitDigMasks;
    12741281var
     
    15201527constructor TEngine.Create;
    15211528begin
     1529  FBitmap := TBitmap.Create;
    15221530  Lock := TCriticalSection.Create;
    15231531  FBitmapLower := TBitmapTColor.Create;
     
    15571565  FreeAndNil(AudioShot);
    15581566  FreeAndNil(AudioExplode);
     1567  FreeAndNil(FBitmap);
    15591568  inherited Destroy;
    15601569end;
     
    15931602      Lock.Release;
    15941603    end;
    1595     if not Thread.Terminated then Thread.Synchronize(DoDrawToBitmap);
     1604    if not Thread.Terminated then DoDrawToBitmap;
     1605    if not Thread.Terminated then Thread.Synchronize(DoOnRepaint);
    15961606    DrawDuration := NowPrecise - DrawStart;
    15971607  end;
Note: See TracChangeset for help on using the changeset viewer.