Changeset 12


Ignore:
Timestamp:
Mar 26, 2015, 11:16:38 PM (10 years ago)
Author:
chronos
Message:
  • Added: 4 more station shapes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UEngine.pas

    r11 r12  
    134134    LastNewPassengerTime: TDateTime;
    135135    LastNewWeekTime: TDateTime;
     136    LastNewShapeTime: TDateTime;
    136137    ImagePassenger: TImage;
    137138    ImageLocomotive: TImage;
     
    142143    procedure DrawShape(Canvas: TCanvas; Position: TPoint; Shape: TStationShape;
    143144      Size: Integer);
     145    procedure DrawClock(Canvas: TCanvas);
    144146    procedure ComputeShapeDistance;
    145147    procedure ComputeShapeDistanceStation(Station: TMetroStation;
    146148      UpdatedShape: TStationShape; Distance: Integer);
    147149    function GetTime: TDateTime;
    148     procedure DrawClock(Canvas: TCanvas);
    149150  public
    150151    Passengers: TMetroPassengers;
     
    590591var
    591592  Points: array of TPoint;
     593  I: Integer;
     594  Angle: Double;
    592595begin
    593596  case Shape of
     
    603606      Points[1] := Point(Position.X + Size div 2, Position.Y + Size div 2);
    604607      Points[2] := Point(Position.X - Size div 2, Position.Y + Size div 2);
     608      Canvas.Polygon(Points);
     609    end;
     610    ssStar: begin
     611      SetLength(Points, 10);
     612      for I := 0 to 9 do begin
     613        Angle := I / 10 * 2 * Pi - Pi / 2;
     614        if (I mod 2) = 0 then
     615        Points[I] := Point(Round(Position.X + Cos(Angle) * Size / 2),
     616          Round(Position.Y + Sin(Angle) * Size / 2))
     617        else
     618        Points[I] := Point(Round(Position.X + Cos(Angle) * Size / 5),
     619          Round(Position.Y + Sin(Angle) * Size / 5));
     620      end;
     621      Canvas.Polygon(Points);
     622    end;
     623    ssPlus: begin
     624      SetLength(Points, 12);
     625      Points[0] := Point(Position.X + Size div 6, Position.Y - Size div 6);
     626      Points[1] := Point(Position.X + Size div 2, Position.Y - Size div 6);
     627      Points[2] := Point(Position.X + Size div 2, Position.Y + Size div 6);
     628      Points[3] := Point(Position.X + Size div 6, Position.Y + Size div 6);
     629      Points[4] := Point(Position.X + Size div 6, Position.Y + Size div 2);
     630      Points[5] := Point(Position.X - Size div 6, Position.Y + Size div 2);
     631      Points[6] := Point(Position.X - Size div 6, Position.Y + Size div 6);
     632      Points[7] := Point(Position.X - Size div 2, Position.Y + Size div 6);
     633      Points[8] := Point(Position.X - Size div 2, Position.Y - Size div 6);
     634      Points[9] := Point(Position.X - Size div 6, Position.Y - Size div 6);
     635      Points[10] := Point(Position.X - Size div 6, Position.Y - Size div 2);
     636      Points[11] := Point(Position.X + Size div 6, Position.Y - Size div 2);
     637      Canvas.Polygon(Points);
     638    end;
     639    ssPentagon: begin
     640      SetLength(Points, 5);
     641      for I := 0 to 4 do begin
     642        Angle := I / 5 * 2 * Pi - Pi / 2;
     643        Points[I] := Point(Round(Position.X + Cos(Angle) * Size / 2),
     644          Round(Position.Y + Sin(Angle) * Size / 2));
     645      end;
     646      Canvas.Polygon(Points);
     647    end;
     648    ssDiamond: begin
     649      SetLength(Points, 4);
     650      Points[0] := Point(Position.X, Position.Y - Size div 2);
     651      Points[1] := Point(Position.X + Size div 2, Position.Y);
     652      Points[2] := Point(Position.X, Position.Y + Size div 2);
     653      Points[3] := Point(Position.X - Size div 2, Position.Y);
    605654      Canvas.Polygon(Points);
    606655    end;
     
    729778  if State = gsRunning then begin
    730779
    731   // Add new stations
     780  // Add new trains
    732781  if (Now - LastNewWeekTime) > 7 then begin
    733782    LastNewWeekTime := Now;
    734783    Trains.AddNew;
    735784    // TODO: Show notification screen with confirmation
     785  end;
     786
     787  // Add new shape
     788  if (Now - LastNewShapeTime) > 10 then begin
     789    LastNewShapeTime := Now;
     790    if ShapeCount <= Integer(High(TStationShape)) then Inc(ShapeCount);
    736791  end;
    737792
     
    9561011  ServedPassengerCount := 0;
    9571012
     1013  // Start with 3 stations with each different shape
    9581014  NewStation := Stations.AddNew;
    9591015  NewStation.Shape := ssSquare;
     
    9731029  LastNewPassengerTime := Now;
    9741030  LastNewWeekTime := Now;
     1031  LastNewShapeTime := Now;
    9751032  State := gsRunning;
    9761033  StartTime := Now;
     
    11111168    end;
    11121169
     1170{
    11131171    Canvas.Brush.Style := bsClear;
    11141172    Text := '';
     
    11161174      Text := Text + IntToStr(ShapeDistance[TStationShape(P)]) + ',';
    11171175    Canvas.TextOut(Position.X + StationSize div 2, Position.Y + StationSize div 2, Text);
     1176    }
    11181177  end;
    11191178
Note: See TracChangeset for help on using the changeset viewer.