Skip to content

Commit

Permalink
Add word file to TypingGame.py
Browse files Browse the repository at this point in the history
  • Loading branch information
deli73 committed Sep 19, 2012
1 parent ead471e commit 11047f9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions TypingGame.py
Expand Up @@ -10,7 +10,7 @@ def openit(name):
def get_words(text):
for i in text:
if len(i.split()) > 5:
words.extend(i.split())
words.extend(i.split())
def clean_text(remove = [',','.','@','%','#','$','*','(',')','^']):
I = 0
for i in lines:
Expand Down Expand Up @@ -46,9 +46,22 @@ def updateSurface(self):
running = False
else:
if word.checkLetter(event.unicode): #event.unicode is the letter the user typed
word = TypingGameWord("Another test!")
try:
wordStr = random.choice(words)
word = TypingGameWord(wordStr)
except:
wordfile = open('TypingGameWords.txt', 'r')
words = wordfile.readlines()
wordStr = random.choice(words).strip('\n')
word = TypingGameWord(wordStr)
wordfile.close()
try:
words.remove(wordStr)
except ValueError:
words.remove(wordStr+'\n')

screen.fill((0,0,0))
screen.blit(word.image, word.rect)
pygame.display.flip()

pygame.quit()
quit()

0 comments on commit 11047f9

Please sign in to comment.