Changeset 10 for trunk/Forms
- Timestamp:
- Oct 4, 2019, 11:05:35 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r8 r10 35 35 private 36 36 public 37 Game: TGame;38 procedure GameChange(Sender: TObject);39 37 end; 40 38 … … 55 53 MovedCount: Integer; 56 54 begin 57 if Game.Running then begin55 if Core.Game.Running then begin 58 56 MovedCount := 0; 59 57 case Key of 60 37: MovedCount := Game.MoveAll(drLeft);61 38: MovedCount := Game.MoveAll(drUp);62 39: MovedCount := Game.MoveAll(drRight);63 40: MovedCount := Game.MoveAll(drDown);58 37: MovedCount := Core.Game.MoveAll(drLeft); 59 38: MovedCount := Core.Game.MoveAll(drUp); 60 39: MovedCount := Core.Game.MoveAll(drRight); 61 40: MovedCount := Core.Game.MoveAll(drDown); 64 62 end; 65 if MovedCount > 0 then Game.FillRandomCell;66 if not Game.CanMove and (Game.GetEmptyCellsCount = 0) then67 Game.GameOver;63 if MovedCount > 0 then Core.Game.FillRandomCell; 64 if not Core.Game.CanMove and (Core.Game.GetEmptyCellsCount = 0) then 65 Core.Game.GameOver; 68 66 end; 69 67 end; … … 71 69 procedure TFormMain.FormPaint(Sender: TObject); 72 70 begin 73 Game.Render(Canvas, Point(Width, Height - MainMenu1.Height));71 Core.Game.Render(Canvas, Point(Width, Height - MainMenu1.Height)); 74 72 end; 75 73 … … 78 76 FormNew := TFormNew.Create(nil); 79 77 try 80 FormNew.Load( Game);78 FormNew.Load(Core.Game); 81 79 if FormNew.ShowModal = mrOk then begin 82 FormNew.Save( Game);83 Game.New;80 FormNew.Save(Core.Game); 81 Core.Game.New; 84 82 end; 85 83 finally … … 111 109 procedure TFormMain.FormCreate(Sender: TObject); 112 110 begin 113 Randomize;114 Game := TGame.Create;115 Game.Size := Point(4, 4);116 Game.OnChange := GameChange;117 111 end; 118 112 119 113 procedure TFormMain.FormDestroy(Sender: TObject); 120 114 begin 121 Game.Free;122 115 end; 123 116 … … 126 119 Core.PersistentForm1.RegistryContext := Core.ApplicationInfo1.GetRegistryContext; 127 120 Core.PersistentForm1.Load(Self); 128 Game.New; 129 { 130 Game.Cells[0, 0].Value := 1; 131 Game.Cells[0, 1].Value := 2; 132 Game.Cells[0, 2].Value := 3; 133 Game.Cells[1, 0].Value := 4; 134 Game.Cells[1, 1].Value := 5; 135 Game.Cells[1, 2].Value := 6; 136 Game.Cells[2, 0].Value := 7; 137 Game.Cells[2, 1].Value := 8; 138 Game.Cells[2, 2].Value := 9; 139 } 140 end; 141 142 procedure TFormMain.GameChange(Sender: TObject); 143 begin 144 Repaint; 121 Core.Game.New; 145 122 end; 146 123
Note:
See TracChangeset
for help on using the changeset viewer.