New to Python trying to make game with pygame

I made some code for my game using pygame to spawn an obstacle and im new to coding. It wouldnt spawn the obstacles and so i put a print statement to see when it spawns and it does print but doesnt 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
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:       
            obstacley -= obstaclespeed #changes y position to lower it down the screen to hit player
            print ("i have spawned")

Read more here:

Content Attribution

This content was originally published by Andrew1245 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: