- Timestamp:
- Oct 5, 2019, 11:29:11 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r20 r28 4 4 Top = 307 5 5 Width = 580 6 Caption = '2048 game'6 Caption = '2048' 7 7 DesignTimePPI = 144 8 8 Menu = MainMenu1 … … 34 34 object MenuItemHelp: TMenuItem 35 35 Caption = 'Help' 36 object MenuItem3: TMenuItem 37 Action = Core.AHelp 38 end 36 39 object MenuItemAbout: TMenuItem 37 40 Action = Core.AAbout -
trunk/Forms/UFormMain.lrj
r11 r28 1 1 {"version":1,"strings":[ 2 {"hash": 128377605,"name":"tformmain.caption","sourcebytes":[50,48,52,56,32,103,97,109,101],"value":"2048 game"},2 {"hash":217976,"name":"tformmain.caption","sourcebytes":[50,48,52,56],"value":"2048"}, 3 3 {"hash":317493,"name":"tformmain.menuitemgame.caption","sourcebytes":[71,97,109,101],"value":"Game"}, 4 4 {"hash":322608,"name":"tformmain.menuitemhelp.caption","sourcebytes":[72,101,108,112],"value":"Help"} -
trunk/Forms/UFormMain.pas
r20 r28 17 17 MenuItem1: TMenuItem; 18 18 MenuItem2: TMenuItem; 19 MenuItem3: TMenuItem; 19 20 MenuItemNew: TMenuItem; 20 21 MenuItemExit: TMenuItem; -
trunk/Forms/UFormNew.lfm
r20 r28 1 1 object FormNew: TFormNew 2 Left = 7 532 Left = 703 3 3 Height = 212 4 Top = 8254 Top = 748 5 5 Width = 487 6 6 Caption = 'New game' … … 60 60 TabOrder = 2 61 61 end 62 object CheckBoxUndoEnabled: TCheckBox 63 Left = 16 64 Height = 30 65 Top = 56 66 Width = 145 67 Caption = 'Undo enabled' 68 TabOrder = 3 69 end 62 70 end -
trunk/Forms/UFormNew.lrj
r8 r28 3 3 {"hash":103901194,"name":"tformnew.label1.caption","sourcebytes":[66,111,97,114,100,32,115,105,122,101,58],"value":"Board size:"}, 4 4 {"hash":77089212,"name":"tformnew.buttoncancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"}, 5 {"hash":1339,"name":"tformnew.buttonok.caption","sourcebytes":[79,75],"value":"OK"} 5 {"hash":1339,"name":"tformnew.buttonok.caption","sourcebytes":[79,75],"value":"OK"}, 6 {"hash":260260820,"name":"tformnew.checkboxundoenabled.caption","sourcebytes":[85,110,100,111,32,101,110,97,98,108,101,100],"value":"Undo enabled"} 6 7 ]} -
trunk/Forms/UFormNew.pas
r20 r28 16 16 ButtonCancel: TButton; 17 17 ButtonOk: TButton; 18 CheckBoxUndoEnabled: TCheckBox; 18 19 ComboBoxSize: TComboBox; 19 20 Label1: TLabel; … … 46 47 begin 47 48 ComboBoxSize.ItemIndex := Game.Board.Size.X - 2; 49 CheckBoxUndoEnabled.Checked := Game.UndoEnabled; 48 50 end; 49 51 … … 51 53 begin 52 54 Game.Board.Size := Point(2 + ComboBoxSize.ItemIndex, 2 + ComboBoxSize.ItemIndex); 55 Game.UndoEnabled := CheckBoxUndoEnabled.Checked; 53 56 end; 54 57 -
trunk/Game2048.lpi
r8 r28 82 82 </Item2> 83 83 </RequiredPackages> 84 <Units Count=" 7">84 <Units Count="8"> 85 85 <Unit0> 86 86 <Filename Value="Game2048.lpr"/> … … 126 126 <ResourceBaseClass Value="DataModule"/> 127 127 </Unit6> 128 <Unit7> 129 <Filename Value="Forms/UFormHelp.pas"/> 130 <IsPartOfProject Value="True"/> 131 <ComponentName Value="FormHelp"/> 132 <ResourceBaseClass Value="Form"/> 133 </Unit7> 128 134 </Units> 129 135 </ProjectOptions> -
trunk/Game2048.lpr
r8 r28 8 8 {$ENDIF} 9 9 Interfaces, SysUtils,// this includes the LCL widgetset 10 Forms, UGame, Common, UFormSettings, UFormMain, UCore 10 Forms, UGame, Common, UFormSettings, UFormMain, UCore, UFormHelp 11 11 { you can add units after this }; 12 12 -
trunk/Languages/Game2048.cs.po
r21 r28 21 21 msgid "Exit" 22 22 msgstr "Ukončít" 23 24 #: tcore.ahelp.caption 25 msgctxt "tcore.ahelp.caption" 26 msgid "Help" 27 msgstr "Nápověda" 23 28 24 29 #: tcore.anew.caption … … 57 62 msgstr " " 58 63 64 #: tformhelp.caption 65 msgctxt "tformhelp.caption" 66 msgid "Help" 67 msgstr "Nápověda" 68 59 69 #: tformmain.caption 60 msgid "2048 game"70 msgid "2048" 61 71 msgstr "2048" 62 72 … … 66 76 67 77 #: tformmain.menuitemhelp.caption 78 msgctxt "tformmain.menuitemhelp.caption" 68 79 msgid "Help" 69 80 msgstr "Nápověda" … … 82 93 msgid "New game" 83 94 msgstr "Nová hra" 95 96 #: tformnew.checkboxundoenabled.caption 97 msgid "Undo enabled" 98 msgstr "Vrátit zpět povoleno" 84 99 85 100 #: tformnew.label1.caption … … 122 137 msgstr "Verze" 123 138 139 #: uformhelp.scontrols 140 msgid "Use arrow keys to slide blocks to one of board side." 141 msgstr "Použij klávesy šipek k posunutí bloků do jedné ze stran desky." 142 143 #: uformhelp.severyturn 144 msgid "Every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4." 145 msgstr "Každý tah se náhodně objeví nová dlaždice v prázdném místě desky s hodnotou 2 nebo 4." 146 147 #: uformhelp.sparagraph1 148 msgid "2048 is a single-player block sliding puzzle game." 149 msgstr "2048 je jednouživatelská logická hra s posouváním bloků." 150 151 #: uformhelp.sparagraph2 152 msgid "The game's objective is to slide numbered tiles on a grid to combine them to create a tile with the number 2048." 153 msgstr "Cílem hry je posouvat očíslované dlaždice na mřížce k jejich spojení a vytvoření dlaždice s číslem 2048." 154 155 #: uformhelp.sundo 156 msgid "You can undo one move back, if undo action is enabled." 157 msgstr "Můžete vrátit zpět jeden pohyb, pokud je akce vrátit zpět povolena." 158 124 159 #: uformsettings.slanguagechangemessage 125 160 msgid "Interface language was changed. It may require restart of application." -
trunk/Languages/Game2048.po
r21 r28 10 10 msgctxt "tcore.aexit.caption" 11 11 msgid "Exit" 12 msgstr "" 13 14 #: tcore.ahelp.caption 15 msgctxt "tcore.ahelp.caption" 16 msgid "Help" 12 17 msgstr "" 13 18 … … 47 52 msgstr "" 48 53 54 #: tformhelp.caption 55 msgctxt "tformhelp.caption" 56 msgid "Help" 57 msgstr "" 58 49 59 #: tformmain.caption 50 msgid "2048 game"60 msgid "2048" 51 61 msgstr "" 52 62 … … 56 66 57 67 #: tformmain.menuitemhelp.caption 68 msgctxt "tformmain.menuitemhelp.caption" 58 69 msgid "Help" 59 70 msgstr "" … … 71 82 #: tformnew.caption 72 83 msgid "New game" 84 msgstr "" 85 86 #: tformnew.checkboxundoenabled.caption 87 msgid "Undo enabled" 73 88 msgstr "" 74 89 … … 112 127 msgstr "" 113 128 129 #: uformhelp.scontrols 130 msgid "Use arrow keys to slide blocks to one of board side." 131 msgstr "" 132 133 #: uformhelp.severyturn 134 msgid "Every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4." 135 msgstr "" 136 137 #: uformhelp.sparagraph1 138 msgid "2048 is a single-player block sliding puzzle game." 139 msgstr "" 140 141 #: uformhelp.sparagraph2 142 msgid "The game's objective is to slide numbered tiles on a grid to combine them to create a tile with the number 2048." 143 msgstr "" 144 145 #: uformhelp.sundo 146 msgid "You can undo one move back, if undo action is enabled." 147 msgstr "" 148 114 149 #: uformsettings.slanguagechangemessage 115 150 msgid "Interface language was changed. It may require restart of application." -
trunk/UCore.lfm
r20 r28 21 21 Identification = 1 22 22 VersionMajor = 1 23 VersionMinor = 023 VersionMinor = 1 24 24 VersionBugFix = 0 25 25 HomePage = 'https://app.zdechov.net/2048' … … 27 27 EmailContact = 'robie@centrum.cz' 28 28 AppName = '2048' 29 Description = ' Classic 2048puzzle game.'30 ReleaseDate = 4374 229 Description = 'A single-player sliding block puzzle game.' 30 ReleaseDate = 43743 31 31 RegistryKey = '\Software\Chronosoft\2048' 32 32 RegistryRoot = rrKeyCurrentUser … … 41 41 end 42 42 object ActionList1: TActionList 43 left = 4 2043 left = 416 44 44 top = 184 45 45 object ANew: TAction … … 66 66 ShortCut = 114 67 67 end 68 object AHelp: TAction 69 Caption = 'Help' 70 OnExecute = AHelpExecute 71 ShortCut = 112 72 end 68 73 end 69 74 end -
trunk/UCore.lrj
r20 r28 4 4 {"hash":4691652,"name":"tcore.aabout.caption","sourcebytes":[65,98,111,117,116],"value":"About"}, 5 5 {"hash":213582195,"name":"tcore.asettings.caption","sourcebytes":[83,101,116,116,105,110,103,115],"value":"Settings"}, 6 {"hash":378031,"name":"tcore.aundo.caption","sourcebytes":[85,110,100,111],"value":"Undo"} 6 {"hash":378031,"name":"tcore.aundo.caption","sourcebytes":[85,110,100,111],"value":"Undo"}, 7 {"hash":322608,"name":"tcore.ahelp.caption","sourcebytes":[72,101,108,112],"value":"Help"} 7 8 ]} -
trunk/UCore.pas
r21 r28 15 15 TCore = class(TDataModule) 16 16 AAbout: TAction; 17 AHelp: TAction; 17 18 AUndo: TAction; 18 19 ASettings: TAction; … … 26 27 procedure AAboutExecute(Sender: TObject); 27 28 procedure AExitExecute(Sender: TObject); 29 procedure AHelpExecute(Sender: TObject); 28 30 procedure ANewExecute(Sender: TObject); 29 31 procedure ASettingsExecute(Sender: TObject); … … 48 50 49 51 uses 50 UFormMain, UFormSettings, UFormAbout, UFormNew ;52 UFormMain, UFormSettings, UFormAbout, UFormNew, UFormHelp; 51 53 52 54 { TCore } … … 98 100 end; 99 101 102 procedure TCore.AHelpExecute(Sender: TObject); 103 begin 104 FormHelp := TFormHelp.Create(nil); 105 try 106 FormHelp.ShowModal; 107 finally 108 FreeAndNil(FormHelp); 109 end; 110 end; 111 100 112 procedure TCore.ANewExecute(Sender: TObject); 101 113 begin … … 126 138 procedure TCore.UpdateInterface; 127 139 begin 128 AUndo.Enabled := Game.CanUndo; ;140 AUndo.Enabled := Game.CanUndo; 129 141 end; 130 142 -
trunk/UGame.pas
r27 r28 64 64 procedure GameOver; 65 65 procedure Win; 66 function FillRandomTile : Integer;66 function FillRandomTile(Value4Change: Double = 0.1): Integer; 67 67 public 68 68 Board: TBoard; … … 70 70 AnimationDuration: Integer; 71 71 WinScore: Integer; 72 UndoEnabled: Boolean; 72 73 function CanUndo: Boolean; 73 74 procedure Undo; … … 268 269 end; 269 270 270 function TGame.FillRandomTile : Integer;271 function TGame.FillRandomTile(Value4Change: Double = 0.1): Integer; 271 272 var 272 273 EmptyTiles: TTiles; 274 NewValue: Integer; 273 275 begin 274 276 Result := 0; … … 276 278 Board.GetEmptyTiles(EmptyTiles); 277 279 if EmptyTiles.Count > 0 then begin 278 EmptyTiles[Random(EmptyTiles.Count)].Value := 2; 280 if Random < Value4Change then NewValue := 4 else NewValue := 2; 281 EmptyTiles[Random(EmptyTiles.Count)].Value := NewValue; 279 282 Result := 1; 280 283 end; … … 304 307 Score := 0; 305 308 Running := True; 306 for I := 0 to 1 do FillRandomTile ;309 for I := 0 to 1 do FillRandomTile(0); 307 310 DoChange; 308 311 end; … … 399 402 function TGame.CanUndo: Boolean; 400 403 begin 401 Result := FCanUndo;404 Result := UndoEnabled and FCanUndo; 402 405 end; 403 406 404 407 procedure TGame.Undo; 405 408 begin 406 if CanUndo then begin409 if UndoEnabled and CanUndo then begin 407 410 Board.Assign(FBoardUndo); 408 411 FCanUndo := False; … … 629 632 WriteBool('GameRunning', FRunning); 630 633 WriteBool('CanUndo', FCanUndo); 634 WriteBool('UndoEnabled', UndoEnabled); 631 635 finally 632 636 Free; … … 646 650 FRunning := ReadBoolWithDefault('GameRunning', False); 647 651 FCanUndo := ReadBoolWithDefault('CanUndo', False); 652 UndoEnabled := ReadBoolWithDefault('UndoEnabled', True); 648 653 finally 649 654 Free;
Note:
See TracChangeset
for help on using the changeset viewer.