22 lines
559 B
GDScript
22 lines
559 B
GDScript
extends Marker2D
|
|
|
|
const pipe = preload("res://scenes/pipe/pipe.tscn")
|
|
var wobbl = 5
|
|
|
|
func spawn_pipe(pos:Vector2,rot,sca):
|
|
var instance = pipe.instantiate()
|
|
instance.global_position = pos
|
|
instance.rotation_degrees = rot
|
|
if sca:
|
|
instance.scale = Vector2(sca,sca)
|
|
$"../pipes".add_child(instance)
|
|
|
|
func double_pipe(pos_y,space):
|
|
spawn_pipe(Vector2(0,pos_y-space/2),180,2)
|
|
spawn_pipe(Vector2(0,pos_y+space/2),0,2)
|
|
|
|
|
|
|
|
func _on_spawn_pipe_timeout() -> void:
|
|
print("spawn pipes")
|
|
double_pipe(randi_range(-wobbl,wobbl)+350,180) #350 =middle of the screen
|