Reputation: 59
Basically I have created a game with users in pygame. I used a tkinter GUI for my login.
I have wrote the SQL part and it outputs my score when die to my database I used test number for my student number, I don't know how to get it so my user can enter their user ID and that is saved along with their score.
Can anyone help please?
Code:
def gameover():
message = Msg("Game Over")
message.update()
player.kill()
shot.kill()
SQL = 'INSERT INTO TblScore(Score, StudentID) VALUES (' + str(score.value) + ', ' + str(8) + ')'
Databaseconnector.INSERT(SQL)
pygame.quit()
Upvotes: 1
Views: 105
Reputation: 4457
(im not experienced with guis yet, but here's my guess)
you could either save their login id or say x = input('Enter your Login ID") then pull the id out of "x"
Upvotes: 0
Reputation: 11180
You could try something like this:
for event in pygame.event.get():
if (event.type == pygame.KEYDOWN):
if(event.key>= K_a && event.key <= K_z):
s+=chr(event.key)
this will append the pressed key character to your string s.
Upvotes: 1