Reputation: 426
I am building my first larger game (an Action RPG) with pygame, and was just starting when I ran into this bizarre bug. I ran my code, and the title screen appeared, like normal, and then when i clicked, it advances, but the screen does not change. Until, I minimize the window. then the screen moves. it is not frozen, because i stuck some print functions in for debugging (that is also how i know it actually advances)
I wont put all the code, just the possibly problematic parts:
def ChoiceScreen():
'''choose which option the player wants'''
print('ChoiceScreen called')
SURFACE.fill(COLOURS['white'])
LabelPlay = pg.font.Font('freesansbold.ttf', 32)
PlaySurf=LabelPlay.render('New Game', True, COLOURS['black'], \
COLOURS['white'])
PlayRect = PlaySurf.get_rect()
PlayRect.center = ((WIN_X // 2), (WIN_Y // 2) - 50)
SURFACE.blit(PlaySurf, PlayRect)
#################################################################
LabelLoad = pg.font.Font('freesansbold.ttf', 32)
LoadSurf=LabelLoad.render('Load Game', True, COLOURS['black'], \
COLOURS['white'])
LoadRect = LoadSurf.get_rect()
LoadRect.center = (WIN_X // 2, WIN_Y // 2)
SURFACE.blit(LoadSurf, LoadRect)
#################################################################
LabelLoadEarlier = pg.font.Font('freesansbold.ttf', 32)
LESurf=LabelLoadEarlier.render('Load Earlier Save', True, COLOURS['black'], \
COLOURS['white'])
LERect = LESurf.get_rect()
LERect.center = (WIN_X // 2, WIN_Y // 2 + 50)
SURFACE.blit(LESurf, LERect)
while True:
for event in pg.event.get():
if event.type == QUIT:
terminate()
elif event.type==MOUSEBUTTONDOWN:
x, y = event.pos
if PlayRect.collidepoint(x,y):
print("PlayRect Clicked")
#more to come
elif LoadRect.collidepoint(x,y):
print("LoadRect Called")
elif LERect.collidepoint(x,y):
print("LERect called")
by the way, COLOURS (I am Canadian) is a dictionary with string keys of RGB tuples, WIN_X is 800, WIN_Y is 600
The IDE i am using is Sublime Text, but i executed it from the Command Prompt, from IDLE, Double Clicking, and from visual studio, all to the same result. I have no clue what to do about it.
Upvotes: 0
Views: 202
Reputation: 9746
You're not updating the screen (pygame.display.update()
) in your game loop
Upvotes: 2