feat: 添加敌人并且追踪player,同时避免敌人重叠
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user