Added locked barriers and a new ghost enemy
This commit is contained in:
28
Enemies/Projectiles/Creepy Hand.gd
Normal file
28
Enemies/Projectiles/Creepy Hand.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
extends Area2D
|
||||
|
||||
const SPEED: int = 35
|
||||
|
||||
var player_position: Vector2
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
|
||||
|
||||
func init(spawn_position: Vector2, shoot_position: Vector2) -> void:
|
||||
position = spawn_position
|
||||
player_position = shoot_position
|
||||
$Sprite.rotation = player_position.angle_to_point(position) + deg2rad(90)
|
||||
return
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if position.distance_to(player_position) > 1:
|
||||
velocity = position.direction_to(player_position).normalized() * SPEED * delta
|
||||
|
||||
position += velocity
|
||||
return
|
||||
|
||||
|
||||
func _on_tifetime_timeout() -> void:
|
||||
call_deferred('queue_free')
|
||||
return
|
Reference in New Issue
Block a user