Added some weapon logic

This commit is contained in:
2025-10-22 00:11:03 +03:00
parent 594e2f95f5
commit d6259d64e1
2 changed files with 70 additions and 8 deletions
+6 -8
View File
@@ -8,14 +8,12 @@ var position : Vector2:
return $Ship.position
func _input(event: InputEvent) -> void:
var weapons : Array = $Ship.weapons
var weapon_actions := { 0: "shoot_weapon_1", 1: "shoot_weapon_2" }
for index : int in weapon_actions:
if event.is_action_pressed(weapon_actions[index]) and weapons.size() > index:
$Ship.shoot(weapons[index])
func _process(delta: float) -> void:
var input_direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
$Ship.accelerate(input_direction, delta)
var weapons : Array = $Ship.weapons
var weapon_actions := { 0: "shoot_weapon_1", 1: "shoot_weapon_2" }
for index : int in weapon_actions:
if Input.is_action_pressed(weapon_actions[index], true) and weapons.size() > index:
$Ship.shoot(weapons[index])