This commit is contained in:
2025-09-08 14:49:21 +02:00
parent 1290cd19fb
commit 9ee0d4708b
10 changed files with 54 additions and 33 deletions

View File

@@ -6,6 +6,7 @@ class_name Ship
@export var SHOOT_NODE: PackedScene
@export var TIME_INVUL := 1.0
@export var animation : AnimationPlayer
@export var target : Node2D
const SPEED = 25.0
const JUMP_VELOCITY = -400.0
@@ -17,6 +18,7 @@ var rota_temp: float
var delay := 0.0
var is_in = true
var delay_inv := 0.0
var is_currently_hit := false
func _input(event):
pass
@@ -47,19 +49,22 @@ func _physics_process(delta: float) -> void:
if horizontal != 0 or vertical != 0:
direction = Vector2(vertical, horizontal)
rotation = atan2(horizontal, vertical)
rotation = rotate_toward(rotation ,atan2(horizontal, vertical), 0.5)
if Input.is_action_pressed("ui_accept") and delay >= 0.5:
shoot()
delay = 0
if !is_inv() and is_currently_hit:
GameController.emit_signal("player_hit")
move_and_slide()
func shoot()->void:
var new = SHOOT_NODE.instantiate()
new.direction = direction
new.position = position + (32 * direction.normalized())
new.direction = (target.global_position - global_position).normalized()
new.position = target.global_position
get_parent().add_child(new)