Wave System For Godot 4 game

extends Node2D
@onready var Player =$Player

var current_wave: Array[int] = [1, 2, 3, 4]

var player_score = 0

@onready var enemy = preload(“res://Scenes/Enemy.tscn”)

var enemy_on_screen = 0

var wave_number = 1

func _ready() → void:
spawn_wave()

func wave():
var spawn_enemy = load(“res://Scenes/Enemy.tscn”).instantiate()
spawn_enemy.position.x = randi_range(0, 1280)
spawn_enemy.position.y = randi_range(0, 720)
add_child(spawn_enemy)
print(“working”)
print(enemy_on_screen)

func spawn_wave():
for i in range(current_wave[wave_number]):
wave()

Player.died.connect(_on_player_died)

func _on_player_died():
print(“game over”)

wave_number += 1

This includes the Death System Ignore that if possible I am on a tight deadline and I cant work this out I will be very grateful for the help thanks

Hi,

Could you please format your code properly and explain your actual issue? You’re just dumping some code and asking for help without any actual info on what’s going on.
The more specific your question is, the better the answers will be. :slight_smile:

1 Like