Changeset 38 for trunk/UGame.pas


Ignore:
Timestamp:
Oct 13, 2019, 5:34:57 PM (5 years ago)
Author:
chronos
Message:
  • Added: In computer AI form allow to set delay of steps computation. Set to zero means fastest processing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r37 r38  
    111111    function FillRandomTile(Value4Change: Double = 0.1): TTile;
    112112    function GetMoveArea(Direction: TMoveDirection): TArea;
     113    procedure MoveAllAnimate(Direction: TMoveDirection);
    113114  public
    114115    Board: TBoard;
     
    126127    procedure New;
    127128    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);
    131131    procedure MoveTile(SourceTile, TargetTile: TTile);
    132132    function IsValidPos(Pos: TPoint): Boolean;
     
    226226  for I := 0 to Step - 1 do
    227227  with Moves[I] do begin
    228     GameStep.MoveAll(Direction);
     228    GameStep.MoveAll(Direction, False);
    229229    if GameStep.Board.Tiles[NewItemPos.Y, NewItemPos.X].Value = 0 then
    230230      GameStep.Board.Tiles[NewItemPos.Y, NewItemPos.X].Value := NewItemValue
     
    608608end;
    609609
    610 procedure TGame.MoveAll(Direction: TMoveDirection);
     610procedure TGame.MoveAll(Direction: TMoveDirection; Animation: Boolean);
    611611var
    612612  P: TPoint;
     
    615615  Area: TArea;
    616616begin
     617  if Animation then begin
     618    MoveAllAnimate(Direction);
     619    Exit;
     620  end;
    617621  if Direction = drNone then Exit;
    618622  if not CanMoveDirection(Direction) then Exit;
     
    856860end;
    857861
    858 procedure TGame.MoveAllAndUpdate(Direction: TMoveDirection);
     862procedure TGame.MoveAllAndUpdate(Direction: TMoveDirection; Animation: Boolean);
    859863var
    860864  HighestValue: Integer;
     
    864868  if CanMoveDirection(Direction) then begin
    865869    HighestValue := Board.GetHighestTileValue;
    866     MoveAllAnimate(Direction);
     870    MoveAll(Direction, Animation);
    867871
    868872    NewTile := FillRandomTile;
Note: See TracChangeset for help on using the changeset viewer.