I am trying to make a player counter to where if the player presses the up arrow on the keyboard i want players to go up by one and display the counter going up and the same with down. But the counter isn't showing
import pygame
pygame.init()
pygame.display.set_mode()
pygame.font.init()
Red = (247, 12, 12)
White = (255,255,255)
Blue = (0, 157, 255)
Black=(0,0,0)
X = 1400
Y = 1000
players = 0
display_surface = pygame.display.set_mode((X, Y))
font = pygame.font.Font('freesansbold.ttf', 20)
text = font.render("Player one is:", True, Black, White)
textRect = text.get_rect()
textRect.center = (X // 4.4, Y // 3.6)
str(players)
while True:
display_surface.fill(White)
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit(); #sys.exit() if sys is imported
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_0:
print("Hey, you pressed the key, '0'!")
if event.key == pygame.K_1:
print("Doing whatever")
if event.key == pygame.K_UP:
int(players)
players = players+1
str(players)
text1 = font.render(players, True, Black, White)
text1Rect = text1.get_rect()
text1Rect.center = (X // 4.4, Y // 3)
display_surface.blit(text, textRect)
int(players)
pygame.display.update()