feat: 添加敌人并且追踪player,同时避免敌人重叠

This commit is contained in:
luke358
2026-05-17 21:02:46 +08:00
parent b678b90883
commit 67ea3f2d42
37 changed files with 543 additions and 4 deletions
+6 -1
View File
@@ -8,6 +8,7 @@ class_name Player
@onready var dash_timer: Timer = $DashTimer
@onready var dash_cooldown_timer: Timer = $DashCooldownTimer
@onready var collision: CollisionShape2D = $CollisionShape2D
@onready var trail: Trail = %Trail
var move_dir: Vector2
var is_dashing := false
@@ -24,12 +25,15 @@ func _ready() -> void:
func _process(delta: float) -> void:
move_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var current_velocity := move_dir * 500
var current_velocity := move_dir * stats.speed
if is_dashing:
current_velocity *= dash_speed_multi
position += current_velocity * delta
position.x = clamp(position.x, -1000, 1000)
position.y = clamp(position.y, -500, 500)
if can_dash():
start_dash()
@@ -54,6 +58,7 @@ func update_rotation() -> void:
func start_dash() -> void:
is_dashing = true
dash_timer.start()
trail.start_trail()
visuals.modulate.a = 0.5
collision.set_deferred("disabled",true)