- Timestamp:
- Mar 26, 2015, 5:40:03 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UEngine.pas
r7 r8 134 134 procedure ComputeShapeDistanceStation(Station: TMetroStation; 135 135 UpdatedShape: TStationShape; Distance: Integer); 136 function GetTime: TDateTime; 137 procedure DrawClock(Canvas: TCanvas); 136 138 public 137 139 Passengers: TMetroPassengers; … … 146 148 ServedPassengerCount: Integer; 147 149 State: TGameState; 148 Time: TDateTime;150 StartTime: TDateTime; 149 151 procedure Tick; 150 152 procedure MouseMove(Position: TPoint); … … 155 157 destructor Destroy; override; 156 158 procedure Paint(Canvas: TCanvas); 159 property Time: TDateTime read GetTime; 157 160 end; 158 161 … … 569 572 end; 570 573 574 function TEngine.GetTime: TDateTime; 575 begin 576 Result := (Now - StartTime) / OneSecond * (60 * OneMinute); 577 end; 578 579 procedure TEngine.DrawClock(Canvas: TCanvas); 580 var 581 ClockCenter: TPoint; 582 Angle: Double; 583 Text: string; 584 I: Integer; 585 const 586 ClockSize = 20; 587 begin 588 Canvas.Pen.Style := psSolid; 589 Canvas.Pen.Color := clBlack; 590 Canvas.Pen.Width := 2; 591 ClockCenter := Point(Canvas.Width - 30, 40); 592 Angle := Time / (12 * OneHour) * 2 * Pi - Pi / 2; 593 Canvas.EllipseC(ClockCenter.X, ClockCenter.Y, ClockSize, ClockSize); 594 Canvas.Line(ClockCenter, Point(ClockCenter.X + Round(Cos(Angle) * ClockSize * 0.8), 595 ClockCenter.Y + Round(Sin(Angle) * ClockSize * 0.8))); 596 Text := FormatDateTime('ddd', Time); 597 Canvas.TextOut(ClockCenter.X - ClockSize - Canvas.TextWidth(Text) - 5, ClockCenter.Y - 598 Canvas.TextWidth(Text) div 2, Text); 599 for I := 0 to 12 do begin 600 Angle := I / 12 * 2 * Pi; 601 Canvas.Line(ClockCenter.X + Round(Cos(Angle) * ClockSize * 0.8), 602 ClockCenter.Y + Round(Sin(Angle) * ClockSize * 0.8), 603 ClockCenter.X + Round(Cos(Angle) * ClockSize * 0.9), 604 ClockCenter.Y + Round(Sin(Angle) * ClockSize * 0.9)); 605 end; 606 end; 607 571 608 procedure TEngine.Tick; 572 609 const … … 584 621 begin 585 622 if State = gsRunning then begin 586 Time := Time + OneMinute;587 623 588 624 // Add new stations … … 754 790 if Assigned(Station) then begin 755 791 SelectedStation := Station; 792 if not Assigned(SelectedLine) then 756 793 for I := 0 to Lines.Count - 1 do 757 794 if TMetroLine(Lines[I]).Stations.Count = 0 then begin … … 801 838 LastNewPassengerTime := Now; 802 839 State := gsRunning; 803 Time := 0;840 StartTime := Now; 804 841 end; 805 842 … … 928 965 Canvas.Pen.Color := clBlack; 929 966 DrawShape(Canvas, Position, Shape, StationSize); 930 Text := '';931 for P := 0 to 2 do932 Text := Text + IntToStr(ShapeDistance[TStationShape(P)]) + ',';933 Canvas.TextOut(Position.X + 20, Position.Y + 20, Text);934 967 935 968 // Draw passengers … … 965 998 // Interface 966 999 Text := IntToStr(ServedPassengerCount); 967 Canvas.Draw(Canvas.Width - 1 00, 20, ImagePassenger.Picture.Bitmap);1000 Canvas.Draw(Canvas.Width - 140, 20, ImagePassenger.Picture.Bitmap); 968 1001 Canvas.Brush.Style := bsClear; 969 Canvas.TextOut(Canvas.Width - 1 06 - Canvas.TextWidth(Text), 25, Text);1002 Canvas.TextOut(Canvas.Width - 146 - Canvas.TextWidth(Text), 25, Text); 970 1003 971 1004 Text := IntToStr(Trains.GetUnusedCount); 972 Canvas.Draw(Canvas.Width - 180, 20, ImageLocomotive.Picture.Bitmap);1005 Canvas.Draw(Canvas.Width - 240, 20, ImageLocomotive.Picture.Bitmap); 973 1006 Canvas.Brush.Style := bsClear; 974 Canvas.TextOut(Canvas.Width - 186 - Canvas.TextWidth(Text), 25, Text); 1007 Canvas.TextOut(Canvas.Width - 246 - Canvas.TextWidth(Text), 25, Text); 1008 1009 DrawClock(Canvas); 975 1010 976 1011 // Game over
Note:
See TracChangeset
for help on using the changeset viewer.