Confused At Why Pygame Display's A Black Screen
Solution 1:
Problem is your code organization.
You have tree times pygame.display.set_mode(). Every time you call pygame.display.set_mode() you destroy previous screen, create new screen and new screen is always black.
You should create screen only once and send it to other class as parameter.
defaddPane(self, textToDisplay):
myPane = Pane(self.screen) # send screen to Pane
myPane.drawPane(textToDisplay)
# ...classPane():def__init__(self, screen):
self.Screen = screen # get screen And remove pygame.display.set_mode() from clear() function - use one screen to the end of the program.
Now I can see your pane with "hello"
Solution 2:
Ok so I have now solved my problem. (aha novice error).
So in the __init__(self) area within class Pane() I added the line self.Screen.fill((white)) to make it look like this:
def__init__(self):
self.Screen = pygame.display.set_mode((1000,600), 0, 32)
self.font = pygame.font.SysFont('Arial', 25)
self.Screen.fill((white))
I'm not sure if this is the best way to solve the problem but it works. So that's good. However if you think that this isn't a good way to solve the problem then by all means teach me of a better way to solve my problem.
Post a Comment for "Confused At Why Pygame Display's A Black Screen"