Я попытался создать панель общего количества кликов с помощью screen.blit()
(также я хочу, чтобы текст обновлялся при нажатии), я попытался
text = font.render('Your total clicks are',totalbal, True, WHITE)
но это не работает
line 21, in <module>
text = font.render('Your total clicks are',totalbal, True, WHITE)
TypeError: Invalid foreground RGBA argument
Я также пробовал это с str(totalbal)
, но снова не работает.
import pygame, sys, time
from pygame.locals import *
pygame.init()
WHITE = 255,255,255
font = pygame.font.SysFont(None, 44)
baltotal = open("totalbal.txt", "r+")
totalbal = int(baltotal.read())
w = 800
h = 600
screen = pygame.display.set_mode((w,h))
Loop = True
text = font.render('Your total clicks are',totalbal, True, WHITE)
while Loop: # main game loop
...
if event.type == MOUSEBUTTONDOWN: #detecting mouse click
totalbal += cps
print("Your total clicks are", totalbal, end="\r")
...
screen.blit(text, (235,557))
pygame.display.flip()
pygame.display.update()
clock.tick(30)
with open("totalbal.txt", "w") as baltotal:
baltotal.write(str(totalbal))
baltotal.close
pygame.quit()
sys.exit()