Changeset 68 for trunk


Ignore:
Timestamp:
Jan 26, 2020, 10:57:41 PM (5 years ago)
Author:
chronos
Message:
  • Fixed: Drawing board in AI mode.
  • Fixed: Undo action was not enabled.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormComputer.pas

    r50 r68  
    161161  J: Integer;
    162162  GameTries: TGameTries;
     163  Delay: Integer;
    163164begin
    164165  ButtonStart.Enabled := False;
     
    201202      else Break;
    202203      }
    203       Application.ProcessMessages;
    204       Sleep(TrackBar1.Position);
     204      Delay := TrackBar1.Position;
     205      while Delay > 0 do begin
     206        Application.ProcessMessages;
     207        Sleep(10);
     208        Delay := Delay - 10;
     209      end;
    205210    end;
    206211  end;
  • trunk/Forms/UFormMain.pas

    r67 r68  
    223223    while Length(MoveBuffer) > 0 do begin
    224224      MoveBufferLock.Release;
    225       Core.Game.MoveAllAndUpdate(MoveBuffer[0], True);
     225      Core.Game.MoveAllAndUpdate(MoveBuffer[0], Core.Game.AnimationDuration > 0);
    226226      MoveBufferLock.Acquire;
    227227      if Length(MoveBuffer) > 1 then
  • trunk/UGame.pas

    r65 r68  
    733733  I: Integer;
    734734  Area: TArea;
     735  DstTile: TTile;
     736  SrcTile: TTile;
     737  TileMoved: Boolean;
    735738begin
    736739  if Animation then begin
     
    746749  Board.ClearMerged;
    747750  for I := 0 to Max(Board.Size.X, Board.Size.Y) - 1 do begin
     751    TileMoved := False;
    748752    P := Area.P1;
    749753    while P.Y <> Area.P2.Y + Area.Increment.Y do begin
     
    752756        PNew := P + DirectionDiff[Direction];
    753757        if IsValidPos(PNew) then begin
    754           if (Board.Tiles[P.Y, P.X].Value <> 0) then begin
    755             if (Board.Tiles[PNew.Y, PNew.X].Value = 0) then begin
    756               Board.Tiles[PNew.Y, PNew.X].Value := Board.Tiles[P.Y, P.X].Value;
    757               Board.Tiles[PNew.Y, PNew.X].Merged := Board.Tiles[P.Y, P.X].Merged;
    758               Board.Tiles[P.Y, P.X].Value := 0;
    759               Board.Tiles[P.Y, P.X].Merged := False;
     758          SrcTile := Board.Tiles[P.Y, P.X];
     759          DstTile := Board.Tiles[PNew.Y, PNew.X];
     760          if SrcTile.Value <> 0 then begin
     761            if DstTile.Value = 0 then begin
     762              DstTile.Value := SrcTile.Value;
     763              DstTile.Merged := SrcTile.Merged;
     764              SrcTile.Value := 0;
     765              SrcTile.Merged := False;
     766              TileMoved := True;
    760767            end else
    761             if (not Board.Tiles[P.Y, P.X].Merged) and (not Board.Tiles[PNew.Y, PNew.X].Merged) and
    762             CanMergeTile(Board.Tiles[PNew.Y, PNew.X].Value, Board.Tiles[P.Y, P.X].Value) then begin
    763               Board.Tiles[PNew.Y, PNew.X].Value := MergeTile(Board.Tiles[PNew.Y, PNew.X].Value, Board.Tiles[P.Y, P.X].Value);
    764               Board.Tiles[PNew.Y, PNew.X].Merged := True;
    765               Board.Tiles[P.Y, P.X].Value := 0;
    766               Board.Tiles[P.Y, P.X].Merged := False;
    767               Score := Score + GetTileSkinScore(Board.Tiles[PNew.Y, PNew.X].Value);
     768            if (not SrcTile.Merged) and (not DstTile.Merged) and
     769            CanMergeTile(DstTile.Value, SrcTile.Value) then begin
     770              DstTile.Value := MergeTile(DstTile.Value, SrcTile.Value);
     771              DstTile.Merged := True;
     772              SrcTile.Value := 0;
     773              SrcTile.Merged := False;
     774              Score := Score + GetTileSkinScore(SrcTile.Value);
     775              TileMoved := True;
    768776            end;
    769777          end;
     
    773781      Inc(P.Y, Area.Increment.Y);
    774782    end;
    775     DoPaint;
    776   end;
     783    if not TileMoved then Break;
     784  end;
     785  DoPaint;
    777786  FMoving := False;
    778787end;
     
    811820    if RecordHistory then History.Moves.Delete(History.Moves.Count - 1);
    812821    DoChange;
     822    DoPaint;
    813823  end;
    814824end;
     
    10801090  HistoryMove: THistoryMove;
    10811091  NewTile: TTile;
     1092  X, Y: Integer;
    10821093begin
    10831094  if CanMoveDirection(Direction) then begin
     
    10861097
    10871098    NewTile := FillRandomTile;
    1088     if Animation then AnimateTiles;
     1099    if Animation then AnimateTiles else begin
     1100      for Y := 0 to Board.Size.Y - 1 do
     1101        for X := 0 to Board.Size.X - 1 do
     1102          if Board.Tiles[Y, X].Action <> taNone then begin
     1103            Board.Tiles[Y, X].Action := taNone;
     1104            Board.Tiles[Y, X].Shift := Point(0, 0);
     1105          end;
     1106      DoPaint;
     1107    end;
    10891108
    10901109    if RecordHistory then begin
     
    11001119    if (HighestValue < WinTileValue) and
    11011120    (Board.GetHighestTileValue >= WinTileValue) then Win;
     1121    DoChange;
    11021122  end;
    11031123end;
Note: See TracChangeset for help on using the changeset viewer.