Changeset 6
- Timestamp:
- Sep 24, 2019, 10:33:34 PM (5 years ago)
- Files:
-
- 6 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 4 4 lib 5 5 heaptrclog.trc 6 Game2048.exe
-
- Property svn:ignore
-
trunk/Game2048.lpi
r4 r6 7 7 <MainUnit Value="0"/> 8 8 <Title Value="Game2048"/> 9 <Scaled Value="True"/> 9 10 <ResourceType Value="res"/> 10 11 <UseXPManifest Value="True"/> -
trunk/Game2048.lpr
r5 r6 25 25 {$ENDIF} 26 26 RequireDerivedFormResource:=True; 27 Application.Scaled:=True; 27 28 Application.Initialize; 28 29 Application.CreateForm(TFormMain, FormMain); -
trunk/UFormMain.pas
r5 r6 67 67 procedure TFormMain.FormPaint(Sender: TObject); 68 68 begin 69 Game.Render(Canvas );69 Game.Render(Canvas, Point(Width, Height - MainMenu1.Height)); 70 70 end; 71 71 -
trunk/UGame.pas
r5 r6 45 45 procedure New; 46 46 procedure Clear; 47 procedure Render(Canvas: TCanvas );47 procedure Render(Canvas: TCanvas; CanvasSize: TPoint); 48 48 function MoveAll(Direction: TDirection): Integer; 49 49 procedure MoveCell(SourceCell, TargetCell: TCell); … … 198 198 end; 199 199 200 procedure TGame.Render(Canvas: TCanvas );200 procedure TGame.Render(Canvas: TCanvas; CanvasSize: TPoint); 201 201 var 202 202 X, Y: Integer; … … 205 205 Frame: TRect; 206 206 TextSize: TSize; 207 const 208 TopBarHeight = 32; 209 begin 207 TopBarHeight: Integer; 208 begin 209 TopBarHeight := ScaleY(24, 96); 210 210 Canvas.Brush.Style := bsSolid; 211 211 Canvas.Brush.Color := clBlack; 212 212 Canvas.FillRect(0, 0, Canvas.Width, Canvas.Height); 213 213 214 ValueStr := 'Score: ' + IntToStr(Score); 214 215 Canvas.Font.Color := clWhite; 215 Canvas.Font.Height := 20; 216 Canvas.TextOut(16, 4, 'Score: ' + IntToStr(Score)); 217 218 Frame := Rect(0, TopBarHeight, Canvas.Width, Canvas.Height); 216 Canvas.Font.Height := Trunc(TopBarHeight * 0.7); 217 Canvas.TextOut(ScaleY(16, 96), (TopBarHeight - Canvas.TextHeight(ValueStr)) div 2, ValueStr); 218 219 // Form.Canvas.Width and Form.Canvas.Height is not working correctly under Windows. 220 // So dimensions are provided by CanvasSize parameter. 221 Frame := Rect(2, TopBarHeight, CanvasSize.X - 2, CanvasSize.Y - 2); 219 222 CellSize := Point(Frame.Width div Size.X, Frame.Height div Size.Y); 220 223 if CellSize.X < CellSize.Y then CellSize.Y := CellSize.X;
Note:
See TracChangeset
for help on using the changeset viewer.