Changeset 33
- Timestamp:
- Apr 19, 2015, 12:42:58 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UEngine.pas
r32 r33 304 304 ServedPassengerCount: Integer; 305 305 State: TGameState; 306 procedure Tick;306 RedrawPending: Boolean; 307 307 procedure MouseMove(Position: TPoint); 308 308 procedure MouseUp(Button: TMouseButton; Position: TPoint); 309 309 procedure MouseDown(Button: TMouseButton; Position: TPoint); 310 310 procedure Reset; 311 procedure Redraw; 311 312 constructor Create; 312 313 destructor Destroy; override; 314 procedure Tick; 313 315 procedure Paint(TargetCanvas: TCanvas); 314 316 property Time: TDateTime read FTime; … … 341 343 //TimePerSecond = (60 * OneMinute); 342 344 TimePerSecond = (60 * OneMinute); 343 NewStationPeriod = 0.01;345 NewStationPeriod = 1; 344 346 NewShapePeriod = 10; 345 347 NewTrainPeriod = 7; // Each week … … 1607 1609 RelPos := RelPos + PosChange; 1608 1610 LastTrainMoveTime := Time; 1611 Redraw; 1609 1612 if Assigned(BaseTrackPoint) then 1610 1613 while (Direction = -1) and (RelPos < 0) do begin … … 1651 1654 InStation := True; 1652 1655 StationStopTime := Time; 1656 Redraw; 1653 1657 end; 1654 1658 LastPosDelta := PosDelta; … … 1791 1795 if State = gsRunning then begin 1792 1796 FTime := FTime + (Now - LastTickTime) / OneSecond * TimePerSecond; 1797 Redraw; // Redraw on every because engine time is changed so clock should be redrawn 1793 1798 1794 1799 // Add new trains … … 1797 1802 Trains.AddNew; 1798 1803 // TODO: Show notification screen with confirmation 1804 Redraw; 1799 1805 end; 1800 1806 … … 1803 1809 LastNewShapeTime := Time; 1804 1810 if ShapeCount <= Integer(High(TStationShape)) then Inc(ShapeCount); 1811 Redraw; 1805 1812 end; 1806 1813 … … 1810 1817 Stations.AddNew; 1811 1818 ResizeView; 1819 Redraw; 1812 1820 end; 1813 1821 … … 1825 1833 while (Passenger.Shape = Passenger.Station.Shape) or not (Passenger.Shape in GetExistStationShapes) do 1826 1834 Passenger.Shape := TStationShape((Integer(Passenger.Shape) + 1) mod Integer(ShapeCount)); 1827 end; 1828 end; 1829 1835 Redraw; 1836 end; 1837 end; 1838 1839 // Check station passenger overload state 1830 1840 for I := 0 to Stations.Count - 1 do 1831 1841 with TMapStation(Stations[I]) do begin … … 1834 1844 if OverloadDuration > MaxPassengersOveloadTime then 1835 1845 OverloadDuration := MaxPassengersOveloadTime; 1846 if OverloadDuration < MaxPassengersOveloadTime then Redraw; 1836 1847 end; 1837 1848 if Passengers.Count <= MaxWaitingPassengers then begin 1849 if OverloadDuration > 0 then Redraw; 1838 1850 OverloadDuration := OverloadDuration - (FTime - FLastTime); 1839 1851 if OverloadDuration < 0 then begin … … 1848 1860 for I := 0 to Stations.Count - 1 do 1849 1861 with TMapStation(Stations[I]) do begin 1850 if OverloadDuration >= MaxPassengersOveloadTime then State := gsGameOver; 1862 if OverloadDuration >= MaxPassengersOveloadTime then begin 1863 State := gsGameOver; 1864 Redraw; 1865 end; 1851 1866 end; 1852 1867 … … 1868 1883 FocusedStation := GetStationOnPos(View.PointDestToSrc(Position)); 1869 1884 Line := nil; 1870 if Assigned(TrackStationDown) then Line := TrackStationDown.Track.Line; 1871 if Assigned(TrackStationUp) then Line := TrackStationUp.Track.Line; 1885 if Assigned(TrackStationDown) then begin 1886 Line := TrackStationDown.Track.Line; 1887 Redraw; 1888 end; 1889 if Assigned(TrackStationUp) then begin 1890 Line := TrackStationUp.Track.Line; 1891 Redraw; 1892 end; 1872 1893 if Assigned(Line) and not Assigned(LastFocusedStation) and Assigned(FocusedStation) then begin 1873 1894 if Assigned(TrackStationDown) and (TrackStationDown.LineStation.MapStation = FocusedStation) then begin … … 2064 2085 LastTickTime := Now; 2065 2086 State := gsRunning; 2087 Redraw; 2088 end; 2089 2090 procedure TEngine.Redraw; 2091 begin 2092 RedrawPending := True; 2066 2093 end; 2067 2094 … … 2315 2342 TargetCanvas.TextOut((TargetCanvas.Width - TargetCanvas.TextWidth(Text)) div 2, 180, Text); 2316 2343 end; 2344 RedrawPending := False; 2317 2345 end; 2318 2346 -
trunk/UFormMain.pas
r30 r33 37 37 public 38 38 Engine: TEngine; 39 procedure Repaint;40 39 end; 41 40 … … 114 113 procedure TFormMain.PaintBox1Resize(Sender: TObject); 115 114 begin 115 Engine.Redraw; 116 116 end; 117 117 … … 119 119 begin 120 120 Engine.Tick; 121 PaintBox1.Repaint; 121 if Engine.RedrawPending then 122 PaintBox1.Repaint; 122 123 end; 123 124 … … 127 128 end; 128 129 129 procedure TFormMain.Repaint;130 begin131 132 end;133 134 130 end. 135 131
Note:
See TracChangeset
for help on using the changeset viewer.