added two stroke scenario with vehicle
This commit is contained in:
26
Program.cs
26
Program.cs
@@ -48,13 +48,17 @@ public class Program
|
||||
private static float _loadTarget = 0.0f; // 0‑1
|
||||
private static float _loadCurrent = 0.0f;
|
||||
|
||||
private static float _clutchTarget = 0f;
|
||||
private static float _clutchCurrent = 0f;
|
||||
private static bool _cKeyHeld = false;
|
||||
|
||||
private const int TargetMaxFill = (int)(SampleRate * 0.2);
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
var window = CreateWindow();
|
||||
LoadFont();
|
||||
_scenario = new SingleCylScenario();
|
||||
_scenario = new TwoStrokeScenario();
|
||||
_scenario.Font = _overlayFont;
|
||||
_scenario.Initialize(SampleRate);
|
||||
_lastThrottleUpdateTime = 0.0f;
|
||||
@@ -102,6 +106,11 @@ public class Program
|
||||
|
||||
_scenario.Throttle = _throttleCurrent;
|
||||
|
||||
float clutchDesired = _cKeyHeld ? 1f : 0f;
|
||||
float clutchSmoothing = 1f - MathF.Exp(-ThrottleLerpRate * dtThrottle);
|
||||
_clutchCurrent += (clutchDesired - _clutchCurrent) * clutchSmoothing;
|
||||
_scenario.Clutch = _clutchCurrent;
|
||||
|
||||
|
||||
// ---- Drawing ----
|
||||
if (now - lastDrawTime >= 1.0 / DrawFrequency)
|
||||
@@ -111,6 +120,7 @@ public class Program
|
||||
string toggleHint = _isRealTime ? "[Space] slow mo" : "[Space] real time";
|
||||
_overlayText.DisplayedString =
|
||||
$"{toggleHint} Speed: {_currentDisplaySpeed:F3}x RT: {(_currentDisplaySpeed * 100.0):F1}% Sim load: {_loadTracker.LoadPercent:F0}%\n" +
|
||||
$"Clutch: {_clutchCurrent*100:F0}% [C]" +
|
||||
$"Load: {_loadCurrent*100:F0}% [←][→] Throttle: {_throttleCurrent * 100:F0}% Target: {_throttleTarget * 100:F0}% [W] {(_wKeyHeld ? "BLIP" : "---")}";
|
||||
}
|
||||
|
||||
@@ -221,6 +231,17 @@ public class Program
|
||||
case Keyboard.Key.Right:
|
||||
_loadTarget = MathF.Min(1.0f, _loadTarget + 0.05f);
|
||||
break;
|
||||
|
||||
case Keyboard.Key.E:
|
||||
_scenario.ShiftUp();
|
||||
break;
|
||||
case Keyboard.Key.Q:
|
||||
_scenario.ShiftDown();
|
||||
break;
|
||||
|
||||
case Keyboard.Key.C:
|
||||
_cKeyHeld = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,5 +249,8 @@ public class Program
|
||||
{
|
||||
if (e.Code == Keyboard.Key.W)
|
||||
_wKeyHeld = false;
|
||||
|
||||
if (e.Code == Keyboard.Key.C)
|
||||
_cKeyHeld = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user