Changeset 65 for trunk/UGame.pas
- Timestamp:
- Jan 23, 2020, 12:21:53 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r63 r65 104 104 FOnChange: TNotifyEvent; 105 105 FOnGameOver: TNotifyEvent; 106 FOnPaint: TNotifyEvent; 106 107 FOnWin: TNotifyEvent; 107 108 FRecordHistory: Boolean; … … 115 116 procedure SetScore(AValue: Integer); 116 117 procedure DoChange; 118 procedure DoPaint; 117 119 procedure RenderTile(Canvas: TCanvas; Tile: TTile; TileRect: TRect; WithText: Boolean); 118 120 procedure GameOver; … … 129 131 TopScore: Integer; 130 132 AnimationDuration: Integer; 133 AnimationTick: Integer; 131 134 WinTileValue: Integer; 132 135 UndoEnabled: Boolean; … … 155 158 property Running: Boolean read FRunning write FRunning; 156 159 property OnChange: TNotifyEvent read FOnChange write FOnChange; 160 property OnPaint: TNotifyEvent read FOnPaint write FOnPaint; 157 161 property OnWin: TNotifyEvent read FOnWin write FOnWin; 158 162 property OnGameOver: TNotifyEvent read FOnGameOver write FOnGameOver; … … 506 510 end; 507 511 512 procedure TGame.DoPaint; 513 begin 514 if Assigned(FOnPaint) then FOnPaint(Self); 515 end; 516 508 517 procedure TGame.GameOver; 509 518 begin … … 516 525 if FSkin = AValue then Exit; 517 526 FSkin := AValue; 518 Do Change;527 DoPaint; 519 528 end; 520 529 … … 595 604 AnimateTiles; 596 605 DoChange; 606 DoPaint; 597 607 end; 598 608 … … 763 773 Inc(P.Y, Area.Increment.Y); 764 774 end; 765 Do Change;775 DoPaint; 766 776 end; 767 777 FMoving := False; … … 945 955 Trunc(Part * DirectionDiff[Direction].Y * 100)); 946 956 end; 947 Do Change;948 Application.ProcessMessages;949 Sleep( 1);957 DoPaint; 958 //Application.ProcessMessages; 959 Sleep(AnimationTick); 950 960 until Time > EndTime; 951 961 … … 968 978 Board.Tiles[Y, X].Value := Board.Tiles[Y, X].NewValue; 969 979 end; 970 Do Change;980 DoPaint; 971 981 FMoving := False; 972 982 end; … … 1008 1018 Board.Tiles[Y, X].Shift := Point(Trunc(Part * 100), Trunc(Part * 100)); 1009 1019 end; 1010 Do Change;1011 Application.ProcessMessages;1012 Sleep( 1);1020 DoPaint; 1021 //Application.ProcessMessages; 1022 Sleep(AnimationTick); 1013 1023 until Time > EndTime; 1014 1024 … … 1019 1029 Board.Tiles[Y, X].Shift := Point(0, 0); 1020 1030 end; 1021 Do Change;1031 DoPaint; 1022 1032 FMoving := False; 1023 1033 end; … … 1155 1165 end; 1156 1166 DoChange; 1167 DoPaint; 1157 1168 end; 1158 1169 … … 1160 1171 begin 1161 1172 AnimationDuration := 30; 1173 AnimationTick := 10; // ms 1162 1174 WinTileValue := 11; // 2^11 = 2048 1163 1175 Board := TBoard.Create;
Note:
See TracChangeset
for help on using the changeset viewer.