2024-04-16 20:29:45 -04:00
|
|
|
extends RigidBody2D
|
|
|
|
|
|
|
|
@onready var player = $"../Player"
|
|
|
|
|
|
|
|
func hit(body):
|
|
|
|
if body.is_in_group("destructible"):
|
|
|
|
if body.has_method("destroy"):
|
|
|
|
body.destroy()
|
|
|
|
else:
|
|
|
|
body.queue_free()
|
2025-02-06 14:49:13 -05:00
|
|
|
spawn_explosion()
|
2024-04-16 20:29:45 -04:00
|
|
|
queue_free()
|
|
|
|
if body.name == "Border":
|
|
|
|
queue_free()
|
2025-02-05 14:05:36 -05:00
|
|
|
spawn_explosion()
|
|
|
|
|
|
|
|
func spawn_explosion():
|
|
|
|
var explosion = load("res://explosion.tscn").instantiate()
|
|
|
|
$"/root/Node2D".add_child(explosion)
|
|
|
|
explosion.global_position = global_position
|
2024-04-16 20:29:45 -04:00
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _physics_process(delta):
|
2025-02-06 11:35:16 -05:00
|
|
|
apply_central_force((global_position - player.global_position).normalized() * -1400)
|