super powerful engine

This commit is contained in:
maxwes08
2026-01-13 10:55:18 +01:00
parent 6249499be2
commit c2bd50511e
5 changed files with 39 additions and 20 deletions

View File

@@ -28,6 +28,7 @@ internal class Program
private Clock _clock = new Clock();
private Time _timePerUpdate = Time.FromSeconds(1.0f / 60.0f); // 60 FPS physics
private Time _accumulatedTime = Time.Zero;
private float _totalTime = 0.0f;
private long _updateCount = 0;
private Dictionary<Keyboard.Key, bool> _previousKeyStates = new Dictionary<Keyboard.Key, bool>();
@@ -75,7 +76,8 @@ internal class Program
while (_accumulatedTime >= _timePerUpdate)
{
ProcessInput(_timePerUpdate.AsSeconds());
car.Update(_timePerUpdate.AsSeconds());
_totalTime += _timePerUpdate.AsSeconds();
car.Update(_timePerUpdate.AsSeconds(), _totalTime);
_accumulatedTime -= _timePerUpdate;
_updateCount++;
}
@@ -202,15 +204,15 @@ internal class Program
if (line < _displayTexts.Count) _displayTexts[line++].DisplayedString = "ENERGY";
if (line < _displayTexts.Count) _displayTexts[line++].DisplayedString = $" Engine: {car.Engine.FlywheelEnergy,7:F0} J";
if (line < _displayTexts.Count) _displayTexts[line++].DisplayedString = $" Total: {car.WheelSystem.TotalEnergy,7:F0} J";
if (line < _displayTexts.Count) _displayTexts[line++].DisplayedString = $" Wheel Rotation: {car.WheelSystem.GetRotationalEnergy(),7:F0} J";
if (line < _displayTexts.Count) _displayTexts[line++].DisplayedString = $" Car Translation: {car.WheelSystem.GetTranslationalEnergy(),7:F0} J";
if (line < _displayTexts.Count) _displayTexts[line++].DisplayedString = $" Wheel Rotation: {car.WheelSystem.GetRotationalEnergy() / 1000,7:F0} KJ";
if (line < _displayTexts.Count) _displayTexts[line++].DisplayedString = $" Car Translation: {car.WheelSystem.GetTranslationalEnergy() / 1000,7:F0} KJ";
}
private void DrawGauges()
{
_window.Draw(_tachometerBackground);
float rpmRatio = Math.Clamp(car.Engine.RPM / 8000f, 0f, 1f);
float rpmRatio = Math.Clamp(car.Engine.RPM / 13000f, 0f, 1f);
float tachometerAngle = -90 + (270 * rpmRatio);
_tachometerNeedle.Rotation = tachometerAngle;
_window.Draw(_tachometerNeedle);