Verse Library verse

01 Standalone

Manages team elimination matches by tracking players, granting weapons, and handling elimination events.

verse-library/team-elimination-1-setting-up-the-level-in-verse/01-standalone.verse

// 1. Define the Game Class
// This is the "Brain" of our island. It holds all the logic.
team_elimination_game := class(creative_game):
    // We need to track players. A "Map" is like a scoreboard list.
    // Key = Player ID, Value = The Player Entity
    Players: Map<player, entity> = Map{}
    
    // List of weapons to grant. Order matters!
    Weapons: []string = ["Pistol", "SMG", "Shotgun", "AR", "Sniper"]
    
    // Track current weapon tier for each team
    TeamRedTier: int = 0
    TeamBlueTier: int = 0

    // 2. The Setup Function
    // This runs once when the game starts. Like the pre-game lobby.
    setup() -> void:
        Print("Game Started! Fight!")
        // Subscribe to the "Player Joined" event.
        // This means: "Hey Verse, call me whenever someone spawns."
        PlayerJoinedEvent.Subscribe(OnPlayerJoined)
        // Subscribe to the "Player Eliminated" event.
        // This means: "Hey Verse, call me whenever someone dies."
        PlayerEliminatedEvent.Subscribe(OnPlayerEliminated)

    // 3. Handle a New Player Joining
    OnPlayerJoined(InPlayer: player) -> void:
        Print(&"{InPlayer.GetPlayerName()} joined the fight!")
        // Add this player to our tracking map
        Players.Add(InPlayer, InPlayer.GetPlayerEntity())

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.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in