- Timestamp:
- Mar 26, 2015, 11:16:38 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UEngine.pas
r11 r12 134 134 LastNewPassengerTime: TDateTime; 135 135 LastNewWeekTime: TDateTime; 136 LastNewShapeTime: TDateTime; 136 137 ImagePassenger: TImage; 137 138 ImageLocomotive: TImage; … … 142 143 procedure DrawShape(Canvas: TCanvas; Position: TPoint; Shape: TStationShape; 143 144 Size: Integer); 145 procedure DrawClock(Canvas: TCanvas); 144 146 procedure ComputeShapeDistance; 145 147 procedure ComputeShapeDistanceStation(Station: TMetroStation; 146 148 UpdatedShape: TStationShape; Distance: Integer); 147 149 function GetTime: TDateTime; 148 procedure DrawClock(Canvas: TCanvas);149 150 public 150 151 Passengers: TMetroPassengers; … … 590 591 var 591 592 Points: array of TPoint; 593 I: Integer; 594 Angle: Double; 592 595 begin 593 596 case Shape of … … 603 606 Points[1] := Point(Position.X + Size div 2, Position.Y + Size div 2); 604 607 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); 605 654 Canvas.Polygon(Points); 606 655 end; … … 729 778 if State = gsRunning then begin 730 779 731 // Add new stations780 // Add new trains 732 781 if (Now - LastNewWeekTime) > 7 then begin 733 782 LastNewWeekTime := Now; 734 783 Trains.AddNew; 735 784 // 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); 736 791 end; 737 792 … … 956 1011 ServedPassengerCount := 0; 957 1012 1013 // Start with 3 stations with each different shape 958 1014 NewStation := Stations.AddNew; 959 1015 NewStation.Shape := ssSquare; … … 973 1029 LastNewPassengerTime := Now; 974 1030 LastNewWeekTime := Now; 1031 LastNewShapeTime := Now; 975 1032 State := gsRunning; 976 1033 StartTime := Now; … … 1111 1168 end; 1112 1169 1170 { 1113 1171 Canvas.Brush.Style := bsClear; 1114 1172 Text := ''; … … 1116 1174 Text := Text + IntToStr(ShapeDistance[TStationShape(P)]) + ','; 1117 1175 Canvas.TextOut(Position.X + StationSize div 2, Position.Y + StationSize div 2, Text); 1176 } 1118 1177 end; 1119 1178
Note:
See TracChangeset
for help on using the changeset viewer.