I have a couple of objects defined/entered into a variable
car1 = pygame.image.load('C:\Users\itzrb_000\Downloads\download (3).png')
car2 = pygame.image.load('C:\Users\itzrb_000\Downloads\download (2).png')
car3 = pygame.image.load('C:\Users\itzrb_000\Downloads\images.png')
rock = pygame.image.load('C:\Users\itzrb_000\Downloads\Rock.png')
def cars(thingx, thingy):
objects = [car1, car2, car3, rock]
num_of_objects = random.randint(1,4)
for x in range(num_of_objects):
y = random.choice(objects)
thing_startx = random.randrange(130,625)
thing_starty = -600
thing_speed = 10
things(thing_startx, thing_starty, thing_width, thing_height, black)
thing_starty += thing_speed
def things(thingx, thingy, thingw, thingh, color):
pygame.draw.rect(gameDisplay, color, [thingx, thingy, thingw, thingh])
You're blitting the objects off screen.
gameDisplay.blit(y,(random.randrange(130, 625),-300)) will blit the image at x between 130 to 625 and y at -300 (which means 300 to the left of the screen).
But is the function doing what you want it to do? Every loop you're blitting a random number of random objects at random positions. I strongly suggest finding a better tutorial which teaches basics as code structure, good naming, how to use docstrings and object-oriented programming, like this.