So I have this block of code if the user types what's on screen correctly.
words = ["Games","Development","Keyboard","Speed","Typer","Anything","Alpha","Zealous","Accurate","Basics","Shortcut","Purpose","Window","Counter","Fortress","Modification","Computer","Science","History","Football","Basketball","Solid","Phantom","Battlefield","Advanced","Warfare","Download","Upload","Antidisestablishmentarianism","Supercalifragilisticexpialidocious","Discomobobulation","Liberated","Assassin","Brotherhood","Revelation","Unity","Syndicate","Victory"]
wordcount = 0
maxwords = 12
skips = 0
def nextWord():
global score
global wordcount
global skips
global maxwords
global name
global high_score
entry.focus_set()
if entry.get().lower() == words[1].lower():
score += 1
wordcount += 1
wordcounter.config(text="Words: " + str(wordcount))
And I'd like to know how to stop this block of code from running if they don't type what's on the screen:
for i in range(maxwords):
entry.delete(0, tkinter.END)
random.shuffle(words)
label.config(text=str(words[1]))
scoreLabel.config(text="Time: " + str(score)+ "s")
It continues even if they don't type it correctly because of:
def startGame(event):
nextWord()
root.bind("<Return>", startGame)
I currently have this:
elif entry.get().lower() != words[1].lower():
wronglabel.config(text="WRONG!")
time.sleep(0.6)
wronglabel.delete(0, tkinter.END)
What this currently does is make
wronglabel = tkinter.Label(root, text="", font =("Helvetica, 14"))
wronglabel.pack()
Say wrong but I'd like to know how to make it not randomly shuffle and get items from the list if they user does not enter the correct word. Thanks.
Aucun commentaire:
Enregistrer un commentaire