add cluster graphics and transmission simulation

This commit is contained in:
Aidan Haas
2025-06-23 15:34:41 -04:00
parent 2ac3bf166b
commit 37c7c89d1e
9 changed files with 150 additions and 29 deletions
+10 -5
View File
@@ -24,7 +24,6 @@ class Engine:
self.fuel_efficiency = fuel_efficiency
self.torque_curve = torque_curve or self.default_torque_curve
self.instant_torque = 0
self.wheel_speed = 0
self.engineFriction = 5
self.peak_torque = 163 # Nm -> 120 ft/lb
self.engine_brake_strength = 40 # Nm
@@ -40,7 +39,8 @@ class Engine:
self.coolant_pressure = 0
self.coolant_capacity = 0
self.fuel_capacity = 0
self.max_fuel_capacity = 68 # Liter
self.fuel_capacity = self.max_fuel_capacity
# Fuel
@@ -63,6 +63,7 @@ class Engine:
self.vehicle_mass = 0
self.drivetrain_loss = 0
# Just a parabolic curve for now
def default_torque_curve(self, rpm):
rpm_ratio = rpm / self.max_rpm
@@ -70,8 +71,7 @@ class Engine:
def start(self, dt):
self.ignition = True
self.starting = True
self.starting = True
def update(self, throttle, load, dt):
self.throttle = throttle
@@ -107,11 +107,15 @@ class Engine:
friction_force = 0
# Engine braking torque (If throttle closed)
if self.throttle < 0.1 and self.rpm > self.idle_rpm + 200 or not self.ignition:
if self.throttle == 0 and self.rpm > self.idle_rpm + 200 or not self.ignition:
engine_brake_torque = self.engine_brake_strength * (self.rpm / self.max_rpm)
else:
engine_brake_torque = 0
# Transmission Load
# Calculate torque
if self.ignition:
available_torque = self.torque_curve(self.rpm)
@@ -123,5 +127,6 @@ class Engine:
self.rpm += rpm_change * dt
self.fuel_rate = self.rpm * throttle * self.fuel_efficiency
# self.fuel_capacity -= self.fuel_rate
#self._update_temps(dt)