Added enemy movement
This commit is contained in:
@@ -1,11 +1,27 @@
|
||||
class_name EnemyController
|
||||
extends Node
|
||||
|
||||
|
||||
signal accelerate(direction: Vector2, delta: float)
|
||||
signal shoot(weapon_index: int)
|
||||
signal shoot()
|
||||
|
||||
|
||||
@export var ship: AbstractEnemyShip
|
||||
|
||||
|
||||
var target_position : Vector2
|
||||
var direction : Vector2
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
for i in 10:
|
||||
shoot.emit(i)
|
||||
accelerate.emit(Vector2.ZERO, delta)
|
||||
if ship.is_on_screen:
|
||||
shoot.emit()
|
||||
accelerate.emit(direction, delta)
|
||||
|
||||
|
||||
func _on_direction_timer_timeout() -> void:
|
||||
direction = get_acceleration_direction()
|
||||
|
||||
|
||||
func get_acceleration_direction() -> Vector2:
|
||||
return (target_position - ship.position).normalized()
|
||||
|
||||
Reference in New Issue
Block a user