tp work and first steep for menu
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
extends Node2D
|
||||
|
||||
class_name Spawner
|
||||
@export var asteroidx1 : PackedScene
|
||||
@export var asteroidx2 : PackedScene
|
||||
@export var asteroidx3 : PackedScene
|
||||
@@ -7,8 +8,9 @@ extends Node2D
|
||||
@export var player : CharacterBody2D
|
||||
@export var distance:= 600.0
|
||||
@export var delay_spawn := 3.0
|
||||
@export var load_screen:= false
|
||||
|
||||
var current_time := 50.0
|
||||
var current_time := 0.0
|
||||
|
||||
signal add_collision
|
||||
|
||||
@@ -17,7 +19,7 @@ var list_of_collision_2 : Array[Node]
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
pass
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
@@ -32,14 +34,17 @@ func _process(delta: float) -> void:
|
||||
list_of_collision_1 = []
|
||||
list_of_collision_2 = []
|
||||
current_time += delta
|
||||
if current_time >= 2.0:
|
||||
if current_time >= delay_spawn and ((load_screen and get_children().size() < 10) or not load_screen):
|
||||
current_time = 0
|
||||
spawn()
|
||||
|
||||
func spawn_duplicate(asteroid: Node2D):
|
||||
var dup = asteroid.duplicate(DUPLICATE_USE_INSTANTIATION)
|
||||
dup.currently_in = true
|
||||
dup.position = (asteroid.position - Vector2(320, 320)).rotated(PI) + Vector2(320, 320)
|
||||
dup.type = asteroid.type
|
||||
dup.is_in = false
|
||||
var new_pos = (asteroid.position ).rotated(PI)
|
||||
dup.position = new_pos
|
||||
dup.rotation = asteroid.rotation
|
||||
dup.direction = asteroid.direction
|
||||
call_deferred("add_child", dup)
|
||||
|
||||
@@ -58,7 +63,7 @@ func spawn():
|
||||
elif choice == 4:
|
||||
new = asteroidx4.instantiate()
|
||||
new.type = 4
|
||||
var new_global_position = Vector2(distance,0).rotated(randf_range(0.0, 360)) + Vector2(320, 320)
|
||||
var new_global_position = Vector2(distance,0).rotated(randf_range(0.0, 360))
|
||||
new.global_position = new_global_position
|
||||
new.direction = (player.global_position - new_global_position).normalized()
|
||||
add_child(new)
|
||||
|
||||
Reference in New Issue
Block a user