I am trying to write a small piggybank program. I already have a window with some background and text but I need to add a functionality for the user to let him add money to the piggybank. When the user press "1" he can see the text "how much do you want to add?" and here is where my problem begins... It's my third day with programming ever and I don't even know what I am looking for. I want to to show in real time what amount user is typing. Any tips?
Here's my code so far (which I can understand :P)
# wyświetlenie napisów
font = pygame.font.SysFont("comic sans MS", 15, bold=True) #ustawienie czcionki
text = font.render("::Swinka 1.4::",False,(BLACK))
screen.blit(text, [150,0])
pygame.draw.line(screen, BLACK, [0,20], [400,20], 3)
text = font.render("Chlewik",False,(BLACK))
screen.blit(text,[145,50])
text = font.render("Aktualny Stan: " +stan_konta,False,(BLACK))
screen.blit(text,[145,110])
text = font.render("1. Nakarm mnie",False,(BLACK))
screen.blit(text,[10,150])
text = font.render("2. Dieta",False,(BLACK))
screen.blit(text,[10,170])
# obsługa klawiszy
if event.type == pygame.KEYDOWN: # ogólne wywołanie wciśnięcia klawisza
if event.key == pygame.K_2: # naciśnięcie konktretnego przycisku, w tym przypadku "2"
#screen.fill(PINK) # odświeżenie ekranu (wycyszczenie plus pomalowanie)
screen.blit(background, [0,0])
stan_konta = 0 # przypisanie początkowej wartości konta
stan_konta=str(stan_konta) # zamiana z liczb na znaki
plik = open("dane/amount.txt", "w") # zapisanie do pliku
plik.write(stan_konta)
plik.close()
text = font.render("Swinka pusta!",False,(BLACK))
screen.blit(text, [185,170])
if event.key == pygame.K_1:
#screen.fill(PINK)
screen.blit(background, [0,0])
text = font.render("Ile mam zjesc?",False,(BLACK))
screen.blit(text,[185,150])
pygame.display.flip()
pygame.quit()
Here is a short example: