no tp
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://ditud5veuxqyb"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://ditud5veuxqyb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b8a23hkmesx0l" path="res://script/asteroid.gd" id="1_p0ukn"]
|
||||
[ext_resource type="Texture2D" uid="uid://dbingmvgsgvfv" path="res://assets/asteroidx1.png" id="1_u87q6"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_p0ukn"]
|
||||
radius = 14.0357
|
||||
|
||||
[node name="asteroid" type="RigidBody2D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
@@ -17,9 +14,7 @@ script = ExtResource("1_p0ukn")
|
||||
[node name="Asteroid" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_u87q6")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
light_mask = 2
|
||||
visibility_layer = 2
|
||||
shape = SubResource("CircleShape2D_p0ukn")
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
polygon = PackedVector2Array(12, -1, 6, -6, 5, -13, -8, -12, -12, -5, -12, 4, -6, 13, -2, 10, 2, 14, 12, 3)
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
|
||||
@@ -35,6 +35,8 @@ position = Vector2(320, 640)
|
||||
shape = SubResource("RectangleShape2D_xxgf6")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
collision_layer = 3
|
||||
collision_mask = 3
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2(0, 320)
|
||||
@@ -52,4 +54,4 @@ shape = SubResource("RectangleShape2D_xxgf6")
|
||||
position = Vector2(320, 640)
|
||||
shape = SubResource("RectangleShape2D_xxgf6")
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_body_entered_for_multiple"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_area_2d_body_exited"]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,9 +6,11 @@ extends Node2D
|
||||
@export var asteroidx4 : PackedScene
|
||||
@export var player : CharacterBody2D
|
||||
@export var distance:= 600.0
|
||||
@export var delay_spawn := 3.0
|
||||
|
||||
var current_time := 0.0
|
||||
var current_time := 50.0
|
||||
|
||||
signal add_collision
|
||||
|
||||
var list_of_collision_1 : Array[Node]
|
||||
var list_of_collision_2 : Array[Node]
|
||||
@@ -35,10 +37,11 @@ func _process(delta: float) -> void:
|
||||
spawn()
|
||||
|
||||
func spawn_duplicate(asteroid: Node2D):
|
||||
var dup = asteroid.duplicate()
|
||||
dup.position = (asteroid.position - Vector2(320, 320)).rotated(PI/2) + Vector2(320, 320)
|
||||
dup.direction = (asteroid.direction - Vector2(320, 320)).rotated(PI/2) + Vector2(320, 320)
|
||||
add_child(dup)
|
||||
var dup = asteroid.duplicate(DUPLICATE_USE_INSTANTIATION)
|
||||
dup.currently_in = true
|
||||
dup.position = (asteroid.position - Vector2(320, 320)).rotated(PI) + Vector2(320, 320)
|
||||
dup.direction = asteroid.direction
|
||||
call_deferred("add_child", dup)
|
||||
|
||||
func spawn():
|
||||
var choice = randi_range(1, 4)
|
||||
@@ -61,7 +64,7 @@ func spawn():
|
||||
add_child(new)
|
||||
|
||||
|
||||
func add_collision(body1 : Node, body2: Node) -> void:
|
||||
func _add_collision(body1 : Node, body2: Node) -> void:
|
||||
for i in range(list_of_collision_1.size()):
|
||||
if list_of_collision_1[i] == body1 and list_of_collision_2[i]== body2:
|
||||
return
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
extends Node2D
|
||||
|
||||
@export var spawner: Node2D
|
||||
|
||||
func _body_entered_for_multiple(body: Node2D) -> void:
|
||||
if body.is_in_group("asteroid") and body.get("is_firt_entree") == false:
|
||||
spawner.spawn()
|
||||
|
||||
func _on_area_2d_body_exited(body: Node2D) -> void:
|
||||
if body.is_in_group("asteroid"):
|
||||
body.set_collision_layer(3)
|
||||
body.set_collision_mask(3)
|
||||
|
||||
Reference in New Issue
Block a user