Changeset 3
- Timestamp:
- Dec 6, 2018, 11:39:27 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r1 r3 30 30 FRunning: Boolean; 31 31 FSize: TPoint; 32 function GetCellColor(Value: Integer): TColor; 32 33 procedure SetSize(AValue: TPoint); 33 34 procedure GetEmptyCells(EmptyCells: TCells); … … 47 48 procedure MoveCell(SourceCell, TargetCell: TCell); 48 49 function IsValidPos(Pos: TPoint): Boolean; 50 constructor Create; 49 51 property Size: TPoint read FSize write SetSize; 50 52 property Running: Boolean read FRunning write FRunning; … … 204 206 Canvas.Font.Height := Trunc(CellSize.Y * 0.7); 205 207 for Y := 0 to Size.Y - 1 do 206 for X := 0 to Size.X - 1 do 207 if Cells[Y, X].Value <> 0 then begin 208 ValueStr := IntToStr(Cells[Y, X].Value); 209 Canvas.TextOut(X * CellSize.X + CellSize.X div 2 - 210 Canvas.TextWidth(ValueStr) div 2, Y * CellSize.Y, ValueStr); 208 for X := 0 to Size.X - 1 do begin 209 Canvas.Brush.Color := GetCellColor(Cells[Y, X].Value); 210 Canvas.Brush.Style := bsSolid; 211 Canvas.FillRect(Rect(X * CellSize.X, Y * CellSize.Y, 212 (X + 1) * CellSize.X, (Y + 1) * CellSize.Y)); 213 if Cells[Y, X].Value <> 0 then begin 214 ValueStr := IntToStr(Cells[Y, X].Value); 215 Canvas.TextOut(X * CellSize.X + CellSize.X div 2 - 216 Canvas.TextWidth(ValueStr) div 2, Y * CellSize.Y, ValueStr); 217 end; 211 218 end; 212 219 … … 305 312 end; 306 313 314 constructor TGame.Create; 315 begin 316 end; 317 318 function TGame.GetCellColor(Value: Integer): TColor; 319 begin 320 case Value of 321 0: Result := $f2f6f9; 322 2: Result := $dae4ee; 323 4: Result := $c8e0ed; 324 8: Result := $79b1f2; 325 16: Result := $6395f5; 326 32: Result := $5f7cf6; 327 64: Result := $3b5ef6; 328 128: Result := $72cfed; 329 256: Result := $61cced; 330 512: Result := $50c8ed; 331 1024: Result := $3fc5ed; 332 2048: Result := $2ec2ed; 333 else Result := $323a3c; 334 end; 335 end; 336 307 337 end. 308 338
Note:
See TracChangeset
for help on using the changeset viewer.