Мне нравится делать функцию кнопок и возвращаться, если вы нажмете кнопку
пример:
def button(x,y,w,h,text,mousex,mousey):
hover = False
if mousex > x and mousex < x + w:
if mousey > y and mousey < y + h:
hover = True
#usually i would have a if click but since you only getting mouse pos when click it should be fine
txtobj = sysfont.render(text,True,(0,0,0))
SURFACE.blit(txtobj, (x,y))
return hover #return True if mouse clicked on button
, тогда вы можете вызывать это для каждой буквы. Таким образом, у меня был бы список
alphabet = ["A","B","C","D"...]
, теперь вы можете l oop через них
for i,letter in enumerate(alphabet): # enumerate gets the letter and its position in the list
letter_clicked = button(55 + (100*i),155,55,55,letter,mouseposx,mouseposy)
if letter_clicked:
answermessage.append(letter)
Что касается синих букв, не появляющихся, начните с того, чтобы не надевать их
answermessaged_rect.center = (40 + (i*50), 60) # 50 is a guess
, если это не работает, возможно, попробуйте другой шрифт
Вы можете получить шрифты, выполнив
sysfont = pygame.font.Font(pygame.font.match_font("Calibri"), 46)