@Luke0/

Writing Game-1

Python 2.7

A experienced Typer Racer type game!

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from timeit import default_timer
from termcolor import colored
import time
import random
import sys


'''
A simple typer racer that tells you your wpm and how many words you
have got wrong.
'''

## Creating the scoreboard
score = [0]

## The list of words it will print for the typer racer
words = ("apply","couch","water","paper","marker","books","movie","popcorn","happy","apple","crazy","desk","ruler","tissue","church","monitor","trophy","journal","telivision","government","comic","complex","hamper")

## variable for the 'for loop'

x = (0)

## This is what happpens when the time is up

def Start():
  intro_question = raw_input("Welcome to SPEEDTYPER!!\nWould you like to play?(yes or no)")
  print (intro_question)
  if intro_question == 'yes':
    score[0] = (0)
    typeracer()
  elif intro_question == 'no':
    sys.exit()
  else:
    WrongInput()

def TimeUP():
  time_up = raw_input("The Time is up try again?\n(yes or no)")
  print(time_up)
  if time_up == 'yes':
    typeracer()
  elif time_up == 'no':
    sys.exit()
  else:
    WrongInput()
    
def WrongInput():
  print colored("WRONG INPUT!!", 'red')
  time.sleep(1.00)
  wrong_question = raw_input("Would you like to play (yes or no)")
  if wrong_question == 'yes':
    typeracer()
  elif wrong_question == 'no':
    sys.exit()
  else:
    WrongInput()
    

## typeracer is the part which the whole typeracer is in

def typeracer():
  print ("Welcome to the typer racer get ready.")
  time.sleep(1.00)
  
  ## starting the timer
  time_start = default_timer()
  
  for x in range(0, 15):
    rndm_number = random.randint(0, 20)
    print (words[rndm_number])
    awnser = raw_input()
    if awnser == words[rndm_number]:
      score[0] = score[0] + 1
      print colored("correct", 'green')
    else:
      print colored("Wrong!", 'red')
      score[0] = score[0] - 1
      
  ## printing the amount you got correct to the screen
  print "Your score is:", score
      

  ## stoping the timer
  time_stop = default_timer()
  
  ## calculating the total total time
  
  totalTime = time_stop - time_start
  float(totalTime)
  
  ## printing the total amount of time it took you to complete the typeracer
  print 'The total time is:', totalTime
  
  Start()
  
      
Start()