Changeset 6


Ignore:
Timestamp:
Mar 26, 2015, 2:40:40 PM (10 years ago)
Author:
chronos
Message:
  • Added: Show line end stations.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UEngine.pas

    r5 r6  
    664664      SelectedStation := Station;
    665665      for I := 0 to Lines.Count - 1 do
    666       if TMetroLine(Lines[I]).Stations.Count = 0 then
     666      if TMetroLine(Lines[I]).Stations.Count = 0 then begin
    667667        SelectedLine := TMetroLine(Lines[I]);
     668        Break;
     669      end;
    668670    end;
    669671
     
    751753  Pos: TPoint;
    752754  Text: string;
     755  Angle: Double;
     756  EndPoint: TPoint;
    753757const
    754758  GameOverText = 'Game Over';
    755759  GameOverReason = 'Overcrowding at this station has forced you to resign as metro manager.';
    756760  GameOverStatistic = '%d passengers travelled on your metro over %d days.';
     761  EndStationLength = 50;
    757762begin
    758763  Canvas.Brush.Color := $eff0e0;
     
    769774    for S := 1 to High(TrackPoints) do begin
    770775      Canvas.LineTo(TrackPoints[S]);
    771     end;
     776      if (S = High(TrackPoints)) then begin
     777        Angle := arctan2((TrackPoints[S].Y - TrackPoints[S - 1].Y), (TrackPoints[S].X - TrackPoints[S - 1].X));
     778        EndPoint := Point(Round(TrackPoints[S].X + EndStationLength * Cos(Angle)),
     779          Round(TrackPoints[S].Y + EndStationLength * Sin(Angle)));
     780        Canvas.LineTo(EndPoint);
     781        Canvas.MoveTo(Point(Round(EndPoint.X + Cos(Angle + Pi / 2) * EndStationLength / 3),
     782          Round(EndPoint.Y + Sin(Angle + Pi / 2) * EndStationLength / 3)));
     783        Canvas.LineTo(Point(Round(EndPoint.X + Cos(Angle - Pi / 2) * EndStationLength / 3),
     784          Round(EndPoint.Y + Sin(Angle - Pi / 2) * EndStationLength / 3)));
     785      end;
     786    end;
     787    if (Length(TrackPoints) > 1) then begin
     788      Angle := arctan2((TrackPoints[1].Y - TrackPoints[0].Y), (TrackPoints[1].X - TrackPoints[0].X));
     789      Canvas.MoveTo(TrackPoints[0]);
     790      EndPoint := Point(Round(TrackPoints[0].X - EndStationLength * Cos(Angle)),
     791        Round(TrackPoints[0].Y - EndStationLength * Sin(Angle)));
     792      Canvas.LineTo(EndPoint);
     793      Canvas.MoveTo(Point(Round(EndPoint.X - Cos(Angle + Pi / 2) * EndStationLength / 3),
     794        Round(EndPoint.Y - Sin(Angle + Pi / 2) * EndStationLength / 3)));
     795      Canvas.LineTo(Point(Round(EndPoint.X - Cos(Angle - Pi / 2) * EndStationLength / 3),
     796        Round(EndPoint.Y - Sin(Angle - Pi / 2) * EndStationLength / 3)));
     797    end;
     798
     799    // Draw design line
    772800    if (SelectedLine = TMetroLine(Lines[I])) and Assigned(SelectedStation) then begin
    773801      Canvas.MoveTo(SelectedStation.Position);
     
    847875
    848876  Text := IntToStr(Trains.GetUnusedCount);
    849   Canvas.Draw(Canvas.Width - 160, 20, ImageLocomotive.Picture.Bitmap);
     877  Canvas.Draw(Canvas.Width - 180, 20, ImageLocomotive.Picture.Bitmap);
    850878  Canvas.Brush.Style := bsClear;
    851   Canvas.TextOut(Canvas.Width - 166 - Canvas.TextWidth(Text), 25, Text);
     879  Canvas.TextOut(Canvas.Width - 186 - Canvas.TextWidth(Text), 25, Text);
    852880
    853881  // Game over
Note: See TracChangeset for help on using the changeset viewer.