first Prototype
This commit is contained in:
parent
89503407e7
commit
c887a2168c
78 changed files with 2494 additions and 2 deletions
22
scenes/spaceShip/enemy/enemy.gd
Normal file
22
scenes/spaceShip/enemy/enemy.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class_name Enemy extends "res://scenes/spaceShip/spaceShip.gd"
|
||||
|
||||
@onready var visionAreaStop: VisionArea = $VisionAreas/VisionAreaStop
|
||||
@onready var raycast: RayCast2D = $RayCast2D
|
||||
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if Globals.getPlayer() != null:
|
||||
look_at(Globals.getPlayer().global_position)
|
||||
var direction = Vector2.RIGHT.rotated(rotation)
|
||||
rotation += PI / 2
|
||||
if not visionAreaStop.has_overlapping_bodies():
|
||||
velocity = velocity.lerp(direction * speed, acceleration * delta)
|
||||
else:
|
||||
if not raycast.is_colliding():
|
||||
attack()
|
||||
velocity = velocity.lerp(Vector2.ZERO, acceleration * delta)
|
||||
move_and_slide()
|
||||
|
||||
func _on_hurt_area_hurt(amount: int) -> void:
|
||||
damage(amount)
|
||||
Loading…
Add table
Add a link
Reference in a new issue