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.
Thanks for the long running support
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
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() |