Changeset 27 for trunk/UGame.pas
- Timestamp:
- Oct 5, 2019, 10:55:00 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r21 r27 76 76 procedure New; 77 77 procedure Render(Canvas: TCanvas; CanvasSize: TPoint); 78 function MoveAll(Direction: TDirection): Integer;78 procedure MoveAll(Direction: TDirection); 79 79 procedure MoveTile(SourceTile, TargetTile: TTile); 80 80 function IsValidPos(Pos: TPoint): Boolean; … … 472 472 end; 473 473 474 function TGame.MoveAll(Direction: TDirection): Integer;474 procedure TGame.MoveAll(Direction: TDirection); 475 475 var 476 476 StartPoint: TPoint; … … 481 481 PNew: TPoint; 482 482 PI: TPoint; 483 MovedCount: Integer;484 483 X, Y: Integer; 485 484 I: Integer; … … 490 489 HighestValue: Integer; 491 490 begin 491 if not CanMoveDirection(Direction) then Exit; 492 492 FMoving := True; 493 493 HighestValue := Board.GetHighestTileValue; … … 521 521 end; 522 522 end; 523 MovedCount := 0;524 523 Board.ClearMerged; 525 524 for I := 0 to Max(Board.Size.X, Board.Size.Y) - 1 do begin … … 545 544 Board.Tiles[P.Y, P.X].NewValue := 0; 546 545 Board.Tiles[P.Y, P.X].Merged := False; 547 Inc(MovedCount);548 546 end else 549 547 if (not Board.Tiles[P.Y, P.X].Merged) and (not Board.Tiles[PNew.Y, PNew.X].Merged) and … … 554 552 Board.Tiles[P.Y, P.X].NewValue := 0; 555 553 Board.Tiles[P.Y, P.X].Merged := False; 556 Inc(MovedCount);557 554 Score := Score + Board.Tiles[PNew.Y, PNew.X].NewValue; 558 555 end; … … 596 593 DoChange; 597 594 end; 598 Result := MovedCount;599 595 600 596 // Update state after move 601 if MovedCount > 0 thenFillRandomTile;597 FillRandomTile; 602 598 if not CanMove and (Board.GetEmptyTilesCount = 0) then 603 599 GameOver;
Note:
See TracChangeset
for help on using the changeset viewer.