Changeset 107 for trunk/Game.pas
- Timestamp:
- Dec 9, 2024, 10:39:50 PM (12 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Game.pas
r106 r107 63 63 public 64 64 Board: TBoard; 65 InitialBoard: TBoard; 65 66 TopScore: Integer; 66 67 AnimationDuration: Integer; … … 78 79 function CanMove: Boolean; 79 80 procedure Assign(Source: TGame); 81 procedure Reset; 80 82 procedure New; 83 procedure Restart; 81 84 procedure Render(Canvas: TCanvas; CanvasSize: TPoint); 82 85 procedure MoveAll(Direction: TMoveDirection; Animation: Boolean); … … 310 313 end; 311 314 312 procedure TGame.New; 313 var 314 I: Integer; 315 Tile: TTile; 315 procedure TGame.Reset; 316 316 const 317 317 Difficulty = 0.7; … … 323 323 Running := True; 324 324 History.Clear; 325 325 end; 326 327 procedure TGame.New; 328 var 329 I: Integer; 330 Tile: TTile; 331 begin 332 Reset; 326 333 327 334 if RecordHistory then begin … … 351 358 FillUnmergeableRandomTile; 352 359 end; 360 InitialBoard.Assign(Board); 361 AnimateTiles; 362 DoChange; 363 DoPaint; 364 end; 365 366 procedure TGame.Restart; 367 begin 368 Reset; 369 Board.Assign(InitialBoard); 353 370 AnimateTiles; 354 371 DoChange; … … 1038 1055 FBoardUndo.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\BoardUndo')); 1039 1056 Board.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Board')); 1057 InitialBoard.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\InitialBoard')); 1040 1058 History.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\History')); 1041 1059 finally … … 1065 1083 FBoardUndo.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\BoardUndo')); 1066 1084 Board.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Board')); 1085 InitialBoard.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\InitialBoard')); 1067 1086 History.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\History')); 1068 1087 finally … … 1079 1098 WinTileValue := 11; // 2^11 = 2048 1080 1099 Board := TBoard.Create; 1100 InitialBoard := TBoard.Create; 1081 1101 FBoardUndo := TBoard.Create; 1082 1102 History := THistory.Create; … … 1089 1109 FreeAndNil(FBoardUndo); 1090 1110 FreeAndNil(Board); 1111 FreeAndNil(InitialBoard); 1091 1112 inherited; 1092 1113 end;
Note:
See TracChangeset
for help on using the changeset viewer.