Basically I'm trying to make a title screen for a game I'm making and I hit a bit of a roadblock. Basically I have two buttons to far. One for a 'PLAY' button and the other for a 'QUIT' button. When I click the quit button I wrote down that it would make done = True. Since the loop needs done = False to do the loop. Here is my code:
done = False
# Used to manage how fast the screen updates
clock = pygame.time.Clock()
# Hide the mouse cursor
pygame.mouse.set_visible(False)
# -------- Main Program Loop -----------
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
elif event.type == pygame.MOUSEBUTTONDOWN:
# When the mouse button is pressed, see if we are in contact with
# other sprites:
start_block = pygame.sprite.spritecollide(player, start_block, True)
if len(start_block) >= 1:
quitg.rect.x = 5000
logo.rect.x = 5000
quit_block = pygame.sprite.spritecollide(player, quit_block, True)
if len(quit_block) >= 1:
done = True
#print(score)
#blocks_hit_list = pygame.sprite.spritecollide(player, block_list, True)
#if len(blocks_hit_list) >= 1:
#score +=1
# Set the list of blocks we are in contact with as the list of
# blocks being carried.
#player.carry_block_list = blocks_hit_list
elif event.type == pygame.MOUSEBUTTONUP:
# When we let up on the mouse, set the list of blocks we are
# carrying as empty.
player.carry_block_list = []
all_sprites_list.update()
# Clear the screen
screen.fill(WHITE)
# Draw all the spites
all_sprites_list.draw(screen)
# Limit to 60 frames per second
clock.tick(60)
# Go ahead and update the screen with what we've drawn.
pygame.display.flip()
pygame.quit()