Changeset 32 for trunk/Forms
- Timestamp:
- Oct 12, 2019, 11:01:10 PM (5 years ago)
- Location:
- trunk/Forms
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormComputer.lfm
r29 r32 13 13 OnShow = FormShow 14 14 LCLVersion = '2.0.2.0' 15 object ButtonS olve: TButton16 Left = 15915 object ButtonStart: TButton 16 Left = 40 17 17 Height = 38 18 Top = 2 8118 Top = 24 19 19 Width = 113 20 Caption = 'S olve'21 OnClick = ButtonS olveClick20 Caption = 'Start' 21 OnClick = ButtonStartClick 22 22 TabOrder = 0 23 23 end 24 object ButtonStop: TButton 25 Left = 208 26 Height = 38 27 Top = 24 28 Width = 113 29 Caption = 'Stop' 30 Enabled = False 31 OnClick = ButtonStopClick 32 TabOrder = 1 33 end 24 34 end -
trunk/Forms/UFormComputer.lrj
r29 r32 1 1 {"version":1,"strings":[ 2 2 {"hash":1113,"name":"tformcomputer.caption","sourcebytes":[65,73],"value":"AI"}, 3 {"hash":5923781,"name":"tformcomputer.buttonsolve.caption","sourcebytes":[83,111,108,118,101],"value":"Solve"} 3 {"hash":5941396,"name":"tformcomputer.buttonstart.caption","sourcebytes":[83,116,97,114,116],"value":"Start"}, 4 {"hash":371552,"name":"tformcomputer.buttonstop.caption","sourcebytes":[83,116,111,112],"value":"Stop"} 4 5 ]} -
trunk/Forms/UFormComputer.pas
r31 r32 28 28 29 29 TFormComputer = class(TForm) 30 ButtonSolve: TButton; 31 procedure ButtonSolveClick(Sender: TObject); 30 ButtonStart: TButton; 31 ButtonStop: TButton; 32 procedure ButtonStartClick(Sender: TObject); 33 procedure ButtonStopClick(Sender: TObject); 32 34 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 33 35 procedure FormCreate(Sender: TObject); … … 35 37 procedure FormShow(Sender: TObject); 36 38 private 39 Stop: Boolean; 37 40 GameTries1: TGameTries; 38 41 GameTries2: TGameTries; … … 147 150 end; 148 151 149 procedure TFormComputer.ButtonS olveClick(Sender: TObject);152 procedure TFormComputer.ButtonStartClick(Sender: TObject); 150 153 var 151 154 NewTry: TGameTry; … … 155 158 GameTries: TGameTries; 156 159 begin 160 ButtonStart.Enabled := False; 161 ButtonStop.Enabled := True; 162 Stop := False; 157 163 with Core.Game do begin 158 while CanMove do begin164 while CanMove and not Stop do begin 159 165 NewTry := TGameTry.Create; 160 166 NewTry.Game.Assign(Core.Game); … … 182 188 end; 183 189 MoveAllAndUpdate(GameTries[0].Moves[0]); 184 { if CanMergeDirection(drDown) then MoveAll (drDown)185 else if CanMergeDirection(drRight) then MoveAll (drRight)186 else if CanMergeDirection(drLeft) then MoveAll (drLeft)187 else if CanMoveDirection(drDown) then MoveAll (drDown)188 else if CanMoveDirection(drRight) then MoveAll (drRight)189 else if CanMoveDirection(drLeft) then MoveAll (drLeft)190 else if CanMoveDirection(drUp) then MoveAll (drUp)190 { if CanMergeDirection(drDown) then MoveAllAnimate(drDown) 191 else if CanMergeDirection(drRight) then MoveAllAnimate(drRight) 192 else if CanMergeDirection(drLeft) then MoveAllAnimate(drLeft) 193 else if CanMoveDirection(drDown) then MoveAllAnimate(drDown) 194 else if CanMoveDirection(drRight) then MoveAllAnimate(drRight) 195 else if CanMoveDirection(drLeft) then MoveAllAnimate(drLeft) 196 else if CanMoveDirection(drUp) then MoveAllAnimate(drUp) 191 197 else Break; 192 198 } … … 195 201 end; 196 202 end; 203 ButtonStart.Enabled := True; 204 ButtonStop.Enabled := False; 205 end; 206 207 procedure TFormComputer.ButtonStopClick(Sender: TObject); 208 begin 209 Stop := True; 197 210 end; 198 211 … … 224 237 NewTry: TGameTry; 225 238 begin 226 for Direction := Low(TMoveDirection) to High(TMoveDirection)do begin239 for Direction := drLeft to drDown do begin 227 240 if GameTry.Game.CanMoveDirection(Direction) then begin 228 241 NewTry := TGameTry.Create; … … 230 243 NewTry.Game.UndoEnabled := False; 231 244 NewTry.Game.AnimationDuration := 0; 232 NewTry.Game.MoveAll (Direction);245 NewTry.Game.MoveAllAnimate(Direction); 233 246 SetLength(NewTry.Moves, Length(NewTry.Moves) + 1); 234 247 NewTry.Moves[Length(NewTry.Moves) - 1] := Direction;
Note:
See TracChangeset
for help on using the changeset viewer.