- Timestamp:
- Feb 9, 2014, 5:30:12 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFormMain.lfm
r4 r5 22 22 OnMouseUp = PaintBox1MouseUp 23 23 OnMouseLeave = PaintBox1MouseLeave 24 OnMouseWheelDown = PaintBox1MouseWheelDown 25 OnMouseWheelUp = PaintBox1MouseWheelUp 24 26 OnPaint = PaintBox1Paint 25 27 end -
trunk/UFormMain.pas
r4 r5 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 9 UGame, LCLType, Menus, ActnList; 9 UGame, LCLType, Menus, ActnList, types; 10 11 const 12 ZoomFactor = 1.5; 10 13 11 14 type … … 39 42 procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 40 43 Shift: TShiftState; X, Y: Integer); 44 procedure PaintBox1MouseWheelDown(Sender: TObject; Shift: TShiftState; 45 MousePos: TPoint; var Handled: Boolean); 46 procedure PaintBox1MouseWheelUp(Sender: TObject; Shift: TShiftState; 47 MousePos: TPoint; var Handled: Boolean); 41 48 procedure PaintBox1Paint(Sender: TObject); 42 49 procedure EraseBackground(DC: HDC); override; … … 125 132 end; 126 133 134 procedure TFormMain.PaintBox1MouseWheelDown(Sender: TObject; 135 Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); 136 begin 137 with TPlayer(Game.Players[0]) do 138 ViewZoom := ViewZoom / ZoomFactor; 139 PaintBox1.Repaint; 140 end; 141 142 procedure TFormMain.PaintBox1MouseWheelUp(Sender: TObject; Shift: TShiftState; 143 MousePos: TPoint; var Handled: Boolean); 144 begin 145 with TPlayer(Game.Players[0]) do 146 ViewZoom := ViewZoom * ZoomFactor; 147 PaintBox1.Repaint; 148 end; 149 127 150 end. 128 151 -
trunk/UGame.pas
r4 r5 30 30 31 31 TMap = class 32 CellSize: TPoint;32 DefaultCellSize: TPoint; 33 33 Cells: array of array of TCell; 34 procedure Paint(Canvas: TCanvas; Rect: TRect );34 procedure Paint(Canvas: TCanvas; Rect: TRect; Zoom: Double); 35 35 constructor Create; 36 36 destructor Destroy; override; … … 45 45 View: TRect; 46 46 Color: TColor; 47 ViewZoom: Double; 47 48 procedure Paint(PaintBox: TPaintBox); 49 constructor Create; 48 50 end; 49 51 … … 81 83 View := Bounds(View.Left, View.Top, PaintBox.Width, 82 84 PaintBox.Height); 83 Game.Map.Paint(PaintBox.Canvas, View); 85 Game.Map.Paint(PaintBox.Canvas, View, ViewZoom); 86 end; 87 88 constructor TPlayer.Create; 89 begin 90 ViewZoom := 1; 84 91 end; 85 92 … … 135 142 { TMap } 136 143 137 procedure TMap.Paint(Canvas: TCanvas; Rect: TRect );144 procedure TMap.Paint(Canvas: TCanvas; Rect: TRect; Zoom: Double); 138 145 var 139 146 CX, CY: Integer; … … 141 148 HexShift: TFloatPoint; 142 149 HexSize: TFloatPoint; 150 CellSize: TFloatPoint; 143 151 144 152 procedure PaintHexagon(X, Y: Double; Text: string); … … 166 174 *) 167 175 Font.Color := clWhite; 176 Font.Size := Trunc(12 * Zoom); 168 177 TextOut(Round(X) - TextWidth(Text) div 2, Round(Y) - TextHeight(Text) div 2, Text); 169 178 end; … … 171 180 172 181 begin 182 CellSize := FloatPoint(DefaultCellSize.X / 1.15 * Zoom, DefaultCellSize.Y / 1.35 * Zoom); 173 183 HexShift := FloatPoint(0.5 * cos(30 / 180 * Pi), 174 184 0.5 * sin(30 / 180 * Pi)); 175 HexSize := FloatPoint( CellSize.X * 1.15, CellSize.Y * 1.35);185 HexSize := FloatPoint(DefaultCellSize.X * Zoom, DefaultCellSize.Y * Zoom); 176 186 with Canvas do try 177 187 Lock; … … 198 208 constructor TMap.Create; 199 209 begin 200 CellSize := Point(62, 62);210 DefaultCellSize := Point(62, 62); 201 211 end; 202 212 203 213 destructor TMap.Destroy; 204 214 begin 205 Init( 0, 0);215 Init(Point(0, 0)); 206 216 inherited Destroy; 207 217 end;
Note:
See TracChangeset
for help on using the changeset viewer.