Reworked player controller

This commit is contained in:
2025-11-09 22:30:22 +03:00
parent 213a0d60ed
commit 22aaeab0aa
23 changed files with 181 additions and 158 deletions
+25
View File
@@ -0,0 +1,25 @@
class_name PlayerController
extends Node
signal accelerate(direction: Vector2, delta: float)
signal shoot(weapon_index: int)
signal reload(weapon_index: int)
func _physics_process(delta: float) -> void:
var input_direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
accelerate.emit(input_direction, delta)
var weapon_actions := {
0: ["shoot_weapon_1", "reload_weapon_1"],
1: ["shoot_weapon_2", "reload_weapon_2"]
}
for index : int in weapon_actions:
if Input.is_action_pressed(weapon_actions[index][0]):
shoot.emit(index)
if Input.is_action_pressed(weapon_actions[index][1]):
reload.emit(index)
@@ -0,0 +1 @@
uid://dgevigih7owxd
+6
View File
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dh1oj1w5wx4je"]
[ext_resource type="Script" uid="uid://dgevigih7owxd" path="res://game/controllers/player_controller.gd" id="1_cu3ev"]
[node name="PlayerController" type="Node"]
script = ExtResource("1_cu3ev")