This commit is contained in:
2025-09-04 19:18:28 +02:00
parent 3f2ca68a4f
commit 6e599c8f1c
5 changed files with 30 additions and 26 deletions

View File

@@ -3,13 +3,12 @@ extends RigidBody2D
var SPEED : float
var direction : Vector2
var type:= 1
var is_firt_entree := true
@export var particles := load("res://destroy.tscn")
@export var particles := load("res://scene/destroy.tscn")
@export var asteroidx1 : = load("res://asteroidx1.tscn")
@export var asteroidx2 : = load("res://asteroidx2.tscn")
@export var asteroidx3 : = load("res://asteroidx3.tscn")
@export var asteroidx1 : = load("res://scene/asteroidx1.tscn")
@export var asteroidx2 : = load("res://scene/asteroidx2.tscn")
@export var asteroidx3 : = load("res://scene/asteroidx3.tscn")
func _ready() -> void:
@@ -43,6 +42,8 @@ func split():
second.direction = direction
first.global_position = position + (2**type * nor)
first.type = type-1
first.set_collision_layer(3)
second.set_collision_layer(3)
second.global_position = position - (2**type * nor)
second.type = type-1
var parent = get_parent()
@@ -55,7 +56,9 @@ func split():
func _on_body_entered(body: Node) -> void:
if body.is_in_group("asteroid"):
get_parent().add_collision(body, self)
if body.is_in_group("shoot"):
get_parent()._add_collision(body, self)
elif body.is_in_group("shoot"):
body.queue_free()
split()
else:
direction = -direction