cute lil prototype
This commit is contained in:
parent
57f147236a
commit
0e4a55d7bd
19 changed files with 305 additions and 2 deletions
28
test_obstacle_spawner.gd
Normal file
28
test_obstacle_spawner.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
extends Node2D
|
||||
|
||||
var active : bool = false
|
||||
var next_spawn : float = 3
|
||||
var spawn_delay : float = 3
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if active:
|
||||
next_spawn -= delta
|
||||
if next_spawn <= 0:
|
||||
spawn_obstacle()
|
||||
spawn_delay -= spawn_delay * 0.02
|
||||
next_spawn = spawn_delay
|
||||
|
||||
func spawn_obstacle():
|
||||
var randy = randi_range(0,360) #y pos to spawn the new obstacle at
|
||||
var new_obstacle : Node2D = load("res://Prefabs/obstacle.tscn").instantiate()
|
||||
new_obstacle.global_position = Vector2(global_position.x, randy)
|
||||
get_tree().get_root().add_child(new_obstacle)
|
||||
|
||||
func _on_lander_moved() -> void:
|
||||
active = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue