Blobby/src/Actors/Enemy/Enemy.gd

28 lines
536 B
GDScript

extends Player
export var score := 100
func _ready() -> void:
set_physics_process(false)
velocity.x = -30
func _on_StompDetector_body_entered(body: Node) -> void:
if body.global_position.y > get_node("StompDetector").global_position.y:
return
get_node("EnemyShape").disabled = true
die()
func _physics_process(delta: float) -> void:
velocity.y += _gravity * delta
if is_on_wall():
velocity.x *= -1.0
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
func die() -> void:
queue_free()
PlayerData.score += score