Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
equivalent nightly.

### Changed
- **During a manual drive, use shift+W to shift up gears, and shift+q to shift down gears .
- **Hours-of-service rules are more realistic.** Realistic mode now tracks the
11-hour driving limit, 14-hour duty window, 30-minute break requirement,
60/70-hour weekly limits, roadside inspections, and legal sleeper-berth split
Expand Down
20 changes: 16 additions & 4 deletions src/freight_fate/states/driving_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from .driving_core import *
from .driving_menu_states import DrivingStatusState, PauseMenuState


class DrivingControlsMixin:
def handle_event(self, event: pygame.event.Event) -> None:
if event.type == pygame.KEYUP and event.key == pygame.K_h:
Expand All @@ -14,6 +13,7 @@ def handle_event(self, event: pygame.event.Event) -> None:
return
key = event.key
tr = self.truck.transmission
global gear_idx
if key in (pygame.K_LCTRL, pygame.K_RCTRL):
self.ctx.stop_event_speech()
self._set_status("Event voice stopped.")
Expand All @@ -29,8 +29,20 @@ def handle_event(self, event: pygame.event.Event) -> None:
self.ctx.say("Neutral.")
elif key == pygame.K_BACKSPACE and not tr.automatic:
self._manual_shift(REVERSE)
elif key in GEAR_KEYS and not tr.automatic:
self._manual_shift(GEAR_KEYS[key])
elif key==pygame.K_q and not tr.automatic and gear_idx>1:
gear_idx-=1
self._manual_shift(gear_idx)
elif key==pygame.K_w and not tr.automatic :
if tr.in_reverse:
gear_idx=1
self._manual_shift(gear_idx)
elif tr.in_neutral:
gear_idx=1
self._manual_shift(gear_idx)
elif gear_idx<10:
gear_idx+=1
self._manual_shift(gear_idx)

elif key == pygame.K_j:
if self.truck.throttle > 0.05 and not self.truck.engine_brake:
self.ctx.say("Release the accelerator before turning the engine brake on.")
Expand Down Expand Up @@ -121,7 +133,7 @@ def handle_event(self, event: pygame.event.Event) -> None:
+ (
""
if self.truck.transmission.automatic
else "Hold Left Shift for clutch, then 1 through 0 for gears, "
else "Hold Left Shift for clutch, then W to shift up or Q to shift down, "
"Backspace for reverse, N for neutral."
)
)
Expand Down
14 changes: 1 addition & 13 deletions src/freight_fate/states/driving_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,7 @@

log = logging.getLogger(__name__)

GEAR_KEYS = {
pygame.K_1: 1,
pygame.K_2: 2,
pygame.K_3: 3,
pygame.K_4: 4,
pygame.K_5: 5,
pygame.K_6: 6,
pygame.K_7: 7,
pygame.K_8: 8,
pygame.K_9: 9,
pygame.K_0: 10,
}

gear_idx=1
HAZARD_SAFE_MPH = 25.0
MPH_PER_MPS = 2.23694

Expand Down
Loading