Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cc33c56
Emit speed_changed signal; add tests
ikostan Apr 11, 2026
bd9f03c
Update player.gd
ikostan Apr 11, 2026
1590492
Test name and assertions are inconsistent (max_and_min but only max i…
ikostan Apr 12, 2026
d857fe3
Update player.gd
ikostan Apr 12, 2026
e0715d7
Update player.gd
ikostan Apr 12, 2026
aa9fdc8
Update test_player_movement_signals.gd
ikostan Apr 12, 2026
a861547
Add HUD, wire it up & refactor player/settings
ikostan Apr 12, 2026
f7d0a6c
Update game_settings_resource.gd
ikostan Apr 12, 2026
56a18a8
Update main_scene.gd
ikostan Apr 12, 2026
3237fd1
Refactor tests to use Globals settings & HUD
ikostan Apr 14, 2026
ce6864d
Update tests for Globals/HUD refactor
ikostan Apr 14, 2026
7b8127c
Update test_helpers.gd
ikostan Apr 14, 2026
5459961
Update player.gd
ikostan Apr 14, 2026
625942a
Update test_player_movement_signals.gd
ikostan Apr 14, 2026
e765c1f
Extract GUT mock builder to helper
ikostan Apr 14, 2026
bdd2377
Update scripts/game_settings_resource.gd
ikostan Apr 14, 2026
9944fd7
Update game_settings_resource.gd
ikostan Apr 14, 2026
4553ccd
Update game_settings_resource.gd
ikostan Apr 14, 2026
a358b22
Update scripts/hud.gd
ikostan Apr 14, 2026
4d2c69d
Use GameSettingsResource for the speed thresholds instead of duplicat…
ikostan Apr 14, 2026
c957693
Update hud.gd
ikostan Apr 14, 2026
afdb474
Fix HUD logging and connection guards; add tests
ikostan Apr 14, 2026
2122a7a
Update globals.gd
ikostan Apr 14, 2026
6195b8c
Update hud.gd
ikostan Apr 14, 2026
7557229
Update test_player.gd
ikostan Apr 14, 2026
5d8f016
Update scripts/game_settings_resource.gd
ikostan Apr 14, 2026
4e289dc
Update game_settings_resource.gd
ikostan Apr 14, 2026
0746137
Update hud.gd
ikostan Apr 14, 2026
6cc9a94
issue (bug_risk): high_yellow_fraction and low_yellow_fraction can be…
ikostan Apr 14, 2026
3ee148e
issue (bug_risk): setup_hud assumes the player_node has a speed_chang…
ikostan Apr 14, 2026
910d718
Release simulated actions before erasing them.
ikostan Apr 14, 2026
6d0f630
This flameout assertion is currently ambiguous.
ikostan Apr 14, 2026
efecc65
suggestion (bug_risk): HUD does not react to speed-related setting ch…
ikostan Apr 14, 2026
c69e1fc
Expose HUD accessors and update tests
ikostan Apr 14, 2026
d6f09f5
Update hud.gd
ikostan Apr 14, 2026
27dff10
Update hud.gd
ikostan Apr 14, 2026
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
4 changes: 3 additions & 1 deletion scenes/main_scene.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=81 format=3 uid="uid://nnnc0qhx07i8"]
[gd_scene load_steps=82 format=3 uid="uid://nnnc0qhx07i8"]

[ext_resource type="Script" uid="uid://ctm7qg12s2swt" path="res://scripts/main_scene.gd" id="1_7ykc4"]
[ext_resource type="PackedScene" uid="uid://cb4n4cqkuddqg" path="res://scenes/pause_menu.tscn" id="1_w2twt"]
Expand Down Expand Up @@ -76,6 +76,7 @@
[ext_resource type="Texture2D" uid="uid://btyfigdtk3x88" path="res://files/random_decor/crates_4.png" id="68_f3krf"]
[ext_resource type="Texture2D" uid="uid://bvxu5x1awjrjv" path="res://files/random_decor/dirt_001.png" id="69_7tyuc"]
[ext_resource type="Texture2D" uid="uid://f4hxu68qa4fi" path="res://files/random_decor/dirt_002.png" id="70_isor2"]
[ext_resource type="Script" uid="uid://blu5qujicfa7e" path="res://scripts/hud.gd" id="72_sgkfd"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pu3yx"]
bg_color = Color(0.2627451, 0.2627451, 0.2627451, 0.5882353)
Expand Down Expand Up @@ -123,6 +124,7 @@ offset_right = 1270.0
offset_bottom = 120.0
tooltip_text = "Player Status Panel"
theme_override_styles/panel = SubResource("StyleBoxFlat_pu3yx")
script = ExtResource("72_sgkfd")
metadata/_edit_use_anchors_ = true

[node name="Stats" type="VBoxContainer" parent="PlayerStatsPanel"]
Expand Down
95 changes: 95 additions & 0 deletions scripts/game_settings_resource.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,92 @@ signal setting_changed(setting_name: String, new_value: Variant)
## game-over states or low-fuel warnings without polling every frame.
signal fuel_depleted

@export_group("Speed System")

@export var max_speed: float = 713.0:
set(value):
var new_val: float = max(1.0, value)
if _max_speed == new_val:
return
_max_speed = new_val

# NEW FIX: Enforce invariant - push min_speed down if max_speed drops below it
if _min_speed > _max_speed:
self.min_speed = _max_speed

setting_changed.emit("max_speed", _max_speed)
get:
return _max_speed

@export var min_speed: float = 95.0:
set(value):
# NEW FIX: Clamp new min_speed so it cannot exceed the current max_speed
var new_val: float = clamp(value, 0.0, _max_speed)

if _min_speed == new_val:
return
_min_speed = new_val
setting_changed.emit("min_speed", _min_speed)
get:
return _min_speed
Comment thread
ikostan marked this conversation as resolved.

@export var lateral_speed: float = 250.0:
set(value):
var new_val: float = max(0.0, value)
if _lateral_speed == new_val:
return
_lateral_speed = new_val
setting_changed.emit("lateral_speed", _lateral_speed)
get:
return _lateral_speed

@export var acceleration: float = 200.0:
set(value):
var new_val: float = max(0.0, value)
if _acceleration == new_val:
return
_acceleration = new_val
setting_changed.emit("acceleration", _acceleration)
get:
return _acceleration

@export var deceleration: float = 100.0:
set(value):
var new_val: float = max(0.0, value)
if _deceleration == new_val:
return
_deceleration = new_val
setting_changed.emit("deceleration", _deceleration)
get:
return _deceleration
Comment thread
ikostan marked this conversation as resolved.

@export var high_yellow_fraction: float = 0.80:
set(value):
var new_val: float = clamp(value, 0.0, 1.0)
if _high_yellow_fraction == new_val:
return
_high_yellow_fraction = new_val

# NEW FIX: Enforce invariant - push low_yellow down if high_yellow drops below it
if _low_yellow_fraction > _high_yellow_fraction:
self.low_yellow_fraction = _high_yellow_fraction

setting_changed.emit("high_yellow_fraction", _high_yellow_fraction)
get:
return _high_yellow_fraction

Comment thread
sourcery-ai[bot] marked this conversation as resolved.
@export var low_yellow_fraction: float = 0.10:
set(value):
# NEW FIX: Clamp new low_yellow so it cannot exceed the current high_yellow
var new_val: float = clamp(value, 0.0, _high_yellow_fraction)

if _low_yellow_fraction == new_val:
return
_low_yellow_fraction = new_val
setting_changed.emit("low_yellow_fraction", _low_yellow_fraction)
get:
return _low_yellow_fraction

@export_group("Fuel System")

## Maximum fuel capacity.
Expand Down Expand Up @@ -167,6 +253,15 @@ var _medium_fuel_threshold: float = 50.0
var _low_fuel_threshold: float = 30.0
var _no_fuel_threshold: float = 15.0

# Speed Backing Fields
var _max_speed: float = 713.0
var _min_speed: float = 95.0
var _lateral_speed: float = 250.0
var _acceleration: float = 200.0
var _deceleration: float = 100.0
var _high_yellow_fraction: float = 0.80
var _low_yellow_fraction: float = 0.10


func _init() -> void:
# This only runs if the values aren't already set (like in a .new() call)
Expand Down
4 changes: 3 additions & 1 deletion scripts/globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ func load_options(menu_to_hide: Node) -> void:
# @param message: The string message to log.
# @param level: The log level (default INFO).
func log_message(message: String, level: LogLevel = LogLevel.INFO) -> void:
if level < settings.current_log_level:
# FIX: Guard the log level check. If settings is null, print everything.
if is_instance_valid(settings) and level < settings.current_log_level:
return # Skip if below threshold

var level_str: String = LogLevel.keys()[level] # Converts enum to string: "INFO", etc.
var timestamp: String = Time.get_datetime_string_from_system()
print("[%s] [%s] %s" % [timestamp, level_str, message])
Expand Down
Loading
Loading