In this game, you run away from your opponent. If your opponent touches you, you die.  For every second, there is +1 survival time. Your goal is to survive as long as you can.

You can click here for a demonstration.

To play this game, copy the code below for free and paste it into your python file. Run the game and enjoy!

Copy the code for FREE!:

import pygame
import sys
import random

pygame.init()

width, height = 800, 600
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Survival Tag")

white = (255, 255, 255)
blue = (0, 0, 255)
red = (255, 0, 0)
black = (0, 0, 0)

wrestler_width, wrestler_height = 50, 50
wrestler_x, wrestler_y = (width - wrestler_width) // 2, (height - wrestler_height) // 2

opponent_width, opponent_height = 40, 40
opponent_x, opponent_y = random.randint(0, width - opponent_width), random.randint(0, height - opponent_height)

survival_time = 0  # Track the player's survival time

font_big = pygame.font.Font(None, 74)
font_small = pygame.font.Font(None, 36)

clock = pygame.time.Clock()

def show_lose_screen():
    text_lose = font_big.render("You Lose!", True, red)
    text_time = font_small.render("Survival Time: {} seconds".format(survival_time // 60), True, black)

    screen.blit(text_lose, (width // 2 - 150, height // 2 - 50))
    screen.blit(text_time, (width // 2 - 150, height // 2 + 50))

    pygame.display.flip()
    pygame.time.delay(2000)  # Display the "You Lose!" screen for 2 seconds
    pygame.quit()
    sys.exit()

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT] and wrestler_x > 0:
        wrestler_x -= 5
    if keys[pygame.K_RIGHT] and wrestler_x < width - wrestler_width:
        wrestler_x += 5
    if keys[pygame.K_UP] and wrestler_y > 0:
        wrestler_y -= 5
    if keys[pygame.K_DOWN] and wrestler_y < height - wrestler_height:
        wrestler_y += 5

    # Make the opponent move away from the player (faster)
    if opponent_x < wrestler_x:
        opponent_x += random.randint(0, 4)
    else:
        opponent_x -= random.randint(0, 4)

    if opponent_y < wrestler_y:
        opponent_y += random.randint(0, 4)
    else:
        opponent_y -= random.randint(0, 4)

    # Check for collision and update survival time
    if (
        wrestler_x < opponent_x + opponent_width
        and wrestler_x + wrestler_width > opponent_x
        and wrestler_y < opponent_y + opponent_height
        and wrestler_y + wrestler_height > opponent_y
    ):
        show_lose_screen()

    survival_time += 1  # Increase the player's survival time

    screen.fill(white)

    pygame.draw.rect(screen, red, (opponent_x, opponent_y, opponent_width, opponent_height))
    pygame.draw.rect(screen, blue, (wrestler_x, wrestler_y, wrestler_width, wrestler_height))

    # Display survival time
    time_text = font_small.render("Survival Time: {} seconds".format(survival_time // 60), True, blue)
    screen.blit(time_text, (10, 10))

    pygame.display.flip()

    clock.tick(60)