Jun 5, 2018 05:27 PM
(This post was last modified: Jun 6, 2018 05:35 AM by WhiteTiger..)
For those who are bored: here is a simple typing game.
Best experience if played directly in command prompt.
To do this; go to the path where you saved the file and type the following:
If Python isn't recognized as a command make sure you add Python to the PATH environmental variable.
Here's the main.py you can copy paste:
(If you're not on windows: change 'cls' to 'clear')
I also do realize that this doesn't give your real wpm because of the random strings but I do think it's still a great time waster.
Feel free to give feedback/share/modify.
Kind regards,
~WT
Best experience if played directly in command prompt.
To do this; go to the path where you saved the file and type the following:
Code
python main.pyIf Python isn't recognized as a command make sure you add Python to the PATH environmental variable.
Here's the main.py you can copy paste:
Code
import time
import random
import os
chars = "abcdefghijklmnopqrstuvwxyz"
TIME = 60
if sys.platform == "linux" or sys.platform == "linux2":
CLEAR = "clear"
elif sys.platform == "win32":
CLEAR = "cls"
def generate_string():
string_length = random.randint(3, 5)
string = ""
for i in range(string_length):
char_index = random.randint(0, len(chars)-1)
char = chars[char_index]
string += char
return string
def get_title(wpm):
if wpm <= 5:
return "Terrible"
elif 5 < wpm <= 10:
return "Bad"
elif 10 < wpm <= 15:
return "Average"
elif 15 < wpm <= 20:
return "Good"
elif 20 < wpm <= 25:
return "Expert"
elif 25 < wpm <= 30:
return "God"
elif 30 < wpm <= 100:
return "Devil"
elif 100 < wpm:
return "Hacker"
def show_info(wpm, cpm, clock, string):
print("Current WPM:", wpm)
print("Current CPM:", cpm)
print("Time left: ", TIME - clock)
print(string)
def show_results(wpm, cpm, title):
print("-----TIME IS UP-----")
print("Your WPM:", wpm)
print("Your CPM:", cpm)
print("Your Title:", title)
print("--------------------")
def game():
os.system(CLEAR)
wpm = 0
cpm = 0
clock = 0
while clock < TIME:
clock = time.clock()
string = generate_string()
show_info(wpm, cpm, clock, string)
correct_input = False
while correct_input is False:
user_input = input()
if user_input == string:
wpm += 1
cpm += len(string)
correct_input = True
os.system(CLEAR)
title = get_title(wpm)
show_results(wpm, cpm, title)
game()(If you're not on windows: change 'cls' to 'clear')
I also do realize that this doesn't give your real wpm because of the random strings but I do think it's still a great time waster.
Feel free to give feedback/share/modify.
Kind regards,
~WT


