blob: 153d9bfd05461ead79517ef790cf4689b078cdfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
extends Node
@export var asteroid : PackedScene
@export var root : Node2D
@export var player : RigidBody2D
@export var v1 : Vector2
@export var v2 : Vector2
@export var speed : float
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_timer_timeout():
if player != null:
var new : RigidBody2D = asteroid.instantiate()
new.position = Vector2(randf_range(v1.x, v2.x), randf_range(v1.y, v2.y))
new.look_at(player.position)
new.linear_velocity = Vector2(0, speed).rotated(new.rotation + deg_to_rad(-90))
root.add_child(new)
$"Timer".wait_time = randf_range(1, 3)
$"Timer".start()
|