I want to do that enemies spawn random but nothing never happens. My idea was that on some time like 0.1 second there is new random coordinate to spawn enemy but I don't know how to use time.sleep in loop without stopping ALL of the code.
CODE:
import random
import pygame
import sys
pygame.init()
from pygame.locals import*
ran_coordinates_x = random.randint(260, 1160)
ran_coordinates_y = random.randint(260, 730)
def add_enemy(ran_coordinates_x, ran_coordinates_y):
pygame.draw.circle(screen, (255, 0, 255), (ran_coordinates_x, ran_coordinates_y), 20)
while running:
digit = random.randint(1, 100)
if digit < 50:
add_enemy(ran_coordinates_x, ran_coordinates_y)