ape-ame/bullet.gd

29 lines
671 B
GDScript3
Raw Normal View History

2024-04-16 20:29:45 -04:00
extends RigidBody2D
var bounces = 0
2024-04-26 16:32:56 -04:00
@onready var player = $"../Player"
2024-04-16 20:29:45 -04:00
2024-04-26 16:32:56 -04:00
func _physics_process(delta):
2024-04-30 15:37:00 -04:00
rotation = linear_velocity.angle()
2024-05-07 21:32:08 -04:00
#if linear_velocity.length() < 1100:
# apply_central_force((global_position - player.global_position).normalized() * -200)
2024-04-18 19:45:52 -04:00
2024-04-16 20:29:45 -04:00
func hit(body):
if body.is_in_group("destructible"):
if body.has_method("destroy"):
body.destroy()
else:
2025-02-05 14:05:36 -05:00
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
body.queue_free()
queue_free()
else:
bounces += 1
2025-02-06 14:49:13 -05:00
$Sprite2D.play("depleted")
2024-04-16 20:29:45 -04:00
#print(bounces)
if bounces >= 2:
queue_free()