- Timestamp:
- Oct 13, 2019, 5:34:57 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormComputer.lfm
r32 r38 32 32 TabOrder = 1 33 33 end 34 object TrackBar1: TTrackBar 35 Left = 24 36 Height = 58 37 Top = 104 38 Width = 430 39 Max = 1000 40 Position = 0 41 Anchors = [akTop, akLeft, akRight] 42 TabOrder = 2 43 end 44 object Label1: TLabel 45 Left = 21 46 Height = 26 47 Top = 76 48 Width = 127 49 Caption = 'Delay per step:' 50 ParentColor = False 51 end 34 52 end -
trunk/Forms/UFormComputer.lrj
r32 r38 2 2 {"hash":1113,"name":"tformcomputer.caption","sourcebytes":[65,73],"value":"AI"}, 3 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 {"hash":371552,"name":"tformcomputer.buttonstop.caption","sourcebytes":[83,116,111,112],"value":"Stop"}, 5 {"hash":116494394,"name":"tformcomputer.label1.caption","sourcebytes":[68,101,108,97,121,32,112,101,114,32,115,116,101,112,58],"value":"Delay per step:"} 5 6 ]} -
trunk/Forms/UFormComputer.pas
r32 r38 6 6 7 7 uses 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, UGame, fgl; 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls, 9 UGame, fgl; 9 10 10 11 type … … 30 31 ButtonStart: TButton; 31 32 ButtonStop: TButton; 33 Label1: TLabel; 34 TrackBar1: TTrackBar; 32 35 procedure ButtonStartClick(Sender: TObject); 33 36 procedure ButtonStopClick(Sender: TObject); … … 135 138 ); 136 139 begin 140 ButtonStopClick(Self); 137 141 Core.PersistentForm1.Save(Self); 138 142 end; … … 187 191 S := S + '), '; 188 192 end; 189 MoveAllAndUpdate(GameTries[0].Moves[0] );193 MoveAllAndUpdate(GameTries[0].Moves[0], False); 190 194 { if CanMergeDirection(drDown) then MoveAllAnimate(drDown) 191 195 else if CanMergeDirection(drRight) then MoveAllAnimate(drRight) … … 198 202 } 199 203 Application.ProcessMessages; 200 Sleep( 10);204 Sleep(TrackBar1.Position); 201 205 end; 202 206 end; … … 243 247 NewTry.Game.UndoEnabled := False; 244 248 NewTry.Game.AnimationDuration := 0; 245 NewTry.Game.MoveAll Animate(Direction);249 NewTry.Game.MoveAll(Direction, False); 246 250 SetLength(NewTry.Moves, Length(NewTry.Moves) + 1); 247 251 NewTry.Moves[Length(NewTry.Moves) - 1] := Direction; -
trunk/Forms/UFormMain.pas
r37 r38 57 57 if Core.Game.Running and not Core.Game.Moving then begin 58 58 case Key of 59 37: Core.Game.MoveAllAndUpdate(drLeft );60 38: Core.Game.MoveAllAndUpdate(drUp );61 39: Core.Game.MoveAllAndUpdate(drRight );62 40: Core.Game.MoveAllAndUpdate(drDown );59 37: Core.Game.MoveAllAndUpdate(drLeft, True); 60 38: Core.Game.MoveAllAndUpdate(drUp, True); 61 39: Core.Game.MoveAllAndUpdate(drRight, True); 62 40: Core.Game.MoveAllAndUpdate(drDown, True); 63 63 end; 64 64 end; -
trunk/Languages/Game2048.cs.po
r36 r38 85 85 msgstr "AI" 86 86 87 #: tformcomputer.label1.caption 88 msgid "Delay per step:" 89 msgstr "Pauza každý krok:" 90 87 91 #: tformhelp.caption 88 92 msgctxt "tformhelp.caption" -
trunk/Languages/Game2048.po
r36 r38 75 75 msgstr "" 76 76 77 #: tformcomputer.label1.caption 78 msgid "Delay per step:" 79 msgstr "" 80 77 81 #: tformhelp.caption 78 82 msgctxt "tformhelp.caption" -
trunk/UGame.pas
r37 r38 111 111 function FillRandomTile(Value4Change: Double = 0.1): TTile; 112 112 function GetMoveArea(Direction: TMoveDirection): TArea; 113 procedure MoveAllAnimate(Direction: TMoveDirection); 113 114 public 114 115 Board: TBoard; … … 126 127 procedure New; 127 128 procedure Render(Canvas: TCanvas; CanvasSize: TPoint); 128 procedure MoveAll(Direction: TMoveDirection); 129 procedure MoveAllAnimate(Direction: TMoveDirection); 130 procedure MoveAllAndUpdate(Direction: TMoveDirection); 129 procedure MoveAll(Direction: TMoveDirection; Animation: Boolean); 130 procedure MoveAllAndUpdate(Direction: TMoveDirection; Animation: Boolean); 131 131 procedure MoveTile(SourceTile, TargetTile: TTile); 132 132 function IsValidPos(Pos: TPoint): Boolean; … … 226 226 for I := 0 to Step - 1 do 227 227 with Moves[I] do begin 228 GameStep.MoveAll(Direction );228 GameStep.MoveAll(Direction, False); 229 229 if GameStep.Board.Tiles[NewItemPos.Y, NewItemPos.X].Value = 0 then 230 230 GameStep.Board.Tiles[NewItemPos.Y, NewItemPos.X].Value := NewItemValue … … 608 608 end; 609 609 610 procedure TGame.MoveAll(Direction: TMoveDirection );610 procedure TGame.MoveAll(Direction: TMoveDirection; Animation: Boolean); 611 611 var 612 612 P: TPoint; … … 615 615 Area: TArea; 616 616 begin 617 if Animation then begin 618 MoveAllAnimate(Direction); 619 Exit; 620 end; 617 621 if Direction = drNone then Exit; 618 622 if not CanMoveDirection(Direction) then Exit; … … 856 860 end; 857 861 858 procedure TGame.MoveAllAndUpdate(Direction: TMoveDirection );862 procedure TGame.MoveAllAndUpdate(Direction: TMoveDirection; Animation: Boolean); 859 863 var 860 864 HighestValue: Integer; … … 864 868 if CanMoveDirection(Direction) then begin 865 869 HighestValue := Board.GetHighestTileValue; 866 MoveAll Animate(Direction);870 MoveAll(Direction, Animation); 867 871 868 872 NewTile := FillRandomTile;
Note:
See TracChangeset
for help on using the changeset viewer.