I made some code for my game using PyGame to spawn an obstacle and im new to coding. It wouldn't spawn the obstacles and so i put a print statement to see when it spawns and it does print but doesn't show up on screen. This is not all the code but instead a minimalistic version of it that only shows the problematic code. no errors show up when running the code
import pygame as pg
import random
pg.init()
obstacle1 = pg.image.load('download1.jpeg')
obstacley = 600#tells object to spawn at top of screen
spawn = random.randint(1,10)
spawned = 0
if spawn == 1 and spawned == 0:
spawn = 0
Obstaclex = random.randint(600,800)#determines where on the top of the screen it spawns with rng
obstaclesize = random.randint(1,5)# determines obstacletype because there are 5 obstacle types that i havent included in this to be as simple as possbile
obstaclespeed = random.randint(3,8)#determines obstaclespeed using rng
spawned = 1
if obstaclesize == 1:
gameDisplay.blit(obstacle1,(obstacley,Obstaclex))
obstacley -= obstaclespeed #changes y position to lower it down the screen to hit player
print ("i have spawned")