Jan-04-2020, 12:03 PM
Hello,
I have created a game which has an error in the display of the label when I want to close the pygame window, my pygame window is not the problem as it closes fine but I have come across an issue in the output of the label. I have abstracted the code down to deal with the problem at hand. Can someone please point out my mistake.
I have created a game which has an error in the display of the label when I want to close the pygame window, my pygame window is not the problem as it closes fine but I have come across an issue in the output of the label. I have abstracted the code down to deal with the problem at hand. Can someone please point out my mistake.
import pygame import time #pygame initialisation pygame.init() def cover(BACKGROUND, screen): # This is a library function built in which displays the selected shape - this case a rectangle pygame.draw.rect(screen, BACKGROUND, (0, 0, 640, 80)) def font(): #set font for later on use for declaring a window Select_Font = pygame.font.SysFont('arial', 70) return Select_Font #Set Colours Colour_Countdown = (0, 255, 0) BACKGROUND = (0, 0, 0) #pygame window setting screen_size = (640, 640) screen = pygame.display.set_mode(screen_size) #setting font for test LabelFont = font() #code with possible error cover(BACKGROUND, screen) label = LabelFont.render("Closing in ...", 1, Colour_Countdown) #print ("Closing in ...") screen.blit(label, (20,-5)) screen.blit(label, (20,-5)) pygame.time.wait(1000) cover(BACKGROUND, screen) label = LabelFont.render("3", 1, Colour_Countdown) #print ("3") screen.blit(label, (20,-5)) pygame.time.wait(1000) cover(BACKGROUND, screen) label = LabelFont.render("2", 1, Colour_Countdown) #print ("2") screen.blit(label, (20,-5)) pygame.time.wait(1000) cover(BACKGROUND, screen) label = LabelFont.render("1", 1, Colour_Countdown) #print ("1") screen.blit(label, (20,-5)) pygame.time.wait(1000) pygame.quit()Thanks for the long running support