gdquest-2d-project-start/game.gd

23 lines
478 B
GDScript

extends Node2D
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func spawn_mob():
var new_mob = preload("res://mob.tscn").instantiate()
(%PathFollow2D as PathFollow2D).progress_ratio = randf()
new_mob.global_position = %PathFollow2D.global_position
add_child(new_mob)
func _on_timer_timeout():
spawn_mob()
func _on_player_health_depleted():
(%GameOver as CanvasLayer).visible = true
get_tree().paused = true