How do I spawn more enemies more often as time goes on?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By System_Error

Hi all. I have an idea, but I’m not sure how to go about it.

In my game, I have a score-keeping Label & Timer duo for keeping track of how long a player has survived. I also have a timer for spawning enemies.

func _on_SpawnTimer_timeout():
var enemy = eyeworm.instance()
enemy.position = Vector2(SCREEN_WIDTH + 10, rand_range(0, SCREEN_HEIGHT))
add_child(enemy)

func _on_SurvivalTimer_timeout():
	score += 1
	$HUD.score_count(score)

How would I make the enemies spawn more and more often as time goes on?

Here’s the whole of Level.gd, for those who want to see.

extends Node2D

const SCREEN_HEIGHT = 580
const SCREEN_WIDTH = 1010

signal game_over
var score
var finalscore
var EnergyShot = preload ('res://player-side/EnergyShot.tscn')
var eyeworm = preload ('res://Enemy.tscn')

func _ready():
	randomize()


func _on_SpawnTimer_timeout():
	var enemy = eyeworm.instance()
	enemy.position = Vector2(SCREEN_WIDTH + 10, rand_range(0, SCREEN_HEIGHT))
	add_child(enemy)

func _on_SurvivalTimer_timeout():
	score += 1
	$HUD.score_count(score)


func _on_BaseArea_area_entered(area):
	$Node/SpawnTimer.stop()
	$Node/SurvivalTimer.stop()
	$HUD.player_loss() 
	emit_signal('game_over')
	$BaseArea/CollisionShape2D.disabled = true
	get_tree().call_group("EyeWorms", "queue_free")


func _on_HUD_play_game():
	score = 0
	$Node/SurvivalTimer.start()
	$Node/SpawnTimer.start() 
	$HUD.show_message("Survive!")
	$BaseArea/CollisionShape2D.disabled = false

System_Error | 2018-12-27 17:01

:bust_in_silhouette: Reply From: 2plus2makes5

You could have a SpawnWaitTime variable that decrease every time a new enemy is spawned, something like this(i guess that SpawnTimer is a Timer node):

...
var SpawnWaitTime=10

...

func _on_SpawnTimer_timeout():
    var enemy = eyeworm.instance()
    enemy.position = Vector2(SCREEN_WIDTH + 10, rand_range(0, SCREEN_HEIGHT))
    add_child(enemy)
    SpawnWaitTime-=0.1
    if(SpawnWaitTime<0.1): 
        SpawnWaitTime=0.1
    SpawnTimer.set_wait_time(SpawnWaitTime)