diff --git a/autoload/persistence/settings/input_controls.gd b/autoload/persistence/settings/input_controls.gd index 5c2d30a..5788228 100644 --- a/autoload/persistence/settings/input_controls.gd +++ b/autoload/persistence/settings/input_controls.gd @@ -31,8 +31,13 @@ const ItemLeft: StringName = &"item_left" const ItemRight: StringName = &"item_right" const ToggleInventory: StringName = &"toggle_inventory" - const Drag: StringName = &"drag" +const VehicleAccelerate: StringName = &"vehicle_accelerate" +const VehicleReverseAccelerate: StringName = &"vehicle_reverse_accelerate" +const VehicleSteerRight: StringName = &"vehicle_steer_right" +const VehicleSteerLeft: StringName = &"vehicle_steer_left" +const VehicleHandBrake: StringName = &"vehicle_hand_brake" + const PerformanceMetrics: StringName = &"performance_metrics" const PauseGame: StringName = &"pause" diff --git a/project.godot b/project.godot index 9a53532..f207b1c 100644 --- a/project.godot +++ b/project.godot @@ -230,6 +230,40 @@ item_right={ , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } +vehicle_accelerate={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null) +] +} +vehicle_reverse_accelerate={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null) +] +} +vehicle_hand_brake={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null) +] +} +vehicle_steer_right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null) +] +} +vehicle_steer_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null) +] +} [internationalization] diff --git a/utilities/math/math_helper.gd b/utilities/math/math_helper.gd index cd3f5bb..36354b5 100644 --- a/utilities/math/math_helper.gd +++ b/utilities/math/math_helper.gd @@ -35,8 +35,11 @@ const ErdosBorweinConstant: float = 1.6066951524 # ERDOS-BORWEIN CONSTANT, norm const NivensConstant: float = 1.7052111401 # NIVENS' CONSTANT, number theory const UniversalParabolicConstant: float = 2.2955871493 # UNIVERSAL PARABOLIC CONSTANT, reflection coefficient const SierpinskisConstant: float = 2.5849817595 # SIERPINSKI'S CONSTANT, Sierpinski triangle fractal - const FransenRobinsonConstant: float = 2.807770 + +const MetersPerSecondToMilePerHourFactor: float = 2.23694 +const MetersPerSecondToKilometersPerHourFactor: float = 3.6 + const HexCharacters: String = "0123456789ABCDEF" ## "x": This is the input value between 0 and 1 that you want to apply the bias to. diff --git a/utilities/motion/velocity_helper.gd b/utilities/motion/velocity_helper.gd index febf159..89cc48c 100644 --- a/utilities/motion/velocity_helper.gd +++ b/utilities/motion/velocity_helper.gd @@ -5,9 +5,6 @@ enum SpeedUnit { MilesPerHour, } -const MetersPerSecondToMilePerHourFactor: float = 2.23694 -const MetersPerSecondToKilometersPerHourFactor: float = 3.6 - static func current_speed_on(speed_unit: SpeedUnit, velocity) -> float: match speed_unit: @@ -21,18 +18,22 @@ static func current_speed_on(speed_unit: SpeedUnit, velocity) -> float: static func current_speed_on_miles_per_hour(velocity) -> float: if velocity is Vector2: - return roundf(velocity.length() * MetersPerSecondToMilePerHourFactor) + return roundf(velocity.length() * MathHelper.MetersPerSecondToMilePerHourFactor) elif velocity is Vector3: - return roundf(Vector3(velocity.x, 0, velocity.z).length() * MetersPerSecondToMilePerHourFactor) + return roundf(Vector3(velocity.x, 0, velocity.z).length() * MathHelper.MetersPerSecondToMilePerHourFactor) + elif velocity is float: ## We assume we received the velocity length + return roundf(velocity * MathHelper.MetersPerSecondToMilePerHourFactor) else: return 0.0 static func current_speed_on_kilometers_per_hour(velocity) -> float: if velocity is Vector2: - return roundf(velocity.length() * MetersPerSecondToKilometersPerHourFactor) + return roundf(velocity.length() * MathHelper.MetersPerSecondToKilometersPerHourFactor) elif velocity is Vector3: - return roundf(Vector3(velocity.x, 0, velocity.z).length() * MetersPerSecondToKilometersPerHourFactor) + return roundf(Vector3(velocity.x, 0, velocity.z).length() * MathHelper.MetersPerSecondToKilometersPerHourFactor) + elif velocity is float: ## We assume we received the velocity length + return roundf(velocity * MathHelper.MetersPerSecondToKilometersPerHourFactor) else: return 0.0