top of page
  • Modie S

DevLog #18

Team Deathmatch is a popular game mode in many shooter games, certainly ones I have played. It pits two teams, usually red and blue, against each other in a battle to see which team can reach a certain number of kills first. In this blog post, I'll be demonstrating how to implement a basic version of Team Deathmatch using arrays, for loops, and algorithms.

Assigning Players to Teams

The first step in creating a Team Deathmatch game is to assign players to teams. We will use an array to store the names of all the players and another array to store which team each player is on. The following pseudocode shows how I assign players to teams using a for loop:

players = ["player1", "player2", "player3", "player4", "player5", "player6"]
teams = ["red", "blue"]
player_teams = []

for i in range(len(players)):
    if i % 2 == 0:


This code creates an array called "players" that contains the names of all the players in the game. It also creates an array called "teams" that contains the names of the two teams in the game (red and blue). The for loop then iterates through the players array, and assigns each player to a team based on whether their index in the array is even or odd. If the index is even, the player is assigned to the red team. If the index is odd, the player is assigned to the blue team.

Implementing Team Deathmatch

Now that I have assigned players to teams, I began implementing the actual Team Deathmatch game. I used a while loop to keep the game running until one team reaches a certain number of kills. The following pseudocode shows an example of how to implement this:

red_kills = 0
blue_kills = 0

while red_kills < 10 and blue_kills < 10:
    # code for player to make a kill
    if player_team[i] == "red":
        red_kills += 1
        blue_kills += 1

if red_kills == 10:
    print("The red team wins!")
    print("The blue team wins!")

This code creates two variables, "red_kills" and "blue_kills," to keep track of the number of kills for each team. The while loop runs until one team reaches 10 kills. Within the loop, we check which team the player that made the kill is on and increment the appropriate team's kill count. Once one team reaches 10 kills, the loop exits and a message is printed to indicate which team won the game.


The pseudocode shown above is essentially the 'blueprint' I used before I implemented the code in C++, and the results shown below by showing a red character spawning instead of the usual blue one. The game won't end at 10 kills, that's way too easy! Soon I'll be packaging the game and testing with 7 other players across Steam. Stay tuned for that video to come!


Recent Posts

See All
bottom of page