Hi guys I was wondering if I could get a bit of help with this. I'm learning Classes in python and trying to incorporate it into my current project for uni.
So below is the code for the class as-well as some variables used by it
def __init__(self, char, startX, startY):
self.char = char
self.startX = startX
self.startY = startY
def drawChar (self):
self.space = pygame.image.load (self.char)
self.space = self.space.convert_alpha()
asteroid = [
Because you tell it to. The code
gameDisplay.blit(self.space, (random.randint(0,display_width), random.randint(0,display_height)))
literally says "blit the image onto the display at a random location." Specifically,
random.randint(0,...) picks random positions from zero to the screen size.
Keep in mind that this display code gets called every time the screen needs to be updated, not just when you start the game. To display at static coordinates, make the coordinates static:
gameDisplay.blit(self.space, (self.startX, self.startY))