Changeset 126 for trunk/UGame.pas


Ignore:
Timestamp:
Jun 17, 2017, 2:54:50 PM (7 years ago)
Author:
chronos
Message:
  • Fixed: Center map to player main city at start.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r125 r126  
    128128    procedure SelectCell(Pos: TPoint; Player: TPlayer; ShiftState: TShiftState);
    129129    procedure CenterMap;
     130    procedure CenterPlayerCity(Player: TPlayer);
    130131    function CanvasToCellPos(Pos: TPoint): TPoint;
    131132    function CellToCanvasPos(Pos: TPoint): TPoint;
     
    22262227end;
    22272228
     2229procedure TView.CenterPlayerCity(Player: TPlayer);
     2230begin
     2231  SourceRect := Bounds(Player.StartCell.PosPx.X - (SourceRect.Right - SourceRect.Left) div 2,
     2232    Player.StartCell.PosPx.Y - (SourceRect.Bottom - SourceRect.Top) div 2,
     2233    SourceRect.Right - SourceRect.Left,
     2234    SourceRect.Bottom - SourceRect.Top);
     2235end;
     2236
    22282237procedure TPlayer.Paint(Canvas: TCanvas; View: TView);
    22292238begin
     
    30483057    View.Clear;
    30493058    View.Zoom := 1;
    3050     View.CenterMap;
     3059    if Assigned(ControlPlayer) then View.CenterPlayerCity(ControlPlayer)
     3060      else View.CenterMap;
    30513061  end;
    30523062end;
Note: See TracChangeset for help on using the changeset viewer.