# This is our main "Round Manager" device.
# Think of this device as the "Game Director."
verse_device class RoundManager:
# These are the "props" (variables) we need to talk to other devices.
# We connect these in the UEFN editor later.
StartButton: ButtonDevice = ButtonDevice{}
BossSpawner: NpcSpawnerDevice = NpcSpawnerDevice{}
# This is the main function. It runs when the device starts.
# It contains our infinite Game Loop.
RunGameLoop(): void =
# The "Infinite Loop" is the Battle Bus that never lands.
# It keeps running forever until we stop it.
loop:
# 1. WAIT FOR THE BUTTON
# We "await" the button being pressed.
# This is like waiting for the Storm to close.
# The code pauses here until a player hits the button.
await StartButton.Pressed
# 2. START THE ROUND
# The button was hit! Now we start the round.
# We tell the spawner to spawn the Boss.
BossSpawner.Spawn()
# 3. WAIT FOR THE ROUND TO END
# We need to wait for the Boss to die OR time to run out.
# We use "any" to wait for the first of two things to happen.
# - BossSpawner.Eliminated: The Boss died.
# - TimerDevice.After(30s): 30 seconds passed.
Verse Library
verse
01 Fragment
Implements an asynchronous game loop that waits for button presses and manages round states.
verse-library/5-game-loop-and-round-management/01-fragment.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.