Poprawki w ruchu

This commit is contained in:
Tomasz Boruc 2026-10-09 13:32:29 +02:00
parent 7f9dc71b69
commit ee06adbbf4
4 changed files with 27 additions and 9 deletions

View File

@ -47,6 +47,14 @@ ship_turn_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"physical_keycode":68)]
}
ship_strafe_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"physical_keycode":81)]
}
ship_strafe_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"physical_keycode":69)]
}
[editor_plugins]

View File

@ -105,12 +105,6 @@ theme_override_colors/font_color = Color(0.92, 0.96, 1, 1)
theme_override_font_sizes/font_size = 54
text = "RANDOLOOT"
[node name="Subtitle" type="Label" parent="MenuLayout" unique_id=999800820]
layout_mode = 2
theme_override_colors/font_color = Color(0.48, 0.78, 1, 1)
theme_override_font_sizes/font_size = 16
text = "SPACE ROGUELITE"
[node name="Spacer" type="Control" parent="MenuLayout" unique_id=823515088]
custom_minimum_size = Vector2(0, 12)
layout_mode = 2

View File

@ -6,4 +6,4 @@ extends CanvasLayer
func _process(_delta: float) -> void:
var speed := player.velocity.length()
var position := player.global_position
readout.text = "W — ciąg S — hamulec / wsteczny (50%)\nA / D — płynny obrót\n\nPRĘDKOŚĆ %03d px/s\nPOZYCJA %d, %d" % [roundi(speed), roundi(position.x), roundi(position.y)]
readout.text = "W — ciąg S — hamulec / wsteczny (50%)\nQ / E — strafe (50%) A / D — obrót\n\nPRĘDKOŚĆ %03d px/s\nPOZYCJA %d, %d" % [roundi(speed), roundi(position.x), roundi(position.y)]

View File

@ -4,6 +4,7 @@ const DEFAULT_SHIP_TEXTURE := "res://assets/Ships/Spaceship_0.png"
@export var max_speed := 420.0
@export var reverse_max_speed := 210.0
@export var max_strafe_speed := 210.0
@export var thrust_acceleration := 260.0
@export var brake_acceleration := 540.0
@export var space_drag := 24.0
@ -19,6 +20,8 @@ func _ready() -> void:
_ensure_input_action(&"ship_brake", KEY_S)
_ensure_input_action(&"ship_turn_left", KEY_A)
_ensure_input_action(&"ship_turn_right", KEY_D)
_ensure_input_action(&"ship_strafe_left", KEY_Q)
_ensure_input_action(&"ship_strafe_right", KEY_E)
_sprite = $Sprite2D
var texture_path := GameState.selected_ship_path
@ -53,7 +56,8 @@ func _physics_process(delta: float) -> void:
var forward := Vector2.UP.rotated(rotation)
if Input.is_action_pressed("ship_brake"):
if velocity.length_squared() > 1.0:
var forward_speed := velocity.dot(forward)
if forward_speed > 0.0:
velocity = velocity.move_toward(Vector2.ZERO, brake_acceleration * delta)
else:
velocity -= forward * thrust_acceleration * delta
@ -65,7 +69,19 @@ func _physics_process(delta: float) -> void:
var forward_speed := velocity.dot(forward)
if forward_speed > max_speed:
velocity += forward * (max_speed - forward_speed)
else:
var strafe_input := Input.get_axis("ship_strafe_left", "ship_strafe_right")
var right := Vector2.RIGHT.rotated(rotation)
if not is_zero_approx(strafe_input):
velocity += right * strafe_input * thrust_acceleration * delta
var strafe_speed := velocity.dot(right)
velocity += right * (clampf(strafe_speed, -max_strafe_speed, max_strafe_speed) - strafe_speed)
if (
not Input.is_action_pressed("ship_brake")
and not Input.is_action_pressed("ship_thrust")
and is_zero_approx(strafe_input)
):
velocity = velocity.move_toward(Vector2.ZERO, space_drag * delta)
move_and_slide()