Ignore:
Timestamp:
Oct 5, 2019, 2:00:50 PM (5 years ago)
Author:
chronos
Message:
  • Added: Player can undo last move.
  • Modified: Optimized code of TGame.CanMove method.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r19 r20  
    1616    MainMenu1: TMainMenu;
    1717    MenuItem1: TMenuItem;
     18    MenuItem2: TMenuItem;
    1819    MenuItemNew: TMenuItem;
    1920    MenuItemExit: TMenuItem;
     
    4849
    4950procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    50 var
    51   MovedCount: Integer;
    5251begin
    5352  if Core.Game.Running and not Core.Game.Moving then begin
    54     MovedCount := 0;
    5553    case Key of
    56       37: MovedCount := Core.Game.MoveAll(drLeft);
    57       38: MovedCount := Core.Game.MoveAll(drUp);
    58       39: MovedCount := Core.Game.MoveAll(drRight);
    59       40: MovedCount := Core.Game.MoveAll(drDown);
     54      37: Core.Game.MoveAll(drLeft);
     55      38: Core.Game.MoveAll(drUp);
     56      39: Core.Game.MoveAll(drRight);
     57      40: Core.Game.MoveAll(drDown);
    6058    end;
    61     if MovedCount > 0 then Core.Game.FillRandomTile;
    62     if not Core.Game.CanMove and (Core.Game.Board.GetEmptyTilesCount = 0) then
    63       Core.Game.GameOver;
    64     if (not Core.Game.Won) and (Core.Game.Board.GetHighestTileValue >= 2048) then
    65       Core.Game.Win;
    6659  end;
    6760end;
Note: See TracChangeset for help on using the changeset viewer.